I would create an indicator which show me when moving average changes direction.
For example : indicator=1 when moving average changes and going up
indicator=-1 when moving average is going down
I have written this code :
Code: Select all
Inputs: price(Close), length(10),
zeroLine(0.0), zeroVisible(false),
upColour(Green), downColour(Red), colourDeltaBar(1);
Variables: var0 (0) ;
var0 = jtHMA(price, length);
//when the average changes direction : (moving average is going down)
if var0[2] > var0[1] and var0[1] < var0 then
value2 = 1 ;
//when the average changes direction : (moving average is going up)
if var0[2] < var0[1] and var0[1] > var0 then
value2 = -1 ;
Plot1(Value2, "jtHMA");
Anybody would have an idea please?