SMC MACD new idea

Profit factor:
0.93

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

Overall Purpose

This script is designed to automatically place and manage buy and sell orders in the Forex market based on a specific trading strategy. It analyzes price charts, looks for certain patterns, and then executes trades according to those patterns. It also attempts to manage existing trades based on the same indicators.

Key Steps and Logic

  1. Setup and Configuration:

    • The script starts by defining some settings that you, the user, can adjust. These include:
      • Lots: The size of each trade (how much currency to buy or sell).
      • TakeProfit: A target profit level for each trade, expressed in points (a unit of price movement).
      • RiskPercent: How much of your account balance you're willing to risk on each trade.
      • SignalLifeBars: How long a buy or sell signal is considered valid.
      • PVoffset: An offset value.
  2. Market Analysis:

    • The script calculates values from various technical indicators (MACD and PSAR). Think of these indicators as tools that analyze price movements and suggest potential buy or sell opportunities.
    • It uses these indicators in the buy and sell rules.
  3. Buy and Sell Signal Generation:

    • The script has a set of rules to determine when to generate buy or sell signals based on indicator values.
    • The rules essentially look for specific patterns in the indicator values to identify potential upward (buy) or downward (sell) trends.
  4. Order Placement:

    • If a buy signal is triggered, the script sends a "buy" order to the trading platform. If a sell signal is triggered, it sends a "sell" order.
    • Before placing an order, the script checks if you have enough money in your account to cover the trade.
  5. Order Management (Stop Loss and Take Profit)

    • The script attempts to manage positions setting a stop loss and take profit prices based on indicator values.
  6. Order Closure

    • The script checks if the current indicator values conflict with the trade in place, indicating a change of trend. If this is the case the script closes the current trade.

Important Considerations

  • Automated Trading: This script automates the trading process. Once it's running, it will place and manage orders without your direct intervention.
  • Risk: Trading Forex involves risk. This script is based on a specific trading strategy, but there's no guarantee that it will be profitable. It's essential to understand the risks involved before using it.
  • Customization: The settings at the beginning of the script can be adjusted to fine-tune the trading strategy. Experimenting with these settings can impact the script's performance.
  • Complexity: The trading strategy itself is complex, relying on several technical indicators and specific rules. Understanding the logic behind these indicators is important for effective use.

In simple terms, this script is like a robot trader that watches the market, looks for patterns, and automatically buys or sells currency based on those patterns. It also attempts to manage existing trades based on the indicator patterns.

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
MACD HistogramParabolic Stop and Reverse system
Miscellaneous
It issuies visual alerts to the screenIt sends emails
16 Views
0 Downloads
0 Favorites
SMC MACD new idea
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                           SMC.mq4 
//|                                                                  +
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+

 extern double Lots = 0.1; 

 extern int    TakeProfit = 100;
 extern double RiskPercent = 1;
 extern int    SignalLifeBars =24;
 extern int    PVoffset = 2;
 
 bool   BuySignal,SellSignal;
 string  LastOrder;
 string  Trend;
 datetime BarTime;
//#####################################################################
int init()
{
//----
LastOrder="xxxx";
//----
   return(0);
  }
//#############################################################################

int start()
  {
   double SL,TP,Spread, ATR, MinDist,MaxRisk;

   double PSARP0,PSARP1;
   double VSMAP0,VSMAP1,SMAP1,MMAP1,LMAP1,VLMAP1,VSMAP1Low,VSMAP1High;

   string MaxRiskStr;
   string Trading;

   bool   Buy,Sell;

   int    total,ticket,err,tmp,cnt;
   int    NumberofPositions;

  if(Bars<100){Print("bars less than 100"); return(0); }
   
//################################################################################
//~~~~~~~~~~~~~~~~Miscellaneous setup stuff~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 MinDist=(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point);
 Spread=(Ask-Bid);
 MaxRisk=(AccountFreeMargin()*RiskPercent/100)*Point;
 MaxRiskStr=DoubleToStr(MaxRisk,4);

//~~~~~~~~~~~~~~~~~~INDICATOR CALCULATIONS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

double LMACDHP1,LMACDSP1,SMACDHP1,SMACDSP1;
double LMACDHP2,LMACDSP2,SMACDHP2,SMACDSP2;

LMACDHP1=iMACD(NULL,0,89,144,22,PRICE_CLOSE,MODE_MAIN,1);
LMACDSP1=iMACD(NULL,0,89,144,22,PRICE_CLOSE,MODE_SIGNAL,1);
LMACDHP2=iMACD(NULL,0,89,144,22,PRICE_CLOSE,MODE_MAIN,2);
LMACDSP2=iMACD(NULL,0,89,144,22,PRICE_CLOSE,MODE_SIGNAL,2);

SMACDHP1=iMACD(NULL,0,8,21,5,PRICE_CLOSE,MODE_MAIN,1);
SMACDSP1=iMACD(NULL,0,8,21,5,PRICE_CLOSE,MODE_SIGNAL,1);
SMACDHP2=iMACD(NULL,0,8,21,5,PRICE_CLOSE,MODE_MAIN,2);
SMACDSP2=iMACD(NULL,0,8,21,5,PRICE_CLOSE,MODE_SIGNAL,2);

PSARP1=iSAR(NULL,0,0.02,0.2,1);

 if(BarTime == Time[0]) {return(0);}
 BarTime = Time[0];

//##############################################################################
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~         
//BUY and SELL rules:
//~~~~~~~~~~~~BUY~~~~~~~~~~~~~~~~~~~~~~~~
SL=0;
TP=0;
 if((LMACDHP1>0&&LMACDHP1>LMACDSP1&&SMACDHP2<SMACDSP2&&SMACDHP1>SMACDSP1)//Long Term UP new Short term signal
     ||
    (LMACDHP2<0&&LMACDHP1>0)  //Long trend changes
     ||
    (LMACDHP1>0&&LMACDHP1>LMACDSP1&&SMACDHP2<0&&SMACDHP1>0))  //Long term trend UP and Short term change top UP
   {
   Buy = true;
    LastOrder = " Buy ";
    }

//~~~~~~~~~~~SELL~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 if((LMACDHP1<0&&SMACDHP1<0&&LMACDHP1<LMACDSP1&&SMACDHP2>SMACDSP2&&SMACDHP1<SMACDSP1)//Long Term UP new Short term signal
     ||
    (LMACDHP2>0&&LMACDHP1<0)  //Long trend changes
     ||
    (LMACDHP1<0&&LMACDHP1<LMACDSP1&&SMACDHP2>0&&SMACDHP1<0))  //Long term trend UP and Short term change top UP

    {Sell=true;
     LastOrder = " Sell ";
     }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//##################################################################################
//~~~~~~~~~~~~~~~~  POSITION MANAGEMENT  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if(0==1)
{
total=OrdersTotal();
  if(total>0)
   { 
   for(cnt=0;cnt<total;cnt++)
    { 
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
     if(OrderType()==OP_BUY && OrderSymbol()==Symbol())    
     { 
      SL=PSARP1;

      if(SL > OrderStopLoss())
      {OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0,Orange);}
       }}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  total=OrdersTotal();
  if(total>0)
   { 
   for(cnt=0;cnt<total;cnt++)
    {
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
     if(OrderType()==OP_SELL && OrderSymbol()==Symbol())   
     {
      
      SL=PSARP1;

      if(SL != 0)
       {
       if(SL < OrderStopLoss() || OrderStopLoss()==0 )
        {OrderModify(OrderTicket(),OrderOpenPrice(),SL,OrderTakeProfit(),0,Orange);}
       }}}}
}
//##################################################################################
//~~~~~~~~~~~~~~~~  ORDER CLOSURE  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if(0==0)
{
//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() &&
         LMACDHP1 < LMACDSP1)
       {
        OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); 
   }}}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//CLOSE SHORT ENTRIES: 
 
   total=OrdersTotal();
   if(total>0)
    { 
    for(cnt=0;cnt<total;cnt++)
     {  
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); 
      if(OrderType()==OP_SELL && OrderSymbol()==Symbol() &&
         LMACDHP1 > LMACDSP1)
       {
        OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // close SHORT position
   }}}
}
//##########################################################################################
//##########################################################################################
//~~~~~~~~~~~ END OF ORDER Closure routines & Stoploss changes  ~~~~~~~~~~~~~~~~~~~~
//##################################################################################
//~~~~~~~~~~~~START of NEW ORDERS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   if(AccountFreeMargin()<(1000*Lots))
   {Print("Insufficient funds available. Free Margin = ", AccountFreeMargin());
    return(0);}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 NumberofPositions = 0;
 total=OrdersTotal();
  if(total>0)
   { 
    for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
       if(OrderSymbol()==Symbol()) NumberofPositions=NumberofPositions+1;
       }
//may require extra code to determine exposure on any one pair
       if (NumberofPositions >=50) return(0);
   }

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//OPEN ORDER: LONG 
 if(Buy==true) 
  {Buy=false;

   ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,SL,TP,LastOrder,070177,0,Orange); //Bid-(Point*(MinDist+2))
   if(ticket>0)
    { 
     if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) 
      {Print("BUY order opened : ",OrderOpenPrice());
       Alert("Buy Order for ",Symbol());
       SendMail("Buy Order "+Symbol()+" "+Ask,SL);     
       }
     }
     else Print("Error opening BUY order : ",GetLastError()); 
     return(0); 
   } 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//OPEN ORDER: SHORT                                   
 if(Sell==true) 
  {Sell=false;

   ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,SL,TP,"Flying Knives" + LastOrder,070177,0,Red);
   if(ticket>0)
    {
      if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) 
       {Print("SELL order opened : ",OrderOpenPrice());
        Alert("Sell Order for ",Symbol());
        SendMail("Sell Order "+Symbol()+" "+Bid,Bid); 
        }
      }
      else Print("Error opening SELL order : ",GetLastError()); 
      return(0); 
   }

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

Profitability Reports

GBP/CAD Jul 2025 - Sep 2025
4.08
Total Trades 45
Won Trades 27
Lost trades 18
Win Rate 60.00 %
Expected payoff 23.15
Gross Profit 1379.79
Gross Loss -338.09
Total Net Profit 1041.70
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
2.99
Total Trades 116
Won Trades 64
Lost trades 52
Win Rate 55.17 %
Expected payoff 34.64
Gross Profit 6032.85
Gross Loss -2014.65
Total Net Profit 4018.20
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
2.25
Total Trades 64
Won Trades 32
Lost trades 32
Win Rate 50.00 %
Expected payoff 16.99
Gross Profit 1959.24
Gross Loss -872.04
Total Net Profit 1087.20
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.79
Total Trades 120
Won Trades 54
Lost trades 66
Win Rate 45.00 %
Expected payoff 11.71
Gross Profit 3189.30
Gross Loss -1784.40
Total Net Profit 1404.90
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.69
Total Trades 54
Won Trades 24
Lost trades 30
Win Rate 44.44 %
Expected payoff 11.71
Gross Profit 1551.30
Gross Loss -918.90
Total Net Profit 632.40
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
1.25
Total Trades 34
Won Trades 16
Lost trades 18
Win Rate 47.06 %
Expected payoff 7.15
Gross Profit 1203.90
Gross Loss -960.90
Total Net Profit 243.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
1.13
Total Trades 55
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 2.50
Gross Profit 1181.00
Gross Loss -1043.60
Total Net Profit 137.40
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
1.03
Total Trades 96
Won Trades 42
Lost trades 54
Win Rate 43.75 %
Expected payoff 0.66
Gross Profit 2358.10
Gross Loss -2294.60
Total Net Profit 63.50
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
1.00
Total Trades 47
Won Trades 15
Lost trades 32
Win Rate 31.91 %
Expected payoff -0.02
Gross Profit 847.10
Gross Loss -848.10
Total Net Profit -1.00
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.85
Total Trades 139
Won Trades 44
Lost trades 95
Win Rate 31.65 %
Expected payoff -4.73
Gross Profit 3798.14
Gross Loss -4455.50
Total Net Profit -657.36
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.82
Total Trades 108
Won Trades 37
Lost trades 71
Win Rate 34.26 %
Expected payoff -6.01
Gross Profit 2928.50
Gross Loss -3577.40
Total Net Profit -648.90
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.82
Total Trades 111
Won Trades 37
Lost trades 74
Win Rate 33.33 %
Expected payoff -1.67
Gross Profit 855.40
Gross Loss -1040.40
Total Net Profit -185.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.78
Total Trades 51
Won Trades 17
Lost trades 34
Win Rate 33.33 %
Expected payoff -6.47
Gross Profit 1171.90
Gross Loss -1502.00
Total Net Profit -330.10
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.78
Total Trades 118
Won Trades 42
Lost trades 76
Win Rate 35.59 %
Expected payoff -4.32
Gross Profit 1791.60
Gross Loss -2300.89
Total Net Profit -509.29
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.65
Total Trades 100
Won Trades 36
Lost trades 64
Win Rate 36.00 %
Expected payoff -3.43
Gross Profit 626.31
Gross Loss -969.60
Total Net Profit -343.29
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.60
Total Trades 117
Won Trades 42
Lost trades 75
Win Rate 35.90 %
Expected payoff -12.81
Gross Profit 2246.12
Gross Loss -3744.87
Total Net Profit -1498.75
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.55
Total Trades 55
Won Trades 13
Lost trades 42
Win Rate 23.64 %
Expected payoff -8.12
Gross Profit 535.60
Gross Loss -982.40
Total Net Profit -446.80
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.54
Total Trades 109
Won Trades 32
Lost trades 77
Win Rate 29.36 %
Expected payoff -10.77
Gross Profit 1369.28
Gross Loss -2543.10
Total Net Profit -1173.82
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.53
Total Trades 63
Won Trades 17
Lost trades 46
Win Rate 26.98 %
Expected payoff -7.23
Gross Profit 513.90
Gross Loss -969.70
Total Net Profit -455.80
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.44
Total Trades 123
Won Trades 29
Lost trades 94
Win Rate 23.58 %
Expected payoff -19.51
Gross Profit 1881.94
Gross Loss -4281.83
Total Net Profit -2399.89
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.38
Total Trades 111
Won Trades 29
Lost trades 82
Win Rate 26.13 %
Expected payoff -14.08
Gross Profit 978.30
Gross Loss -2541.70
Total Net Profit -1563.40
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.32
Total Trades 107
Won Trades 23
Lost trades 84
Win Rate 21.50 %
Expected payoff -16.05
Gross Profit 801.80
Gross Loss -2519.60
Total Net Profit -1717.80
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.24
Total Trades 62
Won Trades 14
Lost trades 48
Win Rate 22.58 %
Expected payoff -14.79
Gross Profit 290.18
Gross Loss -1207.39
Total Net Profit -917.21
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.24
Total Trades 100
Won Trades 24
Lost trades 76
Win Rate 24.00 %
Expected payoff -19.32
Gross Profit 623.46
Gross Loss -2555.89
Total Net Profit -1932.43
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.13
Total Trades 61
Won Trades 9
Lost trades 52
Win Rate 14.75 %
Expected payoff -26.54
Gross Profit 231.84
Gross Loss -1850.50
Total Net Profit -1618.66
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.07
Total Trades 49
Won Trades 4
Lost trades 45
Win Rate 8.16 %
Expected payoff -27.30
Gross Profit 105.89
Gross Loss -1443.63
Total Net Profit -1337.74
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 3
Won Trades 0
Lost trades 3
Win Rate 0.00 %
Expected payoff -35085.07
Gross Profit 0.00
Gross Loss -105255.20
Total Net Profit -105255.20
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 5
Won Trades 0
Lost trades 5
Win Rate 0.00 %
Expected payoff -21102.26
Gross Profit 0.00
Gross Loss -105511.30
Total Net Profit -105511.30
-100%
-50%
0%
50%
100%

Comments