Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PriorDayOHLC() appears to return incorrect prices

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PriorDayOHLC() appears to return incorrect prices

    I am running a test strategy with only this statement in the OnBarUpdate() section:

    Code:
    Print(
          DateTime.Today.ToString("yyyy-MM-dd") + "," +
          ​TradingHours.GetPreviousTradingDayEnd(Time[0]).Date.ToString("yyyy-MM-dd") + "," +
          ​PriorDayOHLC().PriorOpen[0].ToString() + "," +
          ​PriorDayOHLC().PriorHigh[0].ToString() + "," +
          PriorDayOHLC().PriorLow[0].ToString() + "," +
          PriorDayOHLC().PriorClose[0].ToString()
         );​
    When I run this in a chart for instrument ES 12-22, the output window shows the following:
    2022-11-05,2022-11-03,3777.25,3782.5,3704.25,3728.25

    As I am running this on Saturday, 2022-11-05, the previous trading day should be Friday, 2022-11-04 instead of the returned date of 2022-11-03. Also, the OHLC prices that are returned are incorrect for 2022-11-04 and for 2022-11-03. According to CME, the OHLC prices for those dates are
    2022-11-04, 3724.00, 3805.50, 3711.00, 3772.75
    2022-11-03, 3766.75, 3782.50, 3704.25, 3727.75

    My questions are
    1. Why is this statement returning an incorrect date for the previous trading day's end?
    2. What do the returned OHLC prices correspond to?
    3. How do I obtain the correct date of the previous session's end day?
    4. How do I obtain the correct OHLC prices for the previous session?

    #2
    Hello Red_70,

    Thanks for your post.

    "the previous trading day should be Friday, 2022-11-04 instead of the returned date of 2022-11-03. Also, the OHLC prices that are returned are incorrect for 2022-11-04 and for 2022-11-03. According to CME, the OHLC prices for those dates are
    2022-11-04, 3724.00, 3805.50, 3711.00, 3772.75
    2022-11-03, 3766.75, 3782.50, 3704.25, 3727.75"


    When testing this code on my end on 11/06/2022 using a 1-Minute ES 12-22 chart and the default trading hours template, I see the correct expected output. The 11/04/2022 prints match the OHLC prices you mentioned above. See the attached screenshot

    2022-11-06,2022-11-04,3724,3805.5,3711,3772.75

    What Trading Hours template is your Data Series set to? (Right-click on chart > Data Series > 'Trading hours' property)

    ​Please send me a screenshot of the Data Seres settings you are using and the exact steps to reproduce the behavior so I may investigate further.
    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
    I look forward to assisting further.
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon,

      Here's a screenshot of my Data Series settings, captured on 2022-11-07:

      Click image for larger version

Name:	ES_Data_Series.jpg
Views:	80
Size:	46.3 KB
ID:	1222675


      The only other steps I took were to enable the strategy I provided in my first post, using simulated price data because I ran the strategy on a Saturday, when markets were closed. Please let me know if you need additional information.

      Comment


        #4
        Hello Red_70,

        Thanks for your note.

        I have tested the code you shared in your previous post using the Data Series settings you provided.

        I still see the expected values printing to the Output window.

        See this demonstration video: https://brandonh-ninjatrader.tinytak...MV8yMDQ5MjkxOA

        If you test the attached script using the same settings and steps seen in the demonstration video and compare it to the Prior Day OHLC indicator added on the chart, do you see the same values printing to the Output window match the Prior Day OHLC indicator values?

        Let me know if I may assist further.
        Attached Files
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Hi Brandon,

          Thank you for the video and the test script. I'm not sure what caused the original problem, but after updating my NT software and opening new chart windows, everything seems to be working fine.

          I appreciate all of your help!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          65 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          139 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          75 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X