if (CrossAbove(sma1, sma2, nBarsAgo) bullishSignal = true;
However, I'm not entirely sure that I'm coding correctly for a crossover that involves a displaced moving average. Initially I assumed that the Displacement property on a SMA shifted the entire series, but I believe it only shifts the way it's painted visually, on a plot. So I tried coding my crossover like this:
if (CrossAbove(sma, dma[shift], nBarsAgo) bullishSignal = true;
Where [shift] is the amount that I want to displace the second moving average. I'm not sure that this is working the way I assume it would.
I'm aware that I could simply write some clumsy code that checks to see if (sma[0] > dma[shift]) and (ska[1] < dma[shift+1]), but that gets old fast, especially if you're doing it several times. Plus, I like code that's self-documenting.
Can the CrossAbove() and CrossBelow() methods be used with displaced moving averages? And if so, what's the proper way to code this?

Comment