Robot_MACD_12.26.9

Profit factor:
0.61
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Indicators Used
MACD Histogram
9 Views
0 Downloads
0 Favorites
Robot_MACD_12.26.9
//+------------------------------------------------------------------+
//|                                               Robot_MACD_12.26.9 |
//|                                                     Tokman Yuriy |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
             //âíåøíèå ïåðåìåííûå
extern double TakeProfit = 300;
extern double Lots = 0.1;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   double MacdCurrent, MacdPrevious, SignalCurrent,SignalPrevious;
   int cnt, ticket, total;

   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);

   total=OrdersTotal();
   if(total<1)//ïðîâåðêà êîëè÷åñòâà îðäåðîâ 
     {
      // ïðîâåðêà ñâîáîäíûõ ñðåäñòâ
      if(AccountFreeMargin()<(1000*Lots))//êîëè÷åñòâî ñâîáîäíûõ ñðåäñòâ
        {
         Print("Íåäîñòàòî÷íî ñðåäñòâ = ", AccountFreeMargin());
         return(0);  
        }
      // îòêðûòèå äëèííîé ïîçèöèè
      if(MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious
         && MacdCurrent<0 && SignalCurrent<0 )
        {
         ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,"-",0,0,Green);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("îòêðûòà ïîçèöèÿ BUY : ",OrderOpenPrice());
           }
         else Print("Îøèáêà ïðè îòêðûòèè BUY ïîçèöèè : ",GetLastError()); 
         return(0);
        }
      // îòêðûòèå êîðîòêîé ïîçèöèè
      if(MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious
         && MacdCurrent>0 && SignalCurrent>0)
        {
         ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,"-",0,0,Red);
         if(ticket>0)
           {
            if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("îòêðûòà ïîçèöèÿ SELL : ",OrderOpenPrice());
           }
         else Print("Îøèáêà ïðè îòêðûòèè SELL ïîçèöèè : ",GetLastError()); 
         return(0); 
        }
      return(0);
     }
   // óñëîâèÿ çàêðûòèÿ îðäåðîâ   
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   // íàëè÷èå îòêðûòûõ îðäåðîâ 
         OrderSymbol()==Symbol())  // ñîâïàäàþò ëè ôèíàíñîâûå èíñòðóìåíòû
        {
         if(OrderType()==OP_BUY)   // îòêðûòà äëèííàÿ ïîçèöèÿ
           {
            // óñëîâèå çàêðûòèÿ
            if(MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious)
                {
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
                 return(0);
                }
           }
         else // îòêðûòà êîðîòêàÿ ïîçèöèÿ
           {
            // óñëîâèå çàêðûòèÿ
            if( MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious)
              {
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
               return(0);
              }
           }
        }
     }
   return(0);
  }

Profitability Reports

NZD/USD Jul 2025 - Sep 2025
0.83
Total Trades 146
Won Trades 49
Lost trades 97
Win Rate 33.56 %
Expected payoff -1.12
Gross Profit 778.00
Gross Loss -942.00
Total Net Profit -164.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.85
Total Trades 153
Won Trades 56
Lost trades 97
Win Rate 36.60 %
Expected payoff -1.46
Gross Profit 1237.40
Gross Loss -1460.90
Total Net Profit -223.50
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.25
Total Trades 157
Won Trades 32
Lost trades 125
Win Rate 20.38 %
Expected payoff -11.03
Gross Profit 575.19
Gross Loss -2306.73
Total Net Profit -1731.54
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.51
Total Trades 151
Won Trades 50
Lost trades 101
Win Rate 33.11 %
Expected payoff -5.89
Gross Profit 909.33
Gross Loss -1798.89
Total Net Profit -889.56
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.05
Total Trades 201
Won Trades 192
Lost trades 9
Win Rate 95.52 %
Expected payoff -497.62
Gross Profit 5692.70
Gross Loss -105713.60
Total Net Profit -100020.90
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.00
Total Trades 151
Won Trades 48
Lost trades 103
Win Rate 31.79 %
Expected payoff 0.02
Gross Profit 949.00
Gross Loss -946.60
Total Net Profit 2.40
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.64
Total Trades 87
Won Trades 30
Lost trades 57
Win Rate 34.48 %
Expected payoff -3.57
Gross Profit 564.23
Gross Loss -874.82
Total Net Profit -310.59
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.50
Total Trades 90
Won Trades 25
Lost trades 65
Win Rate 27.78 %
Expected payoff -5.88
Gross Profit 536.60
Gross Loss -1066.00
Total Net Profit -529.40
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.97
Total Trades 93
Won Trades 43
Lost trades 50
Win Rate 46.24 %
Expected payoff -0.38
Gross Profit 1190.70
Gross Loss -1225.60
Total Net Profit -34.90
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.75
Total Trades 92
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -2.59
Gross Profit 714.70
Gross Loss -952.60
Total Net Profit -237.90
-100%
-50%
0%
50%
100%

Comments