MA cross exp_v4

Profit factor:
0.69
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
Moving average indicator
5 Views
0 Downloads
0 Favorites
MA cross exp_v4
//+------------------------------------------------------------------+
//|                                  Copyright 2006, Malinouski Yury |
//|                                          mailto:panzernik@tut.by |
//|                                                      version 4.0 |
//|                                                       01.04.2006 |
//+------------------------------------------------------------------+

// Çà îñíîâó âçÿò ýêñïåðò MA cross.mq4 (àâòîð Alexey42)
// Äîáàâëåíû ñëåäóþùèå ïàðàìåòðû: ma_method, TrailingStop, applied_price
// Ýêñïåðò îòêðûâàåò è çàêðûâàåò ïîçèöèè ïî ôàêòó ïåðåñå÷åíèÿ ñðåäíèõ
// Êòî ñìîæåò ðåàëèçîâàòü âûñòàâëåíèå stop_loss ïî ïàðàáîëèêó?

extern int    ma_fast=8;      // Ïåðèîä áûñòðîé ÌÀ
extern int    ma_slow=21;     // Ïåðèîä ìåäëåííîé ÌÀ
extern double ma_method=1;/*MODE_SMA 0  Ïðîñòîå ñêîëüçÿùåå ñðåäíåå 
                            MODE_EMA 1  Ýêñïîíåíöèàëüíîå ñêîëüçÿùåå ñðåäíåå 
                            MODE_SMMA 2 Ñãëàæåííîå ñêîëüçÿùåå ñðåäíåå 
                            MODE_LWMA 3 Ëèíåéíî-âçâåøåííîå ñêîëüçÿùåå ñðåäíåå 
                             */
extern int    stop_loss=110; 
extern int    take_profit=370;
extern double TrailingStop=110;
extern double applied_price=0;/*PRICE_CLOSE    0 Öåíà çàêðûòèÿ 
                                PRICE_OPEN     1 Öåíà îòêðûòèÿ 
                                PRICE_HIGH     2 Ìàêñèìàëüíàÿ öåíà 
                                PRICE_LOW      3 Ìèíèìàëüíàÿ öåíà 
                                PRICE_MEDIAN   4 Ñðåäíÿÿ öåíà, (high+low)/2 
                                PRICE_TYPICAL  5 Òèïè÷íàÿ öåíà, (high+low+close)/3 
                                PRICE_WEIGHTED 6 Âçâåøåííàÿ öåíà çàêðûòèÿ, (high+low+close+close)/4 */
extern int    ma_shifft=0;     // Ñäâèã èíäèêàòîðà îòíîñèòåëüíî öåíîâîãî ãðàôèêà
extern double Lots=0.1;
double m1=1;
double m2=1;
double s1=1;
double s2=1;
double b=1;
int    cnt=0;
//------------------------------------------------------------------------------------------------------------- 


int start() 
  { 
if (b<Bars)
{
m1=iMA(NULL,0,ma_fast, ma_shifft, ma_method, applied_price, 1);
m2=iMA(NULL,0,ma_fast, ma_shifft, ma_method, applied_price, 2);
s1=iMA(NULL,0,ma_slow, ma_shifft, ma_method, applied_price, 1);
s2=iMA(NULL,0,ma_slow, ma_shifft, ma_method, applied_price, 2);  

  if (OrdersTotal()<1)
{ 
if 
((s2>m2)&&(s1<m1))
{
OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-stop_loss*Point,Ask+take_profit*Point,"buy60",1221,0,Blue);
b=Bars;
}
if 
((s2<m2)&&(s1>m1))
{
OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+stop_loss*Point,Bid-take_profit*Point,"sell60",1222,0,Red);
b=Bars;
}
}
  


for(cnt=0;cnt<4;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELL &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // long position is opened
           {
            // should it be closed?
          if ((s2<m2)&&(s1>m1)&&(b<Bars))
                {b=Bars;
                 OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);                  // close position
                 OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+stop_loss*Point,Bid-take_profit*Point,"sell60",1222,0,Red);
                 return(0); // exit
                }
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Point*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
                     return(0);
                    }
                 }
              }
           }
         else // go to short position
           {
            // should it be closed?
        if ((s2>m2)&&(s1<m1)&&(b<Bars))


              {b=Bars;
               OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);                    // close position
               OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-stop_loss*Point,Ask+take_profit*Point,"buy60",1221,0,Blue);
               return(0); // exit
              }
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }
           }
        }
     }
  

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

Profitability Reports

USD/CAD Jul 2025 - Sep 2025
1.11
Total Trades 51
Won Trades 26
Lost trades 25
Win Rate 50.98 %
Expected payoff 0.43
Gross Profit 219.83
Gross Loss -197.73
Total Net Profit 22.10
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.10
Total Trades 59
Won Trades 5
Lost trades 54
Win Rate 8.47 %
Expected payoff -9.10
Gross Profit 57.10
Gross Loss -594.00
Total Net Profit -536.90
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.67
Total Trades 57
Won Trades 22
Lost trades 35
Win Rate 38.60 %
Expected payoff -2.25
Gross Profit 256.90
Gross Loss -385.00
Total Net Profit -128.10
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.78
Total Trades 54
Won Trades 17
Lost trades 37
Win Rate 31.48 %
Expected payoff -1.20
Gross Profit 229.50
Gross Loss -294.37
Total Net Profit -64.87
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.28
Total Trades 60
Won Trades 12
Lost trades 48
Win Rate 20.00 %
Expected payoff -4.16
Gross Profit 98.81
Gross Loss -348.43
Total Net Profit -249.62
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
1.52
Total Trades 61
Won Trades 30
Lost trades 31
Win Rate 49.18 %
Expected payoff 2.89
Gross Profit 517.30
Gross Loss -341.00
Total Net Profit 176.30
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.62
Total Trades 63
Won Trades 20
Lost trades 43
Win Rate 31.75 %
Expected payoff -2.78
Gross Profit 285.40
Gross Loss -460.50
Total Net Profit -175.10
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
1.08
Total Trades 155
Won Trades 57
Lost trades 98
Win Rate 36.77 %
Expected payoff 0.36
Gross Profit 774.87
Gross Loss -718.91
Total Net Profit 55.96
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.74
Total Trades 149
Won Trades 59
Lost trades 90
Win Rate 39.60 %
Expected payoff -1.93
Gross Profit 829.06
Gross Loss -1116.19
Total Net Profit -287.13
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.74
Total Trades 157
Won Trades 63
Lost trades 94
Win Rate 40.13 %
Expected payoff -1.21
Gross Profit 535.35
Gross Loss -725.55
Total Net Profit -190.20
-100%
-50%
0%
50%
100%

Comments