Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Instrument Indicators, Delayed Open & Status Flags (FirstBarOfSession etc.)

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

    Multi Instrument Indicators, Delayed Open & Status Flags (FirstBarOfSession etc.)

    I am trying to develop an indicator which adds bars of many instruments.
    I want the indicator to be robust and be able to tolerate issues related to delayed stock open.

    If I understand correctly, given the event driven nature of NT, the first bar for a particular instrument will start when the first price (trade) tick arrives for that session. On that Tick, the OnBarUpdate method will be called with Bars.FirstBarOfSession = true and FirstTickOfBar = true.

    This will work even if the opening of the stock is delayed due to some reason. So even if other instruments are actively receiving live data, if a stock opens later than other instruments, the first tick which NT receives will trigger a OnBarUpdate event with the FirstBarOfSession and FirstTickOfBar true. This assumes, that the Bars were added using the MarketDataType.Last option in the indicator.

    Please confirm.

    As an enhancement, it would greatly simplify programing if NT added the following two Callbacks
    -> OnSessionOpen() : Called when the first tick of the session is received
    -> OnSessionClose(): Called when the clock strikes the end of the session.

    The second one is especially needed for doing end of day/week/month based analysis.

    #2
    Hello aviat72,

    Thank you for the suggestions on additional methods.

    Yes, this is accurate. Series must be added in Initialize method, and you can define session properties within a specific BarsInProgress context.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Here's a slightly updated version of my "Spread3" indicator that I posted a while back in response to a similar question. It uses 3 instruments and has code for a 4th in comments to show how to extend it.

      It's intended to serve a a prototype to show how to make multi-instrument indicators, and has a lot of comments to explain its use. It correctly synchronizes multiple instruments for both real-time and historical data, with CalculateOnBarClose either true or false. If you don't use my method or something similar, your only alternative is to run with CalculateOnBarClose=false and catch every tick, which is OK for a few instruments but doesn't scale to larger numbers, and you still have to detect and handle missing bars.

      I'm currently using the same Synchronization method (slightly modified for use in a strategy) in a strategy with 100 instruments.

      When one instrument is missing a bar, as in a delayed open, you can do 1 of 3 things: (1) produce some output anyway using the information you have, (2) repeat the last output (usually my preference), or (3) produce no output (but this causes problems if you use it as an input to another indicator).

      9/27/10: File has been place in the NT7 Indicators section:
      http://www.ninjatrader.com/support/f...d=4&linkid=417
      Last edited by kdoren; 09-27-2010, 04:19 AM. Reason: Moved updated spread3.zip file to NT7 Indicators Section

      Comment


        #4
        kdoren, thank you very much for this code. Could you possibly also post it in the NinjaTrader 7 Indicator file sharing section? I will do it for you if you'd like. This is very helpful, and I'm sure many users would love the example.
        AustinNinjaTrader Customer Service

        Comment


          #5
          OK, I posted an updated version of the file in the NT7 Indicators Section:
          http://www.ninjatrader.com/support/f...d=4&linkid=417

          Comment

          Latest Posts

          Collapse

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