You are lucky because no more than 254 bars have elapsed (max. lookback for ProScreener):
1
2
3
4
5
6
7
8
MyBar=0
FORi=0to253
IFdate[i]<20180101THEN
MyBar=i-1
break
ENDIF
NEXT
SCREENER[MyBar](MyBaras"MyBar")
You cannot write “= 20180101” because that day could not be a trading day, so once you have found the first day BEFORE that date, you know the bar AFTER that one is the first trading day of this year, it can be different according to instruments that have, since then, accumulated less trading days.
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