Profit Generator2

Author: Created in 2006, Open Source Project
Profit factor:
0.32
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
1 Views
0 Downloads
0 Favorites
Profit Generator2
//+------------------------------------------------------------------+
//|                                             Profit Generator.mq4 |
//|                       No Copyright, created in 2006, Open Source |
//|                                         http://www.forex-tsd.com |
//|          Works best on Daily timeframes. Possibly H4 and Weekly. | 
//|        Freely receive, Freely give. Please post updated version. |
//+------------------------------------------------------------------+
#property copyright "Created in 2006, Open Source Project"
#property link      "http://www.forex-tsd.com"

extern int ID;
extern double lots=1.0;
extern bool MM = true; //Use Money Management or not
extern int Risk = 10; //10%


extern int stoploss=30,takeprofit=40;
extern int MaxTrades=1;
extern bool UseHourTrade = False;
extern int  FromHourTrade = 8;
extern int  ToHourTrade = 18;
extern bool UseTrail=false;
extern int TrailingStop=0;

void deinit() {
   Comment("");
}
/*
int gb(){
   int in;
   if(!GlobalVariableCheck("PG2_id_storage")){
      GlobalVariableSet("PG2_id_storage",111112);
      in=111112;
   }else{
      in=NormalizeDouble(GlobalVariableGet("PG2_id_storage"),0);
   }
   return(in);
}
      
 */  
int orderscnt(){
int cnt=0;
   for(int i =0;i<OrdersTotal();i++){
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
         if(OrderSymbol()==Symbol() && ID==OrderMagicNumber()){
            cnt++;
         }
      }
   }
   return(cnt);
}

int start(){
   if(UseTrail)Trailing();
   if(orderscnt()==0){
      if (UseHourTrade){
         if(!(Hour()>=FromHourTrade&&Hour()<=ToHourTrade)){
            Comment("Non-Trading Hours!");
            return(0);
         }
      }
   }
   if (Period() < 30) {Comment("change to M30 or higher pls"); return(0); }
   if(orderscnt()<MaxTrades){
      if(MM==true) lots = LotSize();
      if (MathMod(Minute(),Period()) >= 0.5*Period()) return(0);
      CheckOpen();
   }   
}

void CheckOpen(){ 
  // ID=gb();  
   double tp,sl;
   if ((High[0]-Low[0])>10*Point && Open[0]<(High[0]+Low[0])/2 && Ask < Open[0]){
      if(stoploss==0){sl=0;}else{sl=Ask-stoploss*Point;}
      if(takeprofit==0){tp=0;}else{tp=Ask+takeprofit*Point;}
      OrderSend(Symbol(),OP_BUY,lots,Ask,2,sl,tp,"Profit Generator",ID,0,Blue); 
   }
   if ((High[0]-Low[0])>10*Point && Open[0]>(High[0]+Low[0])/2 && Bid > Open[0]){
      if(stoploss==0){sl=0;}else{sl=Bid+stoploss*Point;}
      if(takeprofit==0){tp=0;}else{tp=Bid-takeprofit*Point;}
      OrderSend(Symbol(),OP_SELL,lots,Bid,2,sl,tp,"Profit Generator",ID,0,Red); 
   }
}
double LotSize(){
   double lotMM = MathCeil(AccountFreeMargin() * Risk / 10000) / 10;
   if (lotMM < 0.1) lotMM = lots;
   if (lotMM > 1.0) lotMM = MathCeil(lotMM);
   if  (lotMM > 100) lotMM = 100;
   return (lotMM);
} 


void Trailing(){
   for(int i=0;i<OrdersTotal();i++){
      if(OrderSelect(i,SELECT_BY_POS) && OrderMagicNumber()==ID && Symbol()==OrderSymbol() ){
         if(OrderType()==OP_BUY){
            if(TrailingStop>0){
               if(Bid-OrderOpenPrice()>Point*TrailingStop){
                  if(OrderStopLoss()<Bid-Point*TrailingStop){
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
                     return(0);
                  }
               }
            }
         }else{
            if(TrailingStop>0){
               if(OrderOpenPrice()-Ask>Point*TrailingStop){
                  if(OrderStopLoss()>Ask+Point*TrailingStop){
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                  }
               }
            }
         }
      }
   }
}

Profitability Reports

GBP/USD Oct 2024 - Jan 2025
0.22
Total Trades 1402
Won Trades 188
Lost trades 1214
Win Rate 13.41 %
Expected payoff -7.11
Gross Profit 2836.00
Gross Loss -12799.90
Total Net Profit -9963.90
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.42
Total Trades 1850
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -5.18
Gross Profit 6976.00
Gross Loss -16557.10
Total Net Profit -9581.10
-100%
-50%
0%
50%
100%

Comments