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 sjsj2732, Yesterday, 04:31 AM
            0 responses
            30 views
            0 likes
            Last Post sjsj2732  
            Started by NullPointStrategies, 03-13-2026, 05:17 AM
            0 responses
            286 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            282 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            132 views
            1 like
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            90 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Working...
            X