Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

NT7 - Multi-timeframes multi instruments

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

    NT7 - Multi-timeframes multi instruments

    All,

    A question in relation to NT7 multi-timeframe multi-instrument strategies.
    The below code snippet is executed as part of a strategy on a 10min chart.
    Code:
    protected override void Initialize()
    {
      Add(PeriodType.Minute,30);
      Add("^SP500",PeriodType.Minute,10);
      Add("^SP500",PeriodType.Minute,30); 
    }
    
    protected override void OnBarUpdate()
    {
      if (FirstTickOfBar) 
      {
        if (CurrentBar < 200) return;
        Print (Time.ToString() + " - " + BarsInProgress);
      }
    }
    I would have expected a result similar to the below list.
    17/09/2010 11:30:00 AM - 0
    17/09/2010 11:30:00 AM - 1
    17/09/2010 11:30:00 AM - 2
    17/09/2010 11:30:00 AM - 3
    17/09/2010 11:40:00 AM - 0
    17/09/2010 11:40:00 AM - 2
    17/09/2010 11:50:00 AM - 0
    17/09/2010 11:50:00 AM - 2
    17/09/2010 12:00:00 AM - 0
    17/09/2010 12:00:00 AM - 1
    17/09/2010 12:00:00 AM - 2
    17/09/2010 12:00:00 AM - 3
    However, BarUpdates are not being processed as expected, it seems BarUpdates are being randomly skipped.


    Regards
    Shannon

    #2
    All,

    In the same vein as NT6.5, I've re-ordered the BarArrays to be in in descending order and lower than the Primary BarArray. This partially corrects the issue (where BarArrays 0 & 1 are 30min and BarArrays 2 & 3 are 10min)...
    Code:
    0 - 17/09/2010 4:30:00 AM
    1 - 17/09/2010 4:30:00 AM
    2 - 17/09/2010 4:30:00 AM
    3 - 17/09/2010 4:30:00 AM
    2 - 17/09/2010 4:40:00 AM
    3 - 17/09/2010 4:40:00 AM
    2 - 17/09/2010 4:50:00 AM
    3 - 17/09/2010 4:50:00 AM
    0 - 17/09/2010 5:00:00 AM
    1 - 17/09/2010 5:00:00 AM
    2 - 17/09/2010 5:00:00 AM
    3 - 17/09/2010 5:00:00 AM
    However, for what seems to be whole days things get a little strange, three different combinations from what I can see...
    Code:
    0 - 16/09/2010 10:00:00 AM
    2 - 16/09/2010 10:00:00 AM
    2 - 16/09/2010 10:10:00 AM
    2 - 16/09/2010 10:20:00 AM
    0 - 16/09/2010 10:30:00 AM
    2 - 16/09/2010 10:30:00 AM
    
    3 - 10/09/2010 2:30:00 AM
    3 - 10/09/2010 2:40:00 AM
    3 - 10/09/2010 2:50:00 AM
    3 - 10/09/2010 3:00:00 AM
    
    1 - 18/09/2010 4:30:00 AM
    3 - 18/09/2010 4:30:00 AM
    3 - 18/09/2010 4:40:00 AM
    3 - 18/09/2010 4:50:00 AM
    1 - 18/09/2010 5:00:00 AM
    3 - 18/09/2010 5:00:00 AM
    Ideas are most welcome.

    Regards
    Shannon

    Comment


      #3
      Shannon,

      The way it works is that you will get the event in chronological order. Please be aware that missing data will result in "missing" updates too. Of course real-time behaves completely different than historical as well depending on CalculateOnBarClose since those events get triggered by whichever data event comes down the pipes first from your data provider.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Josh.

        Thanks for the quick reply.

        The two instruments I'm working with are the ^SP500 and the current ES. I would not have expected "missing" data. As I have no control over what or when missing data will present, any recommendations on the structure for robust coding?

        Also you mentioned real-time behaves differently to historical depending on CalculateOnBarClose (COBC), please elaborate further.
        My strategy will run as COBC = false. While is is designed to reference the appropriate bar information. Still, unexpected barupdate events will not help.

        Regard
        Shannon

        Comment


          #5
          Shannon,

          Basically NT is event driven. This means that you should not rely on a certain sequence of events, especially timestamps across different instruments. In real-time the events are processed as they come in. If ES decides to push a tick through your data provider before ^SP500, then you will receive the ES BarsInProgress event first. If on a different tick, ^SP500 came first, then you would get that one first. There is no way you can predict which one will come first and which one will come second. If data on ES suddenly stops for some reason, but ^SP500 continues you will just keep receiving ^SP500 events and completely skip the ES BarsInProgress.

          To deal with this behavior I have no general guidelines I can provide because it is really dependent on what logic you are exactly trying to do. If your code requires both BarsInProgress to have received the information of a certain point in time, you can check the other BarsInProgress' information when you receive one to see if you did receive it already. If you have not, then don't process your logic yet.
          Josh P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by TraderBCL, Today, 04:38 AM
          2 responses
          7 views
          0 likes
          Last Post TraderBCL  
          Started by martin70, 03-24-2023, 04:58 AM
          14 responses
          105 views
          0 likes
          Last Post martin70  
          Started by Radano, 06-10-2021, 01:40 AM
          19 responses
          606 views
          0 likes
          Last Post Radano
          by Radano
           
          Started by KenneGaray, Today, 03:48 AM
          0 responses
          4 views
          0 likes
          Last Post KenneGaray  
          Started by thanajo, 05-04-2021, 02:11 AM
          4 responses
          471 views
          0 likes
          Last Post tradingnasdaqprueba  
          Working...
          X