Finding a price at a certain time yesterday.

Forums ProRealTime English forum ProBuilder support Finding a price at a certain time yesterday.

Viewing 6 posts - 1 through 6 (of 6 total)
  • #76679

    I am trying to write a code that will find a price at a certain time yesterday…or the day before…etc , does anyone know how this is done?

    TIA

     

    Robert

    #76682

    You’ll have to use FOR…NEXT (or WHILE…WEND). It’s very time consuming!

    If you are on a hourly chart, to retrieve the closing price of yesterday at 090000 you may write (not tested):

    now MyClose will retain yesterday’s CLOSE price at 090000.

    Of course if you’re on a 1-minute chart the lookback period will greatly increase making it difficult to run!

     

    #76683

    Roberto, thank you for your speedy reply, and help.

    Robert

    #76687

    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.

    #76688

    Vonasi- Thank you

    #76692

    Here is an example of what I mean;

    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.

Viewing 6 posts - 1 through 6 (of 6 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login