double MACDFast(int shift = 0)
{
double result = iCustom(Symbol(),PERIOD_CURRENT,"MACD 2Line",0,shift);
return result;
}
//double MACDSlow(int shift = 0)
{
double result = iCustom(Symbol(),PERIOD_CURRENT,"MACD 2Line",1,shift);
return result;
}
int FuncMACDCrossOver(int shift = 0)
{
int result = 0;
if(MACDFast(1) <= MACDSlow(1) && MACDFast(0) >= MACDSlow(0))
result = 1;
if(MACDFast(1) >= MACDSlow(1) && MACDFast(0) <= MACDSlow(0))
result = 2;
return result;
}
Where I put the Code
if(FuncMACDCrossOver() == 1 && another condition){
//Go Long
}
if(FuncMACDCrossOver() == 2 && another condition){
//Go Short
}
I want to add another condition where the crossover is below MACD 0 value for go long and crossover is above MACD 0 value for go short. The problem is I cannot put FuncMACDCrossOver() < 0 since it is gonna interference with the MACD function. Any tips for making that new condition works?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi guys, I'm using a 2 line MACD in my strategy. My code is like this:
I want to add another condition where the crossover is below MACD 0 value for go long and crossover is above MACD 0 value for go short. The problem is I cannot put FuncMACDCrossOver() < 0 since it is gonna interference with the MACD function. Any tips for making that new condition works?