Given a number of moving averages with different periods, I would like to code the first moment when they are arranged by order, for example:
ma1=Average[1]
ma2=Average[2]
ma3=Average[3]
ma4=Average[4]
ma1>ma2>ma3>ma4
and that only candle to use as an entry signal.
Hope I have been clear.
Thanks anybody
Alex
ma1=Average[1]
ma2=Average[2]
ma3=Average[3]
ma4=Average[4]
x = ma1 > ma2 AND ma2 > ma3 AND ma3 > ma4
return x
So.
- x > x[1] will tell you the first bar when they are in order
- x < x[1] will tell you the first bar when they are no more in order
- x <> x[1] will tell you whenever there’s been a change from order to disorder and viceversa
|
|
ma1=Average[1]
ma2=Average[2]
ma3=Average[3]
ma4=Average[4]
x = ma1 > ma2 AND ma2 > ma3 AND ma3 > ma4
return x
|
So.
- x > x[1] will tell you the first bar when they are in order
- x < x[1] will tell you the first bar when they are no more in order
- x <> x[1] will tell you whenever there’s been a change from order to disorder and viceversa
So, if I would code an entry, it would be like:
slope=x-x[1]
if slope crosses over 0 then
buy at market
Am I right?
Yes, sure.
You may also add GRAPH to your code to watch desired values as they change candle after candle.