The only other way is to calculate how many bars between the time now and the time yesterday or the day before but this becomes slightly complicated when you go from day 1 to day 7 and when you want to go back more than 24 hours. Knowing the number of bars back you could then simply use close[n] to get the closing price.
This will tell you what the closing price was at ‘mytime’ yesterday on an hourly chart. Now all you have to do is adapt it for whatever time frame you want to use it on and add in a calculation to know how many bars to add on for the number of extra days back you might want to go. Good luck! 🙂
Obviously it does not work on Monday or Sunday due to the quantity of bars on Sundays.
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