SMC HiLo v1.1

Profit factor:
55.68

Okay, here's a breakdown of what the provided MetaTrader script does, explained in a way that doesn't require any programming knowledge:

The script is designed to automatically trade on the Forex market. It aims to identify potential buying and selling opportunities based on price movements. It's set up to run automatically within the MetaTrader platform and perform actions without constant manual intervention.

Here's a step-by-step explanation of its logic:

  1. Setup and Configuration:

    • The script starts by defining several adjustable settings. These settings are like the dials and knobs on a machine, letting you fine-tune how it operates. They include:
      • TakeProfit: The amount of profit (in points) the script aims to make on each trade.
      • Lots: The size of the trade (how much currency to buy or sell).
      • InitialStop: How far away (in points) from the trade entry point to place the initial stop-loss order.
      • TrailingStop: How far the price must move in a favorable direction before the stop-loss order starts to automatically adjust to protect profits.
      • SetHour: The hour of the day (using a 24-hour clock) when the script will try to place new trades.
  2. Initial Checks:

    • The script first performs several checks to ensure it's operating in a valid environment. For example, it makes sure there's enough data available on the chart (at least 100 bars) and that the TakeProfit setting is a reasonable value.
    • It also calculates the spread (the difference between the buying and selling price) for the currency pair.
  3. Automated Stop Loss Modification: *A process is set up to manage the position stop loss automatically based on price fluctuations.

  4. Order Management (If Trades Are Already Open):

    • The script then checks if there are any open trades. If there are, it goes through a loop to manage them. It considers two key actions:
      • Closing Trades: The script checks if the conditions for closing existing trades are met.
      • Trailing Stop Adjustment: The script checks if the price has moved favorably enough to trigger the trailing stop feature. If so, it adjusts the stop-loss order to lock in profits.
  5. Placing New Orders:

    • This is the core part of the script. If no trades are currently open for the specific currency pair, the script proceeds to look for opportunities to place new orders.
    • Time Check: First, it checks if the current hour matches the SetHour setting. This ensures that the script only tries to place new orders during a specific time window.
    • Account Check: The script verifies that there is enough available margin in the trading account to place the desired trade size. This prevents the script from attempting to open trades that the account cannot afford.
    • **Order Placement:**The script calculates the HighPrice and LowPrice
      • If everything is ok, the script then calculates price levels.
      • It then places two pending orders: a "Buy Stop" order (an order to buy if the price goes up to a certain level) and a "Sell Stop" order (an order to sell if the price goes down to a certain level). The InitialStop and TakeProfit settings determine the placement of the stop-loss and take-profit levels for these orders. In some cases, instead of placing pending orders, it immediately places buy or sell orders.
  6. Looping and Repetition:

    • The script is designed to run continuously. After performing its checks and actions, it waits for the next "tick" (a price update) and then repeats the process. This allows it to automatically monitor the market and manage trades in real-time.

In essence, this script is an automated trading system that aims to identify potential trading opportunities, place orders, and manage those orders by adjusting stop-loss levels and closing trades when certain conditions are met. It is designed to operate based on a specific time of day and predefined risk and reward parameters.

Price Data Components
Series array that contains open time of each bar
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Moving average indicator
10 Views
0 Downloads
0 Favorites
SMC HiLo v1.1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                      SMC MaxMin at 1200.mq4 |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

 double TakeProfit = 500;
 double Lots = 0.1;
 double InitialStop = 10;
 double TrailingStop = 30;
 int SetHour = 15;
 
 int cnt,total,ticket,MinDist;
 int SigPos;

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



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

int start()
  {

   int Flag;
   
   double Spread;
   double ATR;
   double StopMA;
   int cnt, tmp;
   double SetupHigh, SetupLow;
// initial data checks
// it is important to make sure that the expert works with a normal
// chart and the user did not make any mistakes setting external 
// variables (Lots, StopLoss, TakeProfit, 
// TrailingStop) in our case, we check TakeProfit
// on a chart of less than 100 bars

  Spread=(Ask-Bid);
//############################################################################
  if(Bars<100){
     Print("bars less than 100");
     return(0);  
  }
  if(TakeProfit<10){
     Print("TakeProfit less than 10");
     return(0);  // check TakeProfit
  }
 
   
//#########################################################################################
//~~~~~~~~~~~~~~~~Miscellaneous setup stuff
 //TrailingStop=iATR(NULL,0,10,0)*2; // BE CAREFUL OF EFFECTING THE AUTO TRAIL STOPS
 StopMA=iMA(NULL,0,24,0,MODE_SMA,PRICE_CLOSE,0);
 
//#########################################################################################
if (TimeHour(CurTime()) == SetHour+1)
{
if (total>0)
  {
  for(cnt=0;cnt<total;cnt++)
   {  
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
     if(OrderType()==OP_BUYSTOP && OrderSymbol()==Symbol())
      {OrderDelete ( OrderTicket() );
 } } }}
//##########################################################################################
//ALWAYS TRY TO COME OUT WITH A PROFIT:
if(0==1)
{
 total=OrdersTotal();
 if (total>0)
  {
  for(cnt=0;cnt<total;cnt++)
   {  
//LONG
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
     if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
      {
       if(OrderStopLoss() < OrderOpenPrice())
      {
       if (OrderStopLoss() < Bid -(Point*(MinDist*2)))
       {
        OrderModify(OrderTicket(),OrderOpenPrice(),Bid -(Point*(2*MinDist)),OrderTakeProfit(),0,Lime);
        }}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// SHORT
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
     if(OrderType()==OP_SELL && OrderSymbol()==Symbol())
      {
       if(OrderStopLoss() > OrderOpenPrice())
        {
         if (OrderStopLoss() > Ask + (Point*(MinDist*2)))
        {
         OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Point*(MinDist*2)),OrderTakeProfit(),0,Lime);
        }}}
  }}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//##################     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())
//##############################################################################
//##   LONG Closure Rules   ###
      {
      if(0==1)
//##############################################################################
       {                                 
        OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // close LONG position
        return(0);
        }}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//CLOSE SHORT ENTRIES: 
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); 
      if(OrderType()==OP_SELL && OrderSymbol()==Symbol()) // check for symbol
//##############################################################################
//##  SHORT Closure Rules  ##
      {
      if(0==1)
//##############################################################################
       {   
        OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close SHORT position
        return(0);
        }}
     }  // for loop return
    }   // close 1st if 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//##################     ORDER TRAILING STOP Adjustment  #######################
//TRAILING STOP: LONG
  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(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,White);
                     Print("Long S/L Should be modified here ",OrderStopLoss()," ",Bid-Point*TrailingStop," ",Bid);
      }}}}}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//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())
      {
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,White);
      }}}}}

//##########################################################################################
//~~~~~~~~~~~ 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
// ADD in code to elimante spikes
// Loop around orders to check symbol doesn't appear more than once
// Check for elapsed time from last entry
tmp= TimeHour(CurTime());
 // Print(" time ",tmp);

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);
       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 
 double MinDist = (MarketInfo(Symbol(),MODE_STOPLEVEL)*Point);
 double HighPrice, LowPrice; 
 if(MinDist-(High[1] - Ask) > 0) HighPrice = High[1]+ (MinDist-(High[1] - Ask));
 if(MinDist-(High[1] - Ask) < 0) HighPrice = High[1];
 if(MinDist-(Bid -Low[1]) > 0) LowPrice = Low[1]+ (MinDist-(Bid -Low[1]));
 if(MinDist-(Bid -Low[1]) < 0) LowPrice = Low[1];
//Print(SetHour," ",LowPrice," ",HighPrice);

  if (TimeHour(CurTime()) == SetHour)
  {
//Place BUY Stop order 
   ticket=OrderSend(Symbol(),OP_BUYSTOP,Lots,HighPrice+(1*Point),3,Low[1]-(30*Point),Ask+(TakeProfit*Point),"MaxMin Long",16384,0,Orange); 
   if(ticket>0)
    {
    if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUYSTOP order opened : ",OrderOpenPrice());
     }
    else // Place  actual Order
     {
      Print("Error opening BUYSTOP order : ",GetLastError()); 
      ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Low[1]-(30*Point),Ask+(TakeProfit*Point),"MaxMin Long",16384,0,Yellow); 
       if(ticket>0)
        {
         if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
          }
        else Print("Error opening BUY order : ",GetLastError()); 
      }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ticket=OrderSend(Symbol(),OP_SELLSTOP,Lots,LowPrice-(1*Point),3,Ask+(30*Point),Bid-(TakeProfit*Point),"MaxMin Long",16384,0,Red); 
    if(ticket>0)
     {
      if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELLSTOP order opened : ",OrderOpenPrice());
       }
     else
      {
       Print("Error opening SELLSTOP order : ",GetLastError()); 
       ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+(30*Point),Bid-(TakeProfit*Point),"MaxMin Long",16384,0,Pink); 
     if(ticket>0)
     {
      if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
       }
      else Print("Error opening SELL order : ",GetLastError()); 
      }






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

Profitability Reports

EUR/USD Jul 2025 - Sep 2025
986.23
Total Trades 40
Won Trades 28
Lost trades 12
Win Rate 70.00 %
Expected payoff 2633.03
Gross Profit 105428.20
Gross Loss -106.90
Total Net Profit 105321.30
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
653.82
Total Trades 55
Won Trades 29
Lost trades 26
Win Rate 52.73 %
Expected payoff 1913.37
Gross Profit 105396.30
Gross Loss -161.20
Total Net Profit 105235.10
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
3.32
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 66.67 %
Expected payoff 4.12
Gross Profit 17.67
Gross Loss -5.32
Total Net Profit 12.35
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
2.73
Total Trades 5
Won Trades 4
Lost trades 1
Win Rate 80.00 %
Expected payoff 4.09
Gross Profit 32.28
Gross Loss -11.81
Total Net Profit 20.47
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
2.67
Total Trades 12
Won Trades 10
Lost trades 2
Win Rate 83.33 %
Expected payoff 2.31
Gross Profit 44.38
Gross Loss -16.61
Total Net Profit 27.77
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
2.32
Total Trades 12
Won Trades 10
Lost trades 2
Win Rate 83.33 %
Expected payoff 1.89
Gross Profit 39.76
Gross Loss -17.13
Total Net Profit 22.63
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
2.20
Total Trades 5
Won Trades 4
Lost trades 1
Win Rate 80.00 %
Expected payoff 2.93
Gross Profit 26.84
Gross Loss -12.19
Total Net Profit 14.65
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.64
Total Trades 58
Won Trades 41
Lost trades 17
Win Rate 70.69 %
Expected payoff 2.23
Gross Profit 330.10
Gross Loss -200.80
Total Net Profit 129.30
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
1.43
Total Trades 71
Won Trades 53
Lost trades 18
Win Rate 74.65 %
Expected payoff 1.02
Gross Profit 240.50
Gross Loss -168.40
Total Net Profit 72.10
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
1.27
Total Trades 120
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 0.66
Gross Profit 367.20
Gross Loss -288.60
Total Net Profit 78.60
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.25
Total Trades 31
Won Trades 21
Lost trades 10
Win Rate 67.74 %
Expected payoff 0.71
Gross Profit 107.90
Gross Loss -86.00
Total Net Profit 21.90
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
1.05
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 66.67 %
Expected payoff 0.18
Gross Profit 10.62
Gross Loss -10.08
Total Net Profit 0.54
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
1.03
Total Trades 111
Won Trades 84
Lost trades 27
Win Rate 75.68 %
Expected payoff 0.10
Gross Profit 359.76
Gross Loss -348.15
Total Net Profit 11.61
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
1.02
Total Trades 169
Won Trades 107
Lost trades 62
Win Rate 63.31 %
Expected payoff 0.05
Gross Profit 483.05
Gross Loss -474.42
Total Net Profit 8.63
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.93
Total Trades 80
Won Trades 53
Lost trades 27
Win Rate 66.25 %
Expected payoff -0.22
Gross Profit 246.90
Gross Loss -264.30
Total Net Profit -17.40
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.92
Total Trades 38
Won Trades 23
Lost trades 15
Win Rate 60.53 %
Expected payoff -0.38
Gross Profit 164.00
Gross Loss -178.50
Total Net Profit -14.50
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.92
Total Trades 36
Won Trades 21
Lost trades 15
Win Rate 58.33 %
Expected payoff -0.32
Gross Profit 125.20
Gross Loss -136.60
Total Net Profit -11.40
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.85
Total Trades 81
Won Trades 46
Lost trades 35
Win Rate 56.79 %
Expected payoff -0.57
Gross Profit 263.11
Gross Loss -309.51
Total Net Profit -46.40
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.74
Total Trades 140
Won Trades 90
Lost trades 50
Win Rate 64.29 %
Expected payoff -0.76
Gross Profit 304.87
Gross Loss -411.64
Total Net Profit -106.77
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.74
Total Trades 40
Won Trades 23
Lost trades 17
Win Rate 57.50 %
Expected payoff -1.04
Gross Profit 117.90
Gross Loss -159.50
Total Net Profit -41.60
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.68
Total Trades 84
Won Trades 57
Lost trades 27
Win Rate 67.86 %
Expected payoff -1.11
Gross Profit 194.40
Gross Loss -287.70
Total Net Profit -93.30
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.59
Total Trades 109
Won Trades 77
Lost trades 32
Win Rate 70.64 %
Expected payoff -1.47
Gross Profit 231.96
Gross Loss -391.78
Total Net Profit -159.82
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.57
Total Trades 15
Won Trades 9
Lost trades 6
Win Rate 60.00 %
Expected payoff -3.17
Gross Profit 62.10
Gross Loss -109.60
Total Net Profit -47.50
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.41
Total Trades 32
Won Trades 22
Lost trades 10
Win Rate 68.75 %
Expected payoff -2.11
Gross Profit 47.23
Gross Loss -114.77
Total Net Profit -67.54
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.39
Total Trades 126
Won Trades 73
Lost trades 53
Win Rate 57.94 %
Expected payoff -3.29
Gross Profit 264.60
Gross Loss -678.90
Total Net Profit -414.30
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.23
Total Trades 12
Won Trades 6
Lost trades 6
Win Rate 50.00 %
Expected payoff -6.22
Gross Profit 22.60
Gross Loss -97.30
Total Net Profit -74.70
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.21
Total Trades 86
Won Trades 40
Lost trades 46
Win Rate 46.51 %
Expected payoff -6.96
Gross Profit 159.65
Gross Loss -758.30
Total Net Profit -598.65
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.19
Total Trades 62
Won Trades 25
Lost trades 37
Win Rate 40.32 %
Expected payoff -8.76
Gross Profit 129.38
Gross Loss -672.25
Total Net Profit -542.87
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.17
Total Trades 58
Won Trades 14
Lost trades 44
Win Rate 24.14 %
Expected payoff -6.17
Gross Profit 75.50
Gross Loss -433.57
Total Net Profit -358.07
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.00
Total Trades 3
Won Trades 3
Lost trades 0
Win Rate 100.00 %
Expected payoff 5.23
Gross Profit 15.70
Gross Loss 0.00
Total Net Profit 15.70
-100%
-50%
0%
50%
100%

Comments