Executer_strong

Author: Copyright � 2006, Alex Sidd (Executer)
Profit factor:
0.62
Price Data Components
Series array that contains open time of each bar
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
Miscellaneous
It plays sound alerts
5 Views
0 Downloads
0 Favorites
Executer_strong
//+------------------------------------------------------------------+
//|                                              Executer_strong.mq4 |
//|                           Copyright © 2006, Alex Sidd (Executer) |
//|                                           mailto:work_st@mail.ru |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Íåêîòîðûå "îáùåïîëåçíûå" ôóíêöèè êîäà, òðåéëèíã ñòîï, íàïðèìåð,  |
//| áûëè ëþáåçíî ïîçàèìñòâîâàíû èç äðóãèõ ýêñïåðòîâ.                 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Alex Sidd (Executer)"
#property link      "mailto:work_st@mail.ru"
//----
#define MAGIC 612457
//----
extern double lStopLoss = 40;
extern double sStopLoss =70;
extern double lTakeProfit = 130;
extern double sTakeProfit = 150;
extern double lTrailingStop = 60;
extern double sTrailingStop = 60;
extern double Lots = 0.90;
extern int a = 3;
extern double DecreaseFactor = 100;
extern double MaximumRisk    = 0.025;
extern double MaximumLots    = 100;
extern double percent = 0.1;
//----
int IsLastBuy = 0;
color clOpenBuy = Blue;
color clCloseBuy = Aqua;
color clOpenSell = Red;
color clCloseSell = Violet;
color clModiBuy = Blue;
color clModiSell = Red;
string Name_Expert = "Executer_Strong";
int Slippage = 0;
bool UseSound = True;
string NameFileSound = "alert.wav";
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsDayStrong()
  {
   double i = 0;
   i = (High[1] - Low[1]);
   if(Close[1] > (High[1] - (i*percent)) && Open[1] < (Low[1] + (i*percent))) 
       return(true);
   else 
       return(false); 
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool IsDayLow()
  {
   double i = 0;
   i = (High[1] - Low[1]);
   if(Close[1] < (Low[1] + (i*percent)) && Open[1] > (High[1] - (i*percent))) 
       return(true);
   else 
       return(false); 
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetSizeLot()
  {
   double Lot = Lots;/*
   int cycle;
   int prof = 0;
   
   int    orders = HistoryTotal();     // history orders total
   int    losses = 0;                  // number of losses orders without a break
   int    vinn = 0;
   int i = orders;
//---- select lot size
  Lot = NormalizeDouble(AccountFreeMargin()*MaximumRisk / 100, 1);
  
  if(AccountFreeMargin() <= 10000 && AccountFreeMargin() > 5000) DecreaseFactor = NormalizeDouble(AccountFreeMargin()/100,1);
  if(AccountFreeMargin() <= 5000 && AccountFreeMargin() > 3000) DecreaseFactor = NormalizeDouble(AccountFreeMargin()/200,1);
  
  if(AccountFreeMargin() <= 14) DecreaseFactor = 14;
  if(AccountFreeMargin() > 10000) DecreaseFactor = 60;
 
   if(DecreaseFactor > 0&&orders>DecreaseFactor)
     {
       for(cycle = 1; cycle < DecreaseFactor; cycle++)
         {
           i--;
           if(OrderSelect(i, SELECT_BY_TICKET, MODE_HISTORY) == false) 
             { 
               Print("Error in history!"); 
               break; 
             }
             
           if(OrderCloseTime()>0)
           {
              prof = prof + OrderProfit(); 
              if(OrderProfit() <= 0 ) losses++;
              else vinn++;
           }
         }
         
      if(prof <= 0 ) Lot = 0.1;//Lot - (0.1*losses); //Lot = 0.1;//&& losses > vinn
      
 //     if(prof <=0 && vinn>losses) Lot = Lot - (0.1*losses);
      
      if(prof > 0 && losses > vinn) 
      {
          Lot = Lot + (0.1*NormalizeDouble(vinn/4,0.1));
      }
      if(prof > 0 && losses <= vinn )
      {
          Lot = Lot + (0.1*NormalizeDouble(vinn/2,0.1));
      }
     } 
   if(AccountFreeMargin()<300||Lot < 0.1) Lot = 0.1;
   if(Lot*1275>=AccountFreeMargin()) Lot = NormalizeDouble(AccountFreeMargin()*MaximumRisk / 100, 1);
   if(MaximumLots != 0 && Lot > MaximumLots) Lot = MaximumLots;
   if(DecreaseFactor > orders) Lot = Lots;*/
   return(Lot);
  }  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+  
void deinit() 
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   if(Bars < 100)
     {
       Print("bars less than 100");
       return(0);
     }
   if(lStopLoss < 3)
     {
       Print("StopLoss less than 3");
       return(0);
     }
   if(lTakeProfit < 3)
     {
       Print("TakeProfit less than 3");
       return(0);
     }
   if(sStopLoss < 3)
     {
       Print("StopLoss less than 3");
       return(0);
     }
   if(sTakeProfit < 3)
     {
       Print("TakeProfit less than 3");
       return(0);
     }
   if(AccountFreeMargin() < (1000*Lots))
     {
       Print("We have no money. Free Margin = ", AccountFreeMargin());
       return(0);
     }
   if(!ExistPositions())
     {
       if(IsDayStrong() == true)
         {
           OpenBuy();
           return(0);
         }

       if(IsDayLow() == true)
         {
           OpenSell();
           return(0);
         }
     }
   TrailingPositionsBuy(lTrailingStop);
   TrailingPositionsSell(sTrailingStop);
   return (0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool ExistPositions() 
  {
	  for(int i = 0; i < OrdersTotal(); i++) 
	    {
		     if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
		       {
			        if(OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC) 
			          {
				           return(True);
			          }
		       } 
	    } 
	  return(false);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void TrailingPositionsBuy(int trailingStop) 
  { 
   for(int i = 0; i < OrdersTotal(); i++) 
     { 
       if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
         { 
           if(OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC) 
             { 
               if(OrderType() == OP_BUY) 
                 { 
                   if(TimeHour(Time[0]) - TimeHour(OrderOpenTime()) == 4)
                       OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clCloseBuy); 
            

                 } 
             } 
         } 
     } 
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void TrailingPositionsSell(int trailingStop) 
  { 
   for(int i = 0; i < OrdersTotal(); i++) 
     { 
       if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
         { 
           if(OrderSymbol() == Symbol() && OrderMagicNumber() == MAGIC) 
             { 
               if(OrderType() == OP_SELL) 
                 { 
                   if(TimeHour(Time[0]) - TimeHour(OrderOpenTime()) == 4)
                       OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clCloseSell);

                 } 
             } 
         } 
     } 
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ModifyStopLoss(double ldStopLoss) 
  { 
   bool fm;
   fm = OrderModify(OrderTicket(), OrderOpenPrice(), ldStopLoss, OrderTakeProfit(), 
                    0, CLR_NONE); 
   if(fm && UseSound) 
       PlaySound(NameFileSound); 
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseBuy() 
  { 
   bool fc; 
   fc = OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clCloseBuy); 
   if(fc && UseSound) 
       PlaySound(NameFileSound); 
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseSell() 
  { 
   bool fc; 
   fc = OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clCloseSell); 
   if(fc && UseSound) 
       PlaySound(NameFileSound); 
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OpenBuy() 
  { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 
   ldLot = GetSizeLot(); 
   ldStop = GetStopLossBuy(); 
   ldTake = GetTakeProfitBuy(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol(), OP_BUY,ldLot, High[1] + 0.0005, Slippage, ldStop, ldTake, 
             lsComm, MAGIC, 0, clOpenBuy); 
   if(UseSound) 
       PlaySound(NameFileSound); 
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OpenSell() 
  { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 
   ldLot = GetSizeLot(); 
   ldStop = GetStopLossSell(); 
   ldTake = GetTakeProfitSell(); 
   lsComm = GetCommentForOrder(); 
   OrderSend(Symbol(), OP_SELL, ldLot, Low[1] - 0.0005, Slippage, ldStop, ldTake,
             lsComm, MAGIC, 0,clOpenSell); 
   if(UseSound) 
       PlaySound(NameFileSound); 
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string GetCommentForOrder() 
  { 	
   return(Name_Expert); 
  } 
//double GetSizeLot() { 	return(Lots); } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetStopLossBuy() 
  { 	
  return(High[1] - ((High[1] - Low[1]) / 2) - 0.0005);
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetStopLossSell() 
  { 	
    return(High[1] - ((High[1] - Low[1]) / 2) + 0.0005); 
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetTakeProfitBuy() 
  { 	
    return(Ask + lTakeProfit*Point); 
  } 
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double GetTakeProfitSell() 
  { 	
    return(Bid - sTakeProfit*Point); 
  } 
//+------------------------------------------------------------------+

Profitability Reports

USD/CHF Jul 2025 - Sep 2025
0.55
Total Trades 38
Won Trades 15
Lost trades 23
Win Rate 39.47 %
Expected payoff -39.44
Gross Profit 1830.87
Gross Loss -3329.41
Total Net Profit -1498.54
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.66
Total Trades 35
Won Trades 16
Lost trades 19
Win Rate 45.71 %
Expected payoff -15.65
Gross Profit 1055.10
Gross Loss -1602.82
Total Net Profit -547.72
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.70
Total Trades 28
Won Trades 12
Lost trades 16
Win Rate 42.86 %
Expected payoff -16.84
Gross Profit 1076.40
Gross Loss -1548.00
Total Net Profit -471.60
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.64
Total Trades 54
Won Trades 26
Lost trades 28
Win Rate 48.15 %
Expected payoff -30.88
Gross Profit 2928.60
Gross Loss -4596.30
Total Net Profit -1667.70
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.47
Total Trades 50
Won Trades 20
Lost trades 30
Win Rate 40.00 %
Expected payoff -36.52
Gross Profit 1634.68
Gross Loss -3460.63
Total Net Profit -1825.95
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.55
Total Trades 65
Won Trades 28
Lost trades 37
Win Rate 43.08 %
Expected payoff -29.34
Gross Profit 2297.41
Gross Loss -4204.49
Total Net Profit -1907.08
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.72
Total Trades 36
Won Trades 17
Lost trades 19
Win Rate 47.22 %
Expected payoff -20.02
Gross Profit 1891.80
Gross Loss -2612.70
Total Net Profit -720.90
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.64
Total Trades 37
Won Trades 18
Lost trades 19
Win Rate 48.65 %
Expected payoff -23.35
Gross Profit 1562.40
Gross Loss -2426.40
Total Net Profit -864.00
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.86
Total Trades 98
Won Trades 48
Lost trades 50
Win Rate 48.98 %
Expected payoff -11.38
Gross Profit 6649.45
Gross Loss -7764.41
Total Net Profit -1114.96
-100%
-50%
0%
50%
100%

Comments