Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical flag false after adding 2nd time-frame

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

    Historical flag false after adding 2nd time-frame

    Hi,

    We have a strategy which needs a 2nd time-frame. Adding the first time-frame works fine and the feature "days to load" works as expected. The strategy indicates these data as "historical" (by setting the flag named Historical). As soon as we add the 2nd time-frame the flag is immediately set to false, even for historical data.

    Is this behavior as expected? Or what can we do to correctly load historical data for multi time-frame strategies?

    Best regards

    #2
    Hello,

    The second data series should load the same amount of historical data as the primary input source.

    Would you be able to provide me with a snippet of your code which demonstrates this behavior?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Hi Matthew

      Here are the code samples you asked for. "Wait until flat" is set for real time strategies. The time frame is set to 2 "days to load".

      Code:
      protected override void Initialize() {
      	...	
      	Add(ADX(14));
      	...
      	CalculateOnBarClose = true;
      	...
      }
      
      protected override void OnBarUpdate() {
      	...
      	Print("DEBUG: OnBarUpdate() - Historical Data: " + Historical + "Time = " + Time[0]);
      	...
      }
      The sample above works as expected in live trading. The historical data for 2 days in the past are processed for the defined time interval immediatly after starting the live strategy. The Historical flag returns true until we reach the actual live data. That is ok so far.

      However as soon as I add a 2nd time frame like in the following example. All data are flaged as Historical false (historical and live data).

      Code:
      protected override void Initialize() {
      	...	
      	Add(ADX(14));
      	[COLOR="Red"]Add(PeriodType.Day, 1);[/COLOR]
      	...
      	CalculateOnBarClose = true;
      	...
      }
      
      protected override void OnBarUpdate() {
      	...
      	Print("DEBUG: OnBarUpdate() - Historical Data: " + Historical + "Time = " + Time[0]);
      	...
      }
      Is this a bug? Or is there an other way the see if we are processing historical data or live date?

      Best regards

      Comment


        #4
        Hello,

        Your strategy is not meeting the minimum bars required when the daily series is added. By default the strategy will need at least 20 bars. To account for weekends, etc please try increasing your days to load to 25.

        You can also try setting Initialize() to BarsRequired = 0;
        MatthewNinjaTrader Product Management

        Comment


          #5
          Hello,

          Neither increasing the "days to load" value to 25 nor setting the BarsRequired = 0 has changed the behavior... All data processed are still flaged as Historical = false...

          Comment


            #6
            If you set the days to load to 50, do you get the prints as true? Please try increasing the days to load to see if you can get this to return as true. In my testing, as long as the bars required was fulfilled, it should return as true.
            MatthewNinjaTrader Product Management

            Comment


              #7
              Hello,

              Another approach would be adding a current bars check to return if the minimum bars required is not met:

              Code:
                   protected override void Initialize()
                      {
                          Add(ADX(14));
                          Add(PeriodType.Day, 1);
                          
                          CalculateOnBarClose = true;
                          BarsRequired = 0;
              
                      }
                      
                      protected override void OnBarUpdate()
                      {
                          
                      if(CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired) return;
                          
                          
                       Print("DEBUG: OnBarUpdate() - Historical Data: " + Historical + "Time = " + Time[0]);
                         
                       }
              Last edited by NinjaTrader_Matthew; 05-07-2012, 08:42 AM.
              MatthewNinjaTrader Product Management

              Comment


                #8
                Hi Matthew

                Increasing the "days to load" to at least 50 values did the job! Unfortunately I increased the value only to about 40 during my first test Sorry...

                Guess I learned a lot for further implementations

                I appreciate you help very much! Thank you!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by thanajo, 05-04-2021, 02:11 AM
                3 responses
                468 views
                0 likes
                Last Post tradingnasdaqprueba  
                Started by Christopher_R, Today, 12:29 AM
                0 responses
                10 views
                0 likes
                Last Post Christopher_R  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                166 responses
                2,237 views
                0 likes
                Last Post sidlercom80  
                Started by thread, Yesterday, 11:58 PM
                0 responses
                4 views
                0 likes
                Last Post thread
                by thread
                 
                Started by jclose, Yesterday, 09:37 PM
                0 responses
                9 views
                0 likes
                Last Post jclose
                by jclose
                 
                Working...
                X