Hi,
I ‘m trying to code a ProScreener indicator using two timeframes, 15 minutes and 5 minutes. How do I test a condition on the 15 minutes timeframe has been met within the last, say 10 bars, while on the 5 minute time frame?
See the example code below where the “long” condition is what I’m trying to figure out
//long
TIMEFRAME(15 minutes)
ma1=ExponentialAverage[200](close)
stochk=Stochastic[8,3](close)
a1=close>ma1
a2=(stochk crosses over 20) or (stochk crosses over 50 and mo>0)
l1=a1 and a2
TIMEFRAME(5 minutes)
ma2=ExponentialAverage[200](close)
mo=Momentum[12]
stochk1=Stochastic[8,3](close)
b1=close>ma2
b2=(stochk1 crosses over 20) or (stochk1 crosses over 50 and mo>0)
l2= b1 and b2
long=l2 and <l1=1 in the last 10 bars of the 15 minute timeframe>
“long” as in line 16 of the above code.
So if I understand correctly your request, you want to return immediately the stocks that fulfilled the conditions of your 5 minutes timeframe, while the conditions of the 15 minutes timeframe were met at least 1 time within the last 10 bars?
Ok, so please find below the modified code accordingly to this condition testing on the 15 minutes timeframe:
//long
TIMEFRAME(15 minutes)
ma1=ExponentialAverage[200](close)
stochk=Stochastic[8,3](close)
a1=close>ma1
a2=(stochk crosses over 20) or (stochk crosses over 50 and mo>0)
l1=summation[10](a1 and a2)>0
TIMEFRAME(5 minutes)
ma2=ExponentialAverage[200](close)
mo=Momentum[12]
stochk1=Stochastic[8,3](close)
b1=close>ma2
b2=(stochk1 crosses over 20) or (stochk1 crosses over 50 and mo>0)
l2= b1 and b2
screener [l1 and l2]
It now should operate correctly, please let us know!
Thanks Nicolas, much appreciated as always.