Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

FirstTickOfBar true, but Open[0] is last bar's open

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

    FirstTickOfBar true, but Open[0] is last bar's open

    Hello NT community!

    I'm currently backtesting my first strategy implemented on NT. My strategy adds both a daily and a tick-based time frame - and within those all relevant calculations are done.

    Now, beginning with the first tick of a new trading day, I want to monitor the market development based on each day's open price.

    The problem is: NT does calculations based on yesterdays open price.

    Consider the following code:
    Code:
    protected override void Initialize() {
    [...]
          Add(PeriodType.Day, 1);
          Add(PeriodType.Tick, 1);
    [...]
    }
    
    protected override void OnBarUpdate() {
         if (BarsInProgress == 1 && FirstTickOfBar) {
              Print("Time: " + Times[1][0] + ", Open: " + Opens[1][0]);
         }
    }
    Contrary to my expectation, the time printed to the output window is the time of yesterday's close and the open price is yesterday's open price (same of course with Open[0]).

    Why? And how do I really get the open price of today?

    Thanks for your help!

    #2
    Dont know if this is anything to do with it but I have found the same problem when drawing lines on overnight charts. I resolved the problem by altering times in the session manager and then altering the session template in the data window to my own session times - everything lined up then so to speak.

    I am not proficient enough to comment on your code & that may still be a problem though I have seen the code read

    ..........+ Opens[0][0]

    Hope that this might help.

    Comment


      #3
      Could also try ....

      double todaysOpen = Open[Bars.BarsSinceSession];

      Comment


        #4
        Thanks for your reply.

        That would always return the open price of the first bar of the session, not the one of the current bar.

        Open[0] should be the open of the most recent bar (not true in my case though)

        Comment


          #5
          Sorry in your original post it appeared you were looking for a reference to the current sessions open price not the current bars !

          "I want to monitor the market development based on each day's open price............ how do I really get the open price of today?"

          Comment


            #6
            The current session's open price may or may not be the open price of the current day (it isn't if the session lasts longer than a day).

            In my strategy, time frame index 1 is based on daily bars, so Opens[1][0] should be the open price of each day.

            Unfortunately it seems that although FirstTickOfBar holds true, the open price has not yet updated.

            That for one doesn't make sense (to me). But even if this is the way it is supposed to be, I can't think of another way to get the data.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            648 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            369 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            572 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X