Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical() not working

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

    Historical() not working

    Hello NT Friends,

    Historical() it not working in my strategy, it is always returning false as if I was always online.

    The thing is when you first enable your strategy, it calls OnBarUpdate for the x past bars to calculate history. Although I enable strategy half hour before market starts , only when it starts that OnBarUpdate is call several times so history is built, and during all these calls Historical() is not returning true, so it is triggering orders even though that OnBarUpdate is not really the online market.

    By bars are set to be calculated on every tick (CalculateOnBarClose False)

    Would you guys know why I'm getting this behaviour?

    Thanks,

    Rodrigo

    #2
    If I am following you correctly - When you enable a strategy 1/2 hour before market open - historical is no longer true.

    Posting some code with the issue would be easier for us to debug. Just remove any of your secrets.

    Comment


      #3
      Yes, I enable strategy before market opens.

      When market opens it looks like it reads all the historical data, calling OnBarUpdate for every bar in the history, which I know is fine if it wasn't for a reason: Historical() shows false all the time, even though when it is not really online.

      Code is really a simple: if (Historical) then write a message to log text file I have and return;.

      In that log is where I'm seeing Historical = false all the time, and this is what is killing my strategy.

      Any thoughts?

      Rodrigo

      Comment


        #4
        Does this Thread help any?

        Comment


          #5
          Adding ToTime should help in your situation.



          Code:
          protected override void OnBarUpdate()
          {
          if (Historical) return;
          
          	
          if (   ToTime(Time[0]) >= ToTime( 09, 30, 00)
          	&& ToTime(Time[0]) <= ToTime( 10, 00, 00))
          {
            //logic

          Comment


            #6
            Hello Rodrigo,

            Thank you for your post.

            Can you provide the code used to check and print the Historical bool?

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            545 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X