MACD Sample russian

Profit factor:
0.72
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
Indicators Used
MACD HistogramMoving average indicator
7 Views
0 Downloads
0 Favorites
MACD Sample russian
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                  MACD Sample.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+

extern double TakeProfit = 50;
extern double Lots = 0.1;
extern double TrailingStop = 30;
extern double MACDOpenLevel=3;
extern double MACDCloseLevel=2;
extern double MATrendPeriod=26;
double Points;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init ()
  {
   Points = MarketInfo (Symbol(), MODE_POINT);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double MacdCurrent=0, MacdPrevious=0, SignalCurrent=0;
   double SignalPrevious=0, MaCurrent=0, MaPrevious=0;
   int cnt=0, total;
// ïåðâè÷íûå ïðîâåðêè äàííûõ
// âàæíî óäîñòîâåðèòüñÿ ÷òî ýêñïåðò ðàáîòàåò íà íîðìàëüíîì ãðàôèêå è
// ïîëüçîâàòåëü ïðàâèëüíî âûñòàâèë âíåøíèå ïåðåìåííûå (Lots, StopLoss,
// TakeProfit, TrailingStop)
// â íàøåì ñëó÷àå ïðîâåðÿåì òîëüêî TakeProfit
   if(Bars<100)
     {
      Print("bars less than 100");
      return(0);  // íà ãðàôèêå ìåíåå 100 áàðîâ
     }
   if(TakeProfit<10)
     {
      Print("TakeProfit less than 10");
      return(0);  // ïðîâåðÿåì TakeProfit
     }
// ðàäè óïðîùåíèÿ è óñêîðåíèÿ êîäà, ñîõðàíèì íåîáõîäèìûå
// äàííûå èíäèêàòîðîâ âî âðåìåííûõ ïåðåìåííûõ
   MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,0);
   MacdPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1);
   SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
   SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
   MaCurrent=iMA(NULL,0,MATrendPeriod,MODE_EMA,0,PRICE_CLOSE,0);
   MaPrevious=iMA(NULL,0,MATrendPeriod,MODE_EMA,0,PRICE_CLOSE,1);
// òåïåðü íàäî îïðåäåëèòüñÿ - â êàêîì ñîñòîÿíèè òîðãîâûé òåðìèíàë?
// ïðîâåðèì, åñòü ëè ðàíåå îòêðûòûå ïîçèöèè èëè îðäåðû?
   if(OrdersTotal()<1) 
     {
      // íåò íè îäíîãî îòêðûòîãî îðäåðà
      // íà âñÿêèé ñëó÷àé ïðîâåðèì, åñëè ó íàñ ñâîáîäíûå äåíüãè íà ñ÷åòó?
      // çíà÷åíèå 1000 âçÿòî äëÿ ïðèìåðà, îáû÷íî ìîæíî îòêðûòü 1 ëîò
      if(AccountFreeMargin()<(1000*Lots))
        {
         Print("We have no money");
         return(0);  // äåíåã íåò - âûõîäèì
        }
      // ïðîâåðèì, íå ñëèøêîì ëè ÷àñòî ïûòàåìñÿ îòêðûòüñÿ?
      // åñëè ïîñëåäíèé ðàç òîðãîâàëè ìåíåå ÷åì 5 ìèíóò(5*60=300 ñåê)
      // íàçàä, òî âûõîäèì
      // If((CurTime-LastTradeTime)<300) { Exit }
      // ïðîâåðÿåì íà âîçìîæíîñòü âñòàòü â äëèííóþ ïîçèöèþ (BUY)
      if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious &&
         MathAbs(MacdCurrent)>(MACDOpenLevel*Points) && MaCurrent>MaPrevious)
        {
         OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Points,"macd sample",16384,0,Red); // èñïîëíÿåì
         if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
         return(0); // âûõîäèì, òàê êàê âñå ðàâíî ïîñëå ñîâåðøåíèÿ òîðãîâîé îïåðàöèè
            // íàñòóïèë 10-òè ñåêóíäíûé òàéìàóò íà ñîâåðøåíèå òîðãîâûõ îïåðàöèé
        }
      // ïðîâåðÿåì íà âîçìîæíîñòü âñòàòü â êîðîòêóþ ïîçèöèþ (SELL)
      if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
         MacdCurrent>(MACDOpenLevel*Points) && MaCurrent<MaPrevious)
        {
         OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Points,"macd sample",16384,0,Red); // èñïîëíÿåì
         if(GetLastError()==0)Print("Order opened : ",OrderOpenPrice());
         return(0); // âûõîäèì
        };
      // çäåñü ìû çàâåðøèëè ïðîâåðêó íà âîçìîæíîñòü îòêðûòèÿ íîâûõ ïîçèöèé.
      // íîâûå ïîçèöèè îòêðûòû íå áûëè è ïðîñòî âûõîäèì ïî Exit, òàê êàê
      // âñå ðàâíî àíàëèçèðîâàòü íå÷åãî
      return(0);
     };
   // ïåðåõîäèì ê âàæíîé ÷àñòè ýêñïåðòà - êîíòðîëþ îòêðûòûõ ïîçèöèé
   // 'âàæíî ïðàâèëüíî âîéòè â ðûíîê, íî âûéòè - åùå âàæíåå...'
   total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL && // ýòî îòêðûòàÿ ïîçèöèÿ? OP_BUY èëè OP_SELL 
         OrderSymbol()==Symbol())    // èíñòðóìåíò ñîâïàäàåò?
        {
         if(OrderType()==OP_BUY)   // îòêðûòà äëèííàÿ ïîçèöèÿ
           {
            // ïðîâåðèì, ìîæåò óæå ïîðà çàêðûâàòüñÿ?
            if(MacdCurrent>0 && MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious &&
               MacdCurrent>(MACDCloseLevel*Points))
                {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet); // çàêðûâàåì ïîçèöèþ
                 return(0); // âûõîäèì
                };
            // ïðîâåðèì - ìîæåò ìîæíî/íóæíî óæå òðåéëèíã ñòîï ñòàâèòü?
            if(TrailingStop>0)  // ïîëüçîâàòåëü âûñòàâèë â íàñòðîéêàõ òðåéëèíãñòîï
              {                 // çíà÷èò ìû èäåì åãî ïðîâåðÿòü
               if(Bid-OrderOpenPrice()>Points*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Points*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Points*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           }
         else // èíà÷å ýòî êîðîòêàÿ ïîçèöèÿ
           {
            // ïðîâåðèì, ìîæåò óæå ïîðà çàêðûâàòüñÿ?
            if(MacdCurrent<0 && MacdCurrent>SignalCurrent &&
               MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDCloseLevel*Points))
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet); // çàêðûâàåì ïîçèöèþ
               return(0); // âûõîäèì
              }
            // ïðîâåðèì - ìîæåò ìîæíî/íóæíî óæå òðåéëèíã ñòîï ñòàâèòü?
            if(TrailingStop>0)  // ïîëüçîâàòåëü âûñòàâèë â íàñòðîéêàõ òðåéëèíãñòîï
              {                 // çíà÷èò ìû èäåì åãî ïðîâåðÿòü
               if((OrderOpenPrice()-Ask)>(Points*TrailingStop))
                 {
                  if(OrderStopLoss()==0.0 || 
                     OrderStopLoss()>(Ask+Points*TrailingStop))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Points*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           }
        }
     }
   return(0);
  }
// the end.

Profitability Reports

USD/CHF Jul 2025 - Sep 2025
3.18
Total Trades 10
Won Trades 9
Lost trades 1
Win Rate 90.00 %
Expected payoff 2.76
Gross Profit 40.25
Gross Loss -12.64
Total Net Profit 27.61
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
2.59
Total Trades 17
Won Trades 16
Lost trades 1
Win Rate 94.12 %
Expected payoff 1.83
Gross Profit 50.70
Gross Loss -19.60
Total Net Profit 31.10
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
1.68
Total Trades 56
Won Trades 55
Lost trades 1
Win Rate 98.21 %
Expected payoff 1.07
Gross Profit 147.11
Gross Loss -87.36
Total Net Profit 59.75
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
1.44
Total Trades 24
Won Trades 23
Lost trades 1
Win Rate 95.83 %
Expected payoff 0.74
Gross Profit 57.96
Gross Loss -40.14
Total Net Profit 17.82
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
1.23
Total Trades 41
Won Trades 40
Lost trades 1
Win Rate 97.56 %
Expected payoff 0.56
Gross Profit 124.40
Gross Loss -101.40
Total Net Profit 23.00
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
1.08
Total Trades 39
Won Trades 37
Lost trades 2
Win Rate 94.87 %
Expected payoff 0.27
Gross Profit 137.81
Gross Loss -127.24
Total Net Profit 10.57
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.99
Total Trades 16
Won Trades 14
Lost trades 2
Win Rate 87.50 %
Expected payoff -0.04
Gross Profit 53.50
Gross Loss -54.20
Total Net Profit -0.70
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.96
Total Trades 60
Won Trades 58
Lost trades 2
Win Rate 96.67 %
Expected payoff -0.11
Gross Profit 153.88
Gross Loss -160.71
Total Net Profit -6.83
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.82
Total Trades 19
Won Trades 17
Lost trades 2
Win Rate 89.47 %
Expected payoff -0.86
Gross Profit 74.86
Gross Loss -91.23
Total Net Profit -16.37
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.73
Total Trades 33
Won Trades 31
Lost trades 2
Win Rate 93.94 %
Expected payoff -0.72
Gross Profit 65.41
Gross Loss -89.24
Total Net Profit -23.83
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.72
Total Trades 29
Won Trades 27
Lost trades 2
Win Rate 93.10 %
Expected payoff -0.98
Gross Profit 72.30
Gross Loss -100.80
Total Net Profit -28.50
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.69
Total Trades 10
Won Trades 9
Lost trades 1
Win Rate 90.00 %
Expected payoff -1.23
Gross Profit 27.90
Gross Loss -40.20
Total Net Profit -12.30
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.67
Total Trades 37
Won Trades 34
Lost trades 3
Win Rate 91.89 %
Expected payoff -1.12
Gross Profit 85.75
Gross Loss -127.04
Total Net Profit -41.29
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.64
Total Trades 30
Won Trades 28
Lost trades 2
Win Rate 93.33 %
Expected payoff -1.51
Gross Profit 78.94
Gross Loss -124.31
Total Net Profit -45.37
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.55
Total Trades 15
Won Trades 14
Lost trades 1
Win Rate 93.33 %
Expected payoff -2.80
Gross Profit 50.60
Gross Loss -92.60
Total Net Profit -42.00
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.48
Total Trades 34
Won Trades 31
Lost trades 3
Win Rate 91.18 %
Expected payoff -2.66
Gross Profit 85.00
Gross Loss -175.50
Total Net Profit -90.50
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.48
Total Trades 32
Won Trades 30
Lost trades 2
Win Rate 93.75 %
Expected payoff -3.61
Gross Profit 105.30
Gross Loss -220.70
Total Net Profit -115.40
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.39
Total Trades 7
Won Trades 6
Lost trades 1
Win Rate 85.71 %
Expected payoff -2.64
Gross Profit 12.01
Gross Loss -30.52
Total Net Profit -18.51
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.39
Total Trades 24
Won Trades 21
Lost trades 3
Win Rate 87.50 %
Expected payoff -4.04
Gross Profit 61.95
Gross Loss -158.99
Total Net Profit -97.04
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.34
Total Trades 22
Won Trades 17
Lost trades 5
Win Rate 77.27 %
Expected payoff -3.78
Gross Profit 43.13
Gross Loss -126.35
Total Net Profit -83.22
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.33
Total Trades 12
Won Trades 10
Lost trades 2
Win Rate 83.33 %
Expected payoff -5.49
Gross Profit 32.90
Gross Loss -98.80
Total Net Profit -65.90
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.32
Total Trades 25
Won Trades 22
Lost trades 3
Win Rate 88.00 %
Expected payoff -7.42
Gross Profit 87.90
Gross Loss -273.50
Total Net Profit -185.60
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.22
Total Trades 57
Won Trades 54
Lost trades 3
Win Rate 94.74 %
Expected payoff -8.52
Gross Profit 138.05
Gross Loss -623.76
Total Net Profit -485.71
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.17
Total Trades 10
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -14.26
Gross Profit 28.60
Gross Loss -171.20
Total Net Profit -142.60
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.16
Total Trades 6
Won Trades 5
Lost trades 1
Win Rate 83.33 %
Expected payoff -10.15
Gross Profit 11.60
Gross Loss -72.50
Total Net Profit -60.90
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.11
Total Trades 6
Won Trades 4
Lost trades 2
Win Rate 66.67 %
Expected payoff -21.10
Gross Profit 15.50
Gross Loss -142.10
Total Net Profit -126.60
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.06
Total Trades 30
Won Trades 22
Lost trades 8
Win Rate 73.33 %
Expected payoff -28.10
Gross Profit 58.21
Gross Loss -901.17
Total Net Profit -842.96
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.05
Total Trades 25
Won Trades 14
Lost trades 11
Win Rate 56.00 %
Expected payoff -23.65
Gross Profit 32.06
Gross Loss -623.32
Total Net Profit -591.26
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.00
Total Trades 13
Won Trades 13
Lost trades 0
Win Rate 100.00 %
Expected payoff 2.61
Gross Profit 33.94
Gross Loss 0.00
Total Net Profit 33.94
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 115
Won Trades 115
Lost trades 0
Win Rate 100.00 %
Expected payoff 4.71
Gross Profit 541.80
Gross Loss 0.00
Total Net Profit 541.80
-100%
-50%
0%
50%
100%

Comments