AtTheBest-EA_v1.0~_001

Author: Copyright ?2008, At The Best.
Profit factor:
0.77
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 reachedChecks for the total of closed orders
Indicators Used
Stochastic oscillatorLarry William percent range indicatorRelative strength index
Miscellaneous
It sends emails
9 Views
0 Downloads
0 Favorites
AtTheBest-EA_v1.0~_001
/*
   Generated by EX4-TO-MQ4 decompiler V4.0.223.1c []
   Website: http://purebeam.biz
   E-mail : purebeam@gmail.com
*/
#property copyright "Copyright ?2008, At The Best."
#property link      "http://www.metaquotes.net"

extern string EAName = "At The Best v 1.0";
int g_magic_84 = 0;
bool gi_88 = FALSE;
extern bool EachTickMode = TRUE;
extern double Lots = 0.1;
int g_slippage_104 = 3;
extern bool UseStopLoss = FALSE;
extern int StopLoss = 30;
extern bool UseTakeProfit = TRUE;
extern int TakeProfit = 15;
bool gi_124 = FALSE;
int gi_128 = 15;
extern bool UseMM = TRUE;
extern double MaximumRisk = 0.03;
extern bool UseHedge = TRUE;
extern bool UseMicroLot = TRUE;
int g_bars_152;
int gi_156;
string g_comment_160;
bool gi_168 = FALSE;
double g_ord_open_price_172;
bool gi_180 = FALSE;
string gs_unused_184 = "";
string gs_unused_192 = "";
bool gi_unused_208 = FALSE;

double LotsOptimized() {
   double ld_ret_0 = 0.1;
   int li_unused_8 = 0;
   ld_ret_0 = NormalizeDouble(AccountFreeMargin() * MaximumRisk / 1000.0, 2);
   if (UseMicroLot == FALSE) {
      if (ld_ret_0 > 100.0) ld_ret_0 = 100;
      if (ld_ret_0 < 0.1) ld_ret_0 = 0.1;
   } else {
      if (ld_ret_0 > 100.0) ld_ret_0 = 100;
      if (ld_ret_0 < 0.01) ld_ret_0 = 0.01;
   }
   return (ld_ret_0);
}

void CloseAllBuyOrders(string as_0) {
   int l_ord_total_8 = OrdersTotal();
   for (int l_ord_total_12 = l_ord_total_8; l_ord_total_12 >= 0; l_ord_total_12--) {
      if (OrderSelect(l_ord_total_12, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderComment() + "[tp]" == as_0)
            if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, 5, Violet);
         if (OrderSymbol() == Symbol() && DoubleToStr(OrderTicket(), 0) + "[tp]" == as_0)
            if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, 5, Violet);
      }
   }
}

void CloseAllSellOrders(string as_0) {
   int l_ord_total_8 = OrdersTotal();
   for (int l_ord_total_12 = l_ord_total_8; l_ord_total_12 >= 0; l_ord_total_12--) {
      if (OrderSelect(l_ord_total_12, SELECT_BY_POS, MODE_TRADES)) {
         if (OrderSymbol() == Symbol() && OrderComment() + "[tp]" == as_0)
            if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, 5, Violet);
         if (OrderSymbol() == Symbol() && DoubleToStr(OrderTicket(), 0) + "[tp]" == as_0)
            if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, 5, Violet);
      }
   }
}

int start() {
   string ls_unused_0;
   int li_16;
   int l_ord_total_20;
   int l_ticket_24;
   double l_price_28;
   double l_price_36;
   bool li_44;
   double l_istochastic_48;
   double ld_56;
   double l_iwpr_64;
   double ld_72;
   double l_irsi_80;
   double ld_unused_88;
   double l_istochastic_96;
   double ld_104;
   double l_iwpr_112;
   double ld_120;
   double l_irsi_128;
   double ld_unused_136;
   int l_hist_total_144;
   double ld_148;
   double ld_156;
   double l_ord_takeprofit_164;
   double l_ord_open_price_172;
   double l_ord_lots_180;
   string ls_188;
   HideTestIndicators(TRUE);
   string ls_unused_196 = "";
   string ls_unused_204 = "";
   int li_unused_212 = 0;
   string ls_216 = Year() + "-" + Month() + "-" + Day();
   int l_str2time_224 = StrToTime(ls_216);
   if (gi_180 == FALSE) {
      li_16 = 0;
      if (EachTickMode && Bars != g_bars_152) gi_168 = FALSE;
      l_ord_total_20 = OrdersTotal();
      li_16 = 0;
      li_44 = FALSE;
      for (int l_pos_228 = 0; l_pos_228 < l_ord_total_20; l_pos_228++) {
         OrderSelect(l_pos_228, SELECT_BY_POS, MODE_TRADES);
         if (OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
            li_44 = TRUE;
            if (OrderType() == OP_BUY) {
               if (li_16 == 3 && (EachTickMode && !gi_168) || (!EachTickMode && Bars != g_bars_152)) {
                  OrderClose(OrderTicket(), OrderLots(), Bid, g_slippage_104, MediumSeaGreen);
                  if (gi_88) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
                  if (!EachTickMode) g_bars_152 = Bars;
                  li_44 = FALSE;
               } else {
                  if (gi_124 && gi_128 > 0) {
                     if (Bid - OrderOpenPrice() > Point * gi_128) {
                        if (OrderStopLoss() < Bid - Point * gi_128) {
                           OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * gi_128, OrderTakeProfit(), 0, MediumSeaGreen);
                           if (!((!EachTickMode))) continue;
                           g_bars_152 = Bars;
                           continue;
                        }
                     }
                  }
                  if (UseHedge) {
                     OrderSelect(0, SELECT_BY_POS);
                     g_ord_open_price_172 = OrderOpenPrice();
                     g_comment_160 = OrderTicket();
                     if (OrdersTotal() == 1)
                        if (Ask <= g_ord_open_price_172 - TakeProfit * Point) OrderSend(Symbol(), OP_BUY, 2.0 * Lots, Ask, 3, 0, Ask + TakeProfit * Point, g_comment_160, 12345, 0, Green);
                     if (OrdersTotal() == 2) {
                        if (Ask <= g_ord_open_price_172 - TakeProfit * 2 * Point) {
                           OrderSend(Symbol(), OP_BUY, 2.0 * (2.0 * Lots), Ask, 3, 0, Ask + TakeProfit * Point, g_comment_160, 12345, 0, Green);
                           g_magic_84 = 3;
                        }
                     }
                     if (OrdersTotal() == 3) {
                        if (Ask <= g_ord_open_price_172 - 3 * TakeProfit * Point) {
                           OrderSend(Symbol(), OP_BUY, 2.0 * (2.0 * (2.0 * Lots)), Ask, 3, 0, Ask + TakeProfit * Point, g_comment_160, 12345, 0, Green);
                           g_magic_84 = 4;
                        }
                     }
                  }
               }
            } else {
               if (li_16 == 4 && (EachTickMode && !gi_168) || (!EachTickMode && Bars != g_bars_152)) {
                  OrderClose(OrderTicket(), OrderLots(), Ask, g_slippage_104, DarkOrange);
                  if (gi_88) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
                  if (!EachTickMode) g_bars_152 = Bars;
                  li_44 = FALSE;
               } else {
                  if (gi_124 && gi_128 > 0) {
                     if (OrderOpenPrice() - Ask > Point * gi_128) {
                        if (OrderStopLoss() > Ask + Point * gi_128 || OrderStopLoss() == 0.0) {
                           OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * gi_128, OrderTakeProfit(), 0, DarkOrange);
                           if (!((!EachTickMode))) continue;
                           g_bars_152 = Bars;
                           continue;
                        }
                     }
                  }
                  if (UseHedge) {
                     OrderSelect(0, SELECT_BY_POS);
                     g_ord_open_price_172 = OrderOpenPrice();
                     g_comment_160 = OrderTicket();
                     if (OrdersTotal() == 1)
                        if (Bid >= g_ord_open_price_172 + TakeProfit * Point) OrderSend(Symbol(), OP_SELL, 2.0 * Lots, Bid, 3, 0, Bid - TakeProfit * Point, g_comment_160, 12345, 0, Green);
                     if (OrdersTotal() == 2)
                        if (Bid >= g_ord_open_price_172 + TakeProfit * 2 * Point) OrderSend(Symbol(), OP_SELL, 2.0 * (2.0 * Lots), Bid, 3, 0, Bid - TakeProfit * Point, g_comment_160, 12345, 0, Green);
                     if (OrdersTotal() == 3)
                        if (Bid >= g_ord_open_price_172 + 3 * TakeProfit * Point) OrderSend(Symbol(), OP_SELL, 2.0 * (2.0 * (2.0 * Lots)), Bid, 3, 0, Bid - TakeProfit * Point, g_comment_160, 12345, 0, Green);
                  }
               }
            }
         }
      }
      l_istochastic_48 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_156 + 0);
      ld_56 = 5;
      l_iwpr_64 = iWPR(NULL, 0, 14, gi_156 + 0);
      ld_72 = -92;
      l_irsi_80 = iRSI(NULL, 0, 14, PRICE_CLOSE, gi_156 + 0);
      ld_unused_88 = 45;
      l_istochastic_96 = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_MAIN, gi_156 + 0);
      ld_104 = 95;
      l_iwpr_112 = iWPR(NULL, 0, 14, gi_156 + 0);
      ld_120 = -7;
      l_irsi_128 = iRSI(NULL, 0, 14, PRICE_CLOSE, gi_156 + 0);
      ld_unused_136 = 65;
      if (l_istochastic_48 <= ld_56 && l_iwpr_64 <= ld_72) li_16 = 1;
      if (l_istochastic_96 >= ld_104 && l_iwpr_112 >= ld_120) li_16 = 2;
      if (UseMM == TRUE) Lots = LotsOptimized();
      if (li_16 == 1 && (EachTickMode && !gi_168) || (!EachTickMode && Bars != g_bars_152)) {
         if (!li_44) {
            if (AccountFreeMargin() < 1000.0 * Lots) {
               Print("We have no money. Free Margin = ", AccountFreeMargin());
               return (0);
            }
            if (UseStopLoss) l_price_28 = Ask - StopLoss * Point;
            else l_price_28 = 0.0;
            if (UseTakeProfit) l_price_36 = Ask + TakeProfit * Point;
            else l_price_36 = 0.0;
            l_ticket_24 = OrderSend(Symbol(), OP_BUY, Lots, Ask, g_slippage_104, l_price_28, l_price_36, "1st", g_magic_84, 0, DodgerBlue);
            if (l_ticket_24 > 0) {
               if (OrderSelect(l_ticket_24, SELECT_BY_TICKET, MODE_TRADES)) {
                  Print("BUY order opened : ", OrderOpenPrice());
                  if (gi_88) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
               } else Print("Error opening BUY order : ", GetLastError());
            }
            if (EachTickMode) gi_168 = TRUE;
            if (!EachTickMode) g_bars_152 = Bars;
            return (0);
         }
      }
      if (li_16 == 2 && (EachTickMode && !gi_168) || (!EachTickMode && Bars != g_bars_152)) {
         if (!li_44) {
            if (AccountFreeMargin() < 1000.0 * Lots) {
               Print("We have no money. Free Margin = ", AccountFreeMargin());
               return (0);
            }
            if (UseStopLoss) l_price_28 = Bid + StopLoss * Point;
            else l_price_28 = 0.0;
            if (UseTakeProfit) l_price_36 = Bid - TakeProfit * Point;
            else l_price_36 = 0.0;
            l_ticket_24 = OrderSend(Symbol(), OP_SELL, Lots, Bid, g_slippage_104, l_price_28, l_price_36, "1st", g_magic_84, 0, DeepPink);
            if (l_ticket_24 > 0) {
               if (OrderSelect(l_ticket_24, SELECT_BY_TICKET, MODE_TRADES)) {
                  Print("SELL order opened : ", OrderOpenPrice());
                  if (gi_88) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
               } else Print("Error opening SELL order : ", GetLastError());
            }
            if (EachTickMode) gi_168 = TRUE;
            if (!EachTickMode) g_bars_152 = Bars;
            return (0);
         }
      }
      if (OrdersTotal() >= 1) {
         l_hist_total_144 = OrdersHistoryTotal();
         OrderSelect(l_hist_total_144 - 1, SELECT_BY_POS, MODE_HISTORY);
         l_ord_takeprofit_164 = OrderTakeProfit();
         l_ord_open_price_172 = OrderOpenPrice();
         l_ord_lots_180 = OrderLots();
         ld_156 = TakeProfit * Point;
         ls_188 = OrderComment();
         if (OrderType() == OP_BUY) {
            ld_148 = l_ord_takeprofit_164 - l_ord_open_price_172;
            ld_156 = TakeProfit * Point;
            if (NormalizeDouble(ld_148, 4) == NormalizeDouble(ld_156, 4) && l_ord_lots_180 != Lots) CloseAllBuyOrders(ls_188);
         }
         if (OrderType() == OP_SELL) {
            ld_148 = l_ord_open_price_172 - l_ord_takeprofit_164;
            ld_156 = TakeProfit * Point;
            if (NormalizeDouble(ld_148, 4) == NormalizeDouble(ld_156, 4) && l_ord_lots_180 != Lots) CloseAllSellOrders(ls_188);
         }
      }
      if (!EachTickMode) g_bars_152 = Bars;
   }
   return (0);
}

Profitability Reports

USD/CAD Jul 2025 - Sep 2025
1.88
Total Trades 134
Won Trades 76
Lost trades 58
Win Rate 56.72 %
Expected payoff 2.43
Gross Profit 693.49
Gross Loss -368.40
Total Net Profit 325.09
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
1.94
Total Trades 185
Won Trades 109
Lost trades 76
Win Rate 58.92 %
Expected payoff 3.67
Gross Profit 1401.98
Gross Loss -722.76
Total Net Profit 679.22
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
2.21
Total Trades 208
Won Trades 120
Lost trades 88
Win Rate 57.69 %
Expected payoff 3.78
Gross Profit 1438.06
Gross Loss -650.85
Total Net Profit 787.21
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.00
Total Trades 12
Won Trades 4
Lost trades 8
Win Rate 33.33 %
Expected payoff -701.60
Gross Profit 39.67
Gross Loss -8458.87
Total Net Profit -8419.20
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.52
Total Trades 120
Won Trades 61
Lost trades 59
Win Rate 50.83 %
Expected payoff 1.83
Gross Profit 641.37
Gross Loss -421.35
Total Net Profit 220.02
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.01
Total Trades 1294
Won Trades 1277
Lost trades 17
Win Rate 98.69 %
Expected payoff -426.16
Gross Profit 7847.02
Gross Loss -559303.90
Total Net Profit -551456.88
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.97
Total Trades 152
Won Trades 99
Lost trades 53
Win Rate 65.13 %
Expected payoff 3.42
Gross Profit 1058.78
Gross Loss -538.35
Total Net Profit 520.43
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.26
Total Trades 645
Won Trades 383
Lost trades 262
Win Rate 59.38 %
Expected payoff -13.21
Gross Profit 2969.62
Gross Loss -11491.49
Total Net Profit -8521.87
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.18
Total Trades 242
Won Trades 143
Lost trades 99
Win Rate 59.09 %
Expected payoff -31.99
Gross Profit 1750.88
Gross Loss -9493.60
Total Net Profit -7742.72
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
2.03
Total Trades 871
Won Trades 494
Lost trades 377
Win Rate 56.72 %
Expected payoff 2.61
Gross Profit 4486.16
Gross Loss -2212.56
Total Net Profit 2273.60
-100%
-50%
0%
50%
100%

Comments