es_capelast_reversed_ECN_v1

Profit factor:
75.53
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
Miscellaneous
It plays sound alertsIt issuies visual alerts to the screen
5 Views
1 Downloads
0 Favorites
es_capelast_reversed_ECN_v1
//+------------------------------------------------------------------+
//|                                  es_capelast_reversed_ECN_v1.mq4 |
//|                                    Copyright © 2009, OGUZ BAYRAM |
//|                                            es_cape77@hotmail.com |
//+------------------------------------------------------------------+

extern int YourAccountNumber = 123456;
extern double lTakeProfit = 10.0;
extern double sTakeProfit = 10.0;
extern double lStopLoss = 2000.0;
extern double sStopLoss = 2000.0;
extern int max_num_orders = 50;
extern int max_orders_per_symbol = 10;
extern color clOpenBuy = Green;
extern color clOpenSell = Red;
extern string Name_Expert = "es_capelast_reversed_ECN_v1";
extern int magic_number = 789667;
extern int Slippage = 1;
extern bool UseSound = FALSE;
extern string NameFileSound = "Alert.wav";
extern double Lots = 0.1;
extern bool reverseLogic = true;

int gi_ticket_number;
double gd_point;
double gd_digit;
bool gi_accountVerified = FALSE;

int init(){
if (IsDemo() == TRUE){
      gi_accountVerified = TRUE;
      Comment(Name_Expert + " trading on DEMO account");
   }
   if (gi_accountVerified == FALSE) gi_accountVerified = CheckAccountNumber();
   if (gi_accountVerified == TRUE) {
      Comment(Name_Expert + " trading on LIVE account");
   }
   gd_point = SetPoint();
   gd_digit = SetDigit();
}
void deinit() {
   Comment("");
}

int start() {
   if (IsTradeAllowed() == FALSE) return (0);
   
   if (Bars < 100) {
      Print("bars less than 100");
      return (0);
   }
   if (lTakeProfit < 1.0) {
      Print("TakeProfit less than 1");
      return (0);
   }
   if (sTakeProfit < 1.0) {
      Print("TakeProfit less than 1");
      return (0);
   }
   double diClose0 = iClose(NULL, PERIOD_M5, 0);
   double diMA1 = iMA(NULL, PERIOD_M5, 5, 0, MODE_EMA, PRICE_OPEN, 1);
   double diClose2 = iClose(NULL, PERIOD_M5, 0);
   double diMA3 = iMA(NULL, PERIOD_M5, 4, 0, MODE_EMA, PRICE_OPEN, 1);
   if (AccountFreeMargin() < 1000.0 * Lots) {
      Print("We have no money. Free Margin = ", AccountFreeMargin());
      return (0);
   }
   if (!ExistPositions()) {
      if (diClose0 < diMA1) {
         if (reverseLogic) OpenSell();
         else OpenBuy();
         return (0);
      }
      if (diClose2 > diMA3) {
         if (reverseLogic) OpenBuy();
         else OpenSell();
         return (0);
      }
   }
   return (0);
}

//Wait to exit positions if all order slots are full
bool ExistPositions() {
   if ((OrdersTotal() >= max_num_orders ) || (OrderCount() >= max_orders_per_symbol))
      return (TRUE);
   else
      return (FALSE); 
}

//Count orders on current chart symbol
int OrderCount () {
   int count=0;
   for (int j=0; j<OrdersTotal(); j++) {
      if (OrderSelect(j, SELECT_BY_POS, MODE_TRADES))
         if (OrderSymbol() == Symbol()) count++;
   }
   return (count);
}

void OpenBuy() {
   double ldLot = GetSizeLot();
   double ldStop = GetStopLossBuy();
   double ldTake = GetTakeProfitBuy();
   string lsComm = GetCommentForOrder();
   gi_ticket_number = OrderSend(Symbol(), OP_BUY, ldLot, Ask, Slippage, 0, 0, Name_Expert, magic_number, 0, clOpenBuy);
   OrderSelect(gi_ticket_number, SELECT_BY_TICKET);
   OrderModify(OrderTicket(), OrderOpenPrice(), ldStop, ldTake, 0, Blue);
   if (UseSound) PlaySound(NameFileSound);
}

void OpenSell() {
   double ldLot = GetSizeLot();
   double ldStop = GetStopLossSell();
   double ldTake = GetTakeProfitSell();
   string lsComm = GetCommentForOrder();
   gi_ticket_number = OrderSend(Symbol(), OP_SELL, ldLot, Bid, Slippage, 0, 0, Name_Expert, magic_number, 0, clOpenSell);
   OrderSelect(gi_ticket_number, SELECT_BY_TICKET);
   OrderModify(OrderTicket(), OrderOpenPrice(), ldStop, ldTake, 0, Red);
   if (UseSound) PlaySound(NameFileSound);
}

string GetCommentForOrder() {
   return (Name_Expert);
}

double GetSizeLot() {
   return (Lots);
}

double SetPoint() {
   double ld_point;
   if (Digits < 4) ld_point = 0.01;
   else ld_point = 0.0001;
   return (ld_point);
}

double SetDigit() {
   double ld_digit;
   if (Digits < 4) ld_digit = 2;
   else ld_digit = 4;
   return (ld_digit);
}

double GetTakeProfitBuy() {
   return (Ask + lTakeProfit * gd_point);
}

double GetTakeProfitSell() {
   return (Bid - sTakeProfit * gd_point);
}

double GetStopLossBuy() {
   return (Bid - lStopLoss * gd_point);
}

double GetStopLossSell() {
   return (Ask + sStopLoss * gd_point);
}

bool CheckAccountNumber() {
   if (YourAccountNumber == AccountNumber()) return (TRUE);
   Alert("AccountNumber entered is incorrect.\n You entered ", YourAccountNumber);
   return (FALSE);
}

Profitability Reports

USD/CAD Jul 2025 - Sep 2025
0.17
Total Trades 49
Won Trades 39
Lost trades 10
Win Rate 79.59 %
Expected payoff -29.63
Gross Profit 287.33
Gross Loss -1739.05
Total Net Profit -1451.72
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
3.18
Total Trades 251
Won Trades 241
Lost trades 10
Win Rate 96.02 %
Expected payoff 6.58
Gross Profit 2410.00
Gross Loss -757.60
Total Net Profit 1652.40
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.26
Total Trades 523
Won Trades 513
Lost trades 10
Win Rate 98.09 %
Expected payoff 2.01
Gross Profit 5130.00
Gross Loss -4077.60
Total Net Profit 1052.40
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
1.48
Total Trades 469
Won Trades 459
Lost trades 10
Win Rate 97.87 %
Expected payoff 2.28
Gross Profit 3315.59
Gross Loss -2246.09
Total Net Profit 1069.50
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.95
Total Trades 170
Won Trades 160
Lost trades 10
Win Rate 94.12 %
Expected payoff -0.36
Gross Profit 1055.49
Gross Loss -1116.15
Total Net Profit -60.66
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.05
Total Trades 72
Won Trades 66
Lost trades 6
Win Rate 91.67 %
Expected payoff -157.61
Gross Profit 660.00
Gross Loss -12007.80
Total Net Profit -11347.80
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.72
Total Trades 150
Won Trades 140
Lost trades 10
Win Rate 93.33 %
Expected payoff -3.67
Gross Profit 1400.00
Gross Loss -1950.70
Total Net Profit -550.70
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
4.60
Total Trades 2178
Won Trades 2168
Lost trades 10
Win Rate 99.54 %
Expected payoff 5.29
Gross Profit 14729.20
Gross Loss -3201.86
Total Net Profit 11527.34
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
1134.16
Total Trades 965
Won Trades 961
Lost trades 4
Win Rate 99.59 %
Expected payoff 11.70
Gross Profit 11296.20
Gross Loss -9.96
Total Net Profit 11286.24
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
10.48
Total Trades 720
Won Trades 710
Lost trades 10
Win Rate 98.61 %
Expected payoff 6.39
Gross Profit 5089.46
Gross Loss -485.78
Total Net Profit 4603.68
-100%
-50%
0%
50%
100%

Comments