I would like to find some simple code for determining whether a study, such as MACD, has been rising (or falling) for n bars.
Let’s say (as a pure example – I’m picking these indicators out of a hat!) that I wish to enter long if:
a) EMA is rising, and
b) MACD has been rising for n <= 3 bars.
So, to determine b), is there a simple way of effectively counting the number of bars an indicator has been rising?
I think this might be achievable using the slope function and a loop of some sort, but can this be avoided?
Any help with this much appreciated.
Comment