SMC Trader 2 MAs 5 20 EMA1

Download script
Profit factor:
0.50

This automated trading script is designed to manage and execute trades based on momentum shifts identified through moving averages. It functions as an autonomous system that monitors price action, manages open positions, and enters new trades based on specific mathematical crossovers.

Core Operational Logic

1. Market Monitoring & Synchronization The script first ensures it has sufficient historical data to operate correctly. To maintain efficiency and prevent repetitive actions, it is designed to run its primary logic only at the beginning of a new price bar. It also constantly calculates the current "spread" (the difference between the buy and sell prices) to ensure market conditions are being tracked accurately.

2. Technical Indicators The system relies on two different types of Exponential Moving Averages (EMAs):

  • Fast Moving Averages: These react quickly to recent price changes.
  • Slow Moving Averages: These represent the broader, longer-term trend of the market. By comparing these two sets of averages, the script identifies whether the momentum is accelerating or reversing.

3. Entry Strategy (Opening Trades) The script looks for specific "crossover" events to trigger trades:

  • Buy Orders: A purchase is initiated when a fast moving average crosses above a slow moving average, signaling an upward shift in momentum.
  • Sell Orders: A sale is initiated when a fast moving average crosses below a slow moving average, signaling a downward shift in momentum.

Before opening any position, the script performs several safety checks:

  • Account Balance: It verifies that there is sufficient free margin (available funds) to cover the cost of the trade.
  • Position Limits: It ensures that only one trade per symbol is active at any given time to prevent over-leveraging.
  • Historical Frequency: There is a built-in mechanism (currently toggleable) to prevent the system from opening multiple trades in rapid succession on the same bar.

4. Exit Strategy & Trade Management Once a trade is active, the script continuously monitors it for closing signals:

  • Momentum Reversals: If the price action suggests the trend has exhausted—specifically when the fast average moves back across the slow average in the opposite direction of the trade—the script will automatically close the position to preserve profit or minimize loss.
  • Trailing Stop (Optional): The script contains a framework for a trailing stop, which is designed to "follow" the price as it moves in favor of the trade, effectively locking in profits while maintaining room for further gains.

5. User-Defined Parameters The logic is governed by several customizable variables, allowing users to define their risk profile, including:

  • The size of each trade (Lots).
  • The target profit level (Take Profit).
  • The initial safety net (Initial Stop Loss).
  • The sensitivity of the trailing stop.
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
Indicators Used
Moving average indicator
13 Views
0 Downloads
0 Favorites
SMC Trader 2 MAs 5 20 EMA1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                      SMC Autotrader Momentum.mq4 |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

 extern double TakeProfit = 50;
 extern double Lots = 0.1;
 extern double InitialStop = 30;
 extern double TrailingStop = 20;
 
 datetime BarTime;

//#####################################################################
int init()
{
//----

//----
   return(0);
  }
//#####################################################################

int start()
  {
   int cnt,total,ticket,MinDist,tmp;
   double Spread;
//############################################################################
  if(Bars<100){
     Print("bars less than 100");
     return(0);  
  }
//exit if not new bar
 if(BarTime == Time[0]) {return(0);}
//new bar, update bartime
 BarTime = Time[0];
//#########################################################################################
//~~~~~~~~~~~~~~~~Miscellaneous setup stuff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 MinDist=MarketInfo(Symbol(),MODE_STOPLEVEL);
 Spread=(Ask-Bid);
//#########################################################################################
double SMAP1,SMAP2,MMAP1,MMAP2;

SMAP1=iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,1);
SMAP2=iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,2);
MMAP1=iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,1);
MMAP2=iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,2);
//########################################################################################
//##################     ORDER CLOSURE  ###################################################
// If Orders are in force then check for closure against Technicals LONG & SHORT
//CLOSE LONG Entries
  total=OrdersTotal();
  if(total>0)
   { 
   for(cnt=0;cnt<total;cnt++)
   {
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
    if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
     {
     if(SMAP2 > MMAP2 && SMAP1 < SMAP2)
      {                                 
       OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close LONG position
     }}

//CLOSE SHORT ENTRIES: 
    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); 
    if(OrderType()==OP_SELL && OrderSymbol()==Symbol()) // check for symbol
     {
     if(SMAP2 < MMAP2 && SMAP1 > SMAP2)
      {   
       OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close SHORT position
     }}
    }  // for loop return
    }   // close 1st if 
//##############################################################################
//##################     ORDER TRAILING STOP Adjustment  #######################
//TRAILING STOP: LONG
if(0==1)  //This is used to turn the trailing stop on & off
 {
  total=OrdersTotal();
  if(total>0)
   { 
   for(cnt=0;cnt<total;cnt++)
    {
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
     if(OrderType()==OP_BUY && OrderSymbol()==Symbol()
     &&
     Bid-OrderOpenPrice()> (Point*TrailingStop)
     &&
     OrderStopLoss()<Bid-(Point*TrailingStop)
     )
     {OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,White);
           return(0);}
 }}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//TRAILING STOP: SHORT
  total=OrdersTotal();
  if(total>0)
   { 
   for(cnt=0;cnt<total;cnt++)
    {
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
     if(OrderType()==OP_SELL && OrderSymbol()==Symbol()
     &&
     OrderOpenPrice()-Ask > (Point*TrailingStop)
     &&
     OrderStopLoss() > Ask+(Point*TrailingStop) 
     )
     {OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Point*TrailingStop),OrderTakeProfit(),0,Yellow);
          return(0);}
 }}
}  // end bracket for on/off switch
//##########################################################################################
//~~~~~~~~~~~ END OF ORDER Closure routines & Stoploss changes  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
//##########################################################################################
//~~~~~~~~~~~~START of NEW ORDERS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//#########################  NEW POSITIONS ?  ######################################
//Possibly add in timer to stop multiple entries within Period
// Check Margin available
// ONLY ONE ORDER per SYMBOL
// Loop around orders to check symbol doesn't appear more than once
// Check for elapsed time from last entry to stop multiple entries on same bar
if (0==1) // switch to turn ON/OFF history check
{  
 total=HistoryTotal();
 if(total>0)
  { 
   for(cnt=0;cnt<total;cnt++)
    {
     OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);            //Needs to be next day not as below
     if(OrderSymbol()==Symbol()&& CurTime()- OrderCloseTime() < (Period() * 60 )
        )
        {
        return(0);
 }}}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 total=OrdersTotal();
  if(total>0)
   { 
    for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
       if(OrderSymbol()==Symbol()) return(0);
   }
   }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   if(AccountFreeMargin()<(1000*Lots))
   {Print("We have no money. Free Margin = ", AccountFreeMargin());
    return(0);}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//#########################################################################################
//ENTRY RULES: LONG 
 if(SMAP2 < MMAP2 && SMAP1 > MMAP2)
  {
   ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,0,"MaxMin Long",16384,0,Orange); //Bid-(Point*(MinDist+2))
   if(ticket>0)
    {
    if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
     }
     else Print("Error opening BUY order : ",GetLastError()); 
     return(0); 
   } 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//ENTRY RULES: SHORT                                     //################################
 if(SMAP2 > MMAP2 && SMAP1 < MMAP2)
  {
   ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,0,"MaxMin Short",16384,0,Red);
   if(ticket>0)
    {
     if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
      }
      else Print("Error opening SELL order : ",GetLastError()); 
      return(0); 
   }

//####################################################################################
//############               End of PROGRAM                  #########################   
   return(0);
}

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
16 reports
USD/JPY Jul 2025 - Sep 2025
1.09
Total Trades 159
Won Trades 53
Lost trades 106
Win Rate 33.33 %
Expected payoff 0.47
Gross Profit 939.60
Gross Loss -864.60
Total Net Profit 75.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.82
Total Trades 74
Won Trades 23
Lost trades 51
Win Rate 31.08 %
Expected payoff -1.00
Gross Profit 342.02
Gross Loss -415.65
Total Net Profit -73.63
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.70
Total Trades 100
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -2.26
Gross Profit 538.40
Gross Loss -764.40
Total Net Profit -226.00
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.68
Total Trades 147
Won Trades 43
Lost trades 104
Win Rate 29.25 %
Expected payoff -1.60
Gross Profit 502.80
Gross Loss -737.80
Total Net Profit -235.00
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.68
Total Trades 296
Won Trades 81
Lost trades 215
Win Rate 27.36 %
Expected payoff -2.81
Gross Profit 1770.43
Gross Loss -2602.10
Total Net Profit -831.67
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.67
Total Trades 308
Won Trades 89
Lost trades 219
Win Rate 28.90 %
Expected payoff -1.93
Gross Profit 1225.10
Gross Loss -1818.00
Total Net Profit -592.90
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.62
Total Trades 167
Won Trades 51
Lost trades 116
Win Rate 30.54 %
Expected payoff -2.39
Gross Profit 644.95
Gross Loss -1043.46
Total Net Profit -398.51
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.56
Total Trades 179
Won Trades 45
Lost trades 134
Win Rate 25.14 %
Expected payoff -3.44
Gross Profit 793.30
Gross Loss -1409.30
Total Net Profit -616.00
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.47
Total Trades 169
Won Trades 50
Lost trades 119
Win Rate 29.59 %
Expected payoff -2.26
Gross Profit 337.47
Gross Loss -718.62
Total Net Profit -381.15
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.46
Total Trades 100
Won Trades 30
Lost trades 70
Win Rate 30.00 %
Expected payoff -7.36
Gross Profit 631.40
Gross Loss -1367.30
Total Net Profit -735.90
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.37
Total Trades 110
Won Trades 26
Lost trades 84
Win Rate 23.64 %
Expected payoff -4.69
Gross Profit 307.70
Gross Loss -823.90
Total Net Profit -516.20
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.32
Total Trades 310
Won Trades 62
Lost trades 248
Win Rate 20.00 %
Expected payoff -4.80
Gross Profit 710.00
Gross Loss -2198.80
Total Net Profit -1488.80
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.20
Total Trades 165
Won Trades 22
Lost trades 143
Win Rate 13.33 %
Expected payoff -9.30
Gross Profit 390.84
Gross Loss -1926.16
Total Net Profit -1535.32
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.18
Total Trades 186
Won Trades 26
Lost trades 160
Win Rate 13.98 %
Expected payoff -10.68
Gross Profit 432.76
Gross Loss -2419.18
Total Net Profit -1986.42
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.10
Total Trades 315
Won Trades 34
Lost trades 281
Win Rate 10.79 %
Expected payoff -13.50
Gross Profit 493.39
Gross Loss -4746.26
Total Net Profit -4252.87
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 17
Won Trades 5
Lost trades 12
Win Rate 29.41 %
Expected payoff -6207.32
Gross Profit 47.70
Gross Loss -105572.10
Total Net Profit -105524.40
-100%
-50%
0%
50%
100%

Comments