Number of bars between two reference points
Forums › ProRealTime English forum › ProBuilder support › Number of bars between two reference points
- This topic has 6 replies, 2 voices, and was last updated 4 years ago by
robertogozzi.
-
-
12/12/2017 at 12:07 PM #5548112/12/2017 at 12:25 PM #55487
Bars are identified by their time.
You know what TF your strategy is running on, so in a 30-minute TF the difference between, say, 100000 and 113000 will return 3 bars elapsed.
Is that what you meant?
12/12/2017 at 1:23 PM #55491Thanks for your reply Robertogozzi but not quite what I meant.
I want to know if point B has moved more than x bars from point A, irrespective of time-frame.
So for example, if an instrument has retraced more than 6 bars before detecting a bullish engulfing candle
12/12/2017 at 3:19 PM #55497I 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:
1234567ONCE EventBar = 0a = Average[20](close)b = Average[100](close)IF (a CROSSES OVER b) OR (a CROSSES UNDER b) THEN //in case of any crossingx = BARINDEX - EventBar //x will tell you how many bars have elapsed since the previous crossingEventBar = BARINDEX //make it ready for the next countENDIFRoberto
12/12/2017 at 3:31 PM #5550105/21/2021 at 6:44 AM #170083Hi Roberto,
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?
05/21/2021 at 8:14 AM #170091 -
AuthorPosts
Find exclusive trading pro-tools on