Hi brains, I want to find the highest and lowest EMA between my current barindex to the previous tradeindex, but the following simple code returns nothing.
Please advise what I have done wrong? Much appreciated.
EMA=exponentialaverage[10](close)
HH=highest[barindex-tradeindex](EMA)
LL=lowest[barindex-tradeindex](EMA)
return HH as "HighestEMA", LL as "LowestEMA"
TRADEINDEX is to be used in a strategy, not in an indicator.
Yes, actually, I am using in a strategy, trying to debug.
In my code, I actually used
graph HH as “HighestEMA”
Nothing came out.
Thanks.
Sometimes it is necessary to make sure you have enough bars before starting to calculate or nothing gets displayed. Try this:
if barindex >= 10 and tradeindex <> 0 then
EMA=exponentialaverage[10](close)
HH=highest[barindex-tradeindex](EMA)
LL=lowest[barindex-tradeindex](EMA)
endif
graph HH as "HighestEMA"
graph LL as "LowestEMA"
Above added as Log 215 here
Snippet Link Library