Author: Igor Morozov
Profit factor:
0.06
Orders Execution
It automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategyChecks for the total of open orders
Indicators Used
MACD Histogram
10 Views
0 Downloads
0 Favorites
MACD5MIN
//+------------------------------------------------------------------+
//|                                                     MACD5MIN.mq4 |
//|                                                     Igor Morozov |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Igor Morozov"
#property link      ""

//---- input parameters
extern int       FastEMA=10;
extern int       SlowEMA=26;
extern int       Divergence=8;
extern int       StopLoss=20;
extern int       TakeProfit=20;
extern int       MagicNumber=10268;

int ticket;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
{
//----
   
//----
   return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
{
//----
   
//----
   return(0);
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
//----
	ticket=GetTicket(MagicNumber);
	switch(ticket)
	{
		case 0: // look for entry
		{
			double curMACD=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,1,PRICE_CLOSE,0,1);
			double priMACD=iMACD(NULL,PERIOD_M5,FastEMA,SlowEMA,1,PRICE_CLOSE,0,2);
			// buy signal
			if(curMACD>=Divergence*Point&&priMACD<Divergence*Point) 
				OrderSend(Symbol(),OP_BUY,1,Ask,2,
						Ask-StopLoss*Point,Ask+TakeProfit*Point,"",
						MagicNumber,0,Blue);
			// sell signal
			if(curMACD<=Divergence*Point*(-1)&&priMACD>Divergence*Point*(-1)) 
				OrderSend(Symbol(),OP_SELL,1,Bid,2,
						Bid+StopLoss*Point,Bid-TakeProfit*Point,"",
						MagicNumber,0,Red);
			break;
		}
		default: // look for exit
		{
			if(OrderSelect(ticket,SELECT_BY_TICKET))
			{
				switch(OrderType())
				{
					case OP_BUY:
					{
						if(Bid-OrderOpenPrice()>TakeProfit*Point*0.8)
						{
							double newsl=MathMin(
									OrderOpenPrice()+TakeProfit*Point*0.5,
									Bid-(MarketInfo(Symbol(),MODE_STOPLEVEL)+1)*Point);
							OrderModify(ticket,0,newsl,OrderTakeProfit(),0,Aqua);
						}
						break;
					}
					case OP_SELL:
					{
						if(OrderOpenPrice()-Bid>TakeProfit*Point*0.8)
						{
							newsl=MathMax(
									OrderOpenPrice()-TakeProfit*Point*0.5,
									Ask+(MarketInfo(Symbol(),MODE_STOPLEVEL)+1)*Point);
							OrderModify(ticket,0,newsl,OrderTakeProfit(),0,Orange);
						}
						break;
					}
				}
			}
		}
	}	   
//----
   return(0);
}
//+------------------------------------------------------------------+

int GetTicket(int magic)
{
	for(int i=0;i<OrdersTotal();i++)
	{
		if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
		{
			if(OrderSymbol()==Symbol()&&OrderMagicNumber()==magic)
				return(OrderTicket());
		}
	}
	return(0);
}

Profitability Reports

USD/CAD Oct 2024 - Jan 2025
0.01
Total Trades 671
Won Trades 4
Lost trades 667
Win Rate 0.60 %
Expected payoff -14.54
Gross Profit 59.14
Gross Loss -9812.86
Total Net Profit -9753.72
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.01
Total Trades 523
Won Trades 6
Lost trades 517
Win Rate 1.15 %
Expected payoff -18.79
Gross Profit 57.00
Gross Loss -9884.00
Total Net Profit -9827.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.12
Total Trades 685
Won Trades 140
Lost trades 545
Win Rate 20.44 %
Expected payoff -14.05
Gross Profit 1268.00
Gross Loss -10894.00
Total Net Profit -9626.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.11
Total Trades 693
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -14.19
Gross Profit 1161.00
Gross Loss -10992.00
Total Net Profit -9831.00
-100%
-50%
0%
50%
100%

Comments