Can you help me here?
This a simple study that counts how many bars, in this case, MACD, fills above and below zero line.
The problem is that the counter starts always at 1 and never at zero. I can't understand why. I'm starting the count at zero everytime the bars crosses zero line.
Another strange reaction is although I'm requesting to count the up bars, above zero, it actually counts the down bars, below zero.
Code: Select all
myMACD = MACD(close, fastLength, slowLength);
if myMACD > 0 then begin
upCount = true;
counterUpBars = 0;
downCount = true;
counterDownBars = 0;
if upCount then
counterUpBars = counterUpBars + 1;
if downCount then
counterDownBars = counterDownBars + 1;