I don’t know exactly what you mean, anyway when any event of your choice occurs tou may use BARINDEX to save that bar. At a later moment, whenever you choose to, you may retrueve that value and compare it to the caurrent BARINDEX to know exactly how many bars have elapsed.
This is an example saving the bar number when an average crossing happens and computes the number of bars elapsed from then to the next crossing:
1
2
3
4
5
6
7
ONCEEventBar=0
a=Average[20](close)
b=Average[100](close)
IF(aCROSSES OVERb)OR(aCROSSES UNDERb)THEN//in case of any crossing
x=BARINDEX-EventBar//x will tell you how many bars have elapsed since the previous crossing
EventBar=BARINDEX//make it ready for the next count
I have the highest high during intraday being drawn on current bar. If for example the highest high bar occurred x bars ago and that particular bar had another value drawn on it by an indicator.
How do I make reference to that highest high bar (x bars ago) and have the code also show on current bar the value of the indicator on that x bar?
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue