I'm calculating MACD and the histogram values as such and putting an arrow on the chart. Periodically I will get a false crossover signal. Can anyone tell me why and help me fix it?
Thanks very much in advance,
E
MacdCurrent=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_SIGNAL,1);
MacdHist = MacdCurrent - SignalCurrent;
if(MacdHist > 0 && MacdCurrent > SignalCurrent && MacdPrevious < SignalPrevious)
-- Draw Arrow
if(MacdHist < 0 && MacdCurrent < SignalCurrent && MacdPrevious > SignalPrevious)
-- Draw Arrow
Thanks very much in advance,
E
MacdCurrent=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_MAIN,0);
MacdPrevious=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_MAIN,1);
SignalCurrent=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_SIGNAL,0);
SignalPrevious=iMACD(NULL,0,8,17,9,PRICE_CLOSE,MODE_SIGNAL,1);
MacdHist = MacdCurrent - SignalCurrent;
if(MacdHist > 0 && MacdCurrent > SignalCurrent && MacdPrevious < SignalPrevious)
-- Draw Arrow
if(MacdHist < 0 && MacdCurrent < SignalCurrent && MacdPrevious > SignalPrevious)
-- Draw Arrow