Hello Everyone,
I would like to ask for your help as for the following issue: is there any code that would let me calculating a number of bars since supertrend indicator was crossed by the price? The beginning of my code is:
If close crosses over supertrend then “rise”
Now the issue is that based on prorealtime handbook, i cannot use barindex to calculate the number of bars starting from the point when price crossed over supertrend.
Thank you in advance for your help.
Kind regards,
Kemel
LeoParticipant
Veteran
Hi, create a variable where to save the moment of crossing. That moment is BarIndex
like:
If close crosses over mySupertrend then
CrossingPosition = barindex
Endif
DistanceToCrossingPosition=Barindex-CrossingPosition