5_8MACROSS2

Author: Copyright � 2006, MetaQuotes Software Corp.
Profit factor:
0.43
Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
Indicators Used
Moving average indicator
7 Views
0 Downloads
0 Favorites
5_8MACROSS2
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                   5_8MACROSS.mq4 |
//|                      Copyright © 2006, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

extern double Lots=0.1;
extern int StopLoss=0;
extern int TrailingStop=0;
extern int TakeProfit=0;

extern int mafastperiod=5;
extern int mafastshift=0;
extern int mafastmethod =MODE_EMA;
extern int mafastprice=PRICE_CLOSE;

extern int maslowperiod=8;
extern int maslowshift=0;
extern int maslowmethod =MODE_EMA;
extern int maslowprice=PRICE_OPEN;

datetime TimePrev=0;

//+-----------------------------------------------------------------+

int init()
   {
   return(0);
   }

//+-----------------------------------------------------------------+

int deinit()
   {
   return(0);
   }

//+-----------------------------------------------------------------+

int start()
   {
   //Trailing Stop
   TrailingAlls(TrailingStop);
   //close/Open
   if (TimePrev==Time[0])
      return(0);
   TimePrev=Time[0];
   
   //Caculate indicators
   double fast1=iMA(NULL,0,mafastperiod,mafastshift,mafastmethod,mafastprice,1);
   double fast2=iMA(NULL,0,mafastperiod,mafastshift,mafastmethod,mafastprice,2);
   double slow1=iMA(NULL,0,maslowperiod,maslowshift,maslowmethod,maslowprice,1);
   double slow2=iMA(NULL,0,maslowperiod,maslowshift,maslowmethod,maslowprice,2);

   //LONG
   if (fast1>slow1&&fast2<slow2)
      {
      closeshrts();
      OrderSend(Symbol(),OP_BUY,Lots,Ask,0,Stoplong(Ask,StopLoss),Takelong(Ask,TakeProfit),NULL,0,0,Blue);
      }//long

   //shrt
   if(fast1<slow1&&fast2>slow2)
      {
      closelongs();
      OrderSend(Symbol(),OP_SELL,Lots,Bid,0,Stopshrt(Bid,StopLoss),Takeshrt(Bid,TakeProfit),NULL,0,0,Red);
      }//shrt
   return(0);
   }
//+-----------------------------------------------------------------+

double Stoplong(double price,int stop)
   {
   if(stop==0)
      return (0.0);
   return(price-(stop*Point));
   }

//+-----------------------------------------------------------------+

double Stopshrt(double price,int stop)
   {
   if (stop==0)
      return(0.0);
   return(price+(stop*Point));
   }

//+-----------------------------------------------------------------+

double Takelong(double price,int Take)
   {
   if (Take==0)
      return(0.0);
   return(price+(Take*Point));
   }

//+-----------------------------------------------------------------+

double Takeshrt(double price,int Take)
   {
   if (Take==0)
      return(0.0);
   return(price-(Take*Point));
   }

//+-----------------------------------------------------------------+

void closelongs()
   {
   int trade;
   int trades=OrdersTotal();
   for (trade=0;trade<trades;trade++)
      {
      
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol())
         continue;
      
      if(OrderType()==OP_BUY)
         OrderClose(OrderTicket(),OrderLots(),Bid,0,Blue);
      }//for
   }

//+-----------------------------------------------------------------+

void closeshrts()
   {
   int trade;
   int trades=OrdersTotal();
   for (trade=0;trade<trades;trade++)
      {
      
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol())
         continue;
         
      if(OrderType()==OP_SELL)
         OrderClose(OrderTicket(),OrderLots(),Ask,0,Red);
      }//for
   }

//+-----------------------------------------------------------------+

void TrailingAlls(int trail)
   {
   if(trail==0)
      return;

   double stopcrnt;
   double stopcal;

   int trade;
   int trades=OrdersTotal();
   for(trade=0;trade<trades;trade++)
      {
      OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol())
         {
         //continue;
         }
      //LONG
      if(OrderType()==OP_BUY)
         {
         stopcrnt=OrderStopLoss();
         stopcal=Bid-(trail*Point);
         if (stopcrnt==0)
            {
            OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Blue);
            }
         else
            if(stopcal>stopcrnt)
               {
               OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Blue);
               }
         }//LONG
      //Shrt
      if(OrderType()==OP_SELL)
         {
         stopcrnt=OrderStopLoss();
         stopcal=Ask+(trail*Point);
         if (stopcrnt==0)
            {
            OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Red);
            }
         else
            if(stopcal<stopcrnt)
               {
               OrderModify(OrderTicket(),OrderOpenPrice(),stopcal,OrderTakeProfit(),0,Red);
               }
         }//Shrt
      }
   }
  
//+------------------------------------------------------------------+

Profitability Reports

USD/CAD Jul 2025 - Sep 2025
0.46
Total Trades 424
Won Trades 79
Lost trades 345
Win Rate 18.63 %
Expected payoff -2.57
Gross Profit 910.08
Gross Loss -1999.97
Total Net Profit -1089.89
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.45
Total Trades 451
Won Trades 81
Lost trades 370
Win Rate 17.96 %
Expected payoff -3.07
Gross Profit 1138.10
Gross Loss -2521.20
Total Net Profit -1383.10
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.51
Total Trades 427
Won Trades 84
Lost trades 343
Win Rate 19.67 %
Expected payoff -4.50
Gross Profit 2030.40
Gross Loss -3952.30
Total Net Profit -1921.90
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.13
Total Trades 472
Won Trades 41
Lost trades 431
Win Rate 8.69 %
Expected payoff -12.37
Gross Profit 854.78
Gross Loss -6694.86
Total Net Profit -5840.08
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.60
Total Trades 397
Won Trades 95
Lost trades 302
Win Rate 23.93 %
Expected payoff -3.17
Gross Profit 1903.16
Gross Loss -3162.40
Total Net Profit -1259.24
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 41
Won Trades 12
Lost trades 29
Win Rate 29.27 %
Expected payoff -2573.62
Gross Profit 189.30
Gross Loss -105707.80
Total Net Profit -105518.50
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.52
Total Trades 459
Won Trades 88
Lost trades 371
Win Rate 19.17 %
Expected payoff -2.44
Gross Profit 1190.10
Gross Loss -2309.10
Total Net Profit -1119.00
-100%
-50%
0%
50%
100%
USD/CHF Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.94
Total Trades 210
Won Trades 59
Lost trades 151
Win Rate 28.10 %
Expected payoff -0.35
Gross Profit 1126.60
Gross Loss -1199.07
Total Net Profit -72.47
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.46
Total Trades 222
Won Trades 42
Lost trades 180
Win Rate 18.92 %
Expected payoff -4.66
Gross Profit 871.80
Gross Loss -1907.10
Total Net Profit -1035.30
-100%
-50%
0%
50%
100%

Comments