Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to add Instrument with custom SessionTemplate

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

    How to add Instrument with custom SessionTemplate

    My strategy is running on instrument 6E with session template CME FX Futures ETH.

    I need to use Pivot indicator - but it is more common to calculate Pivot on bars with session template CME FX Futures RTH, because of historical reasons and old good floor-trading times.

    So question is:
    How can I add new bar-series to strategy, that will use different session template?.
    I would use that bar-series only for calculation of Pivot indicator.

    What I would like to achieve is something like:

    Add(PeriodType.Minute, 15);
    BarsArray[1].Session = Session.String2Session("CME FX Futures RTH");
    Pivots pivotIndicator = Pivots(BarsArray[1], ....)


    But the code above is not working (Session is read-only) - it is just for demonstration of logic I need to achieve.
    Last edited by misova; 11-03-2015, 04:50 PM.

    #2
    Hi misova,

    If a multi-series script adds an additional Bars object that already exists on the chart, the script will use the preexisting series instead of creating a new one to conserve memory. This includes that series' session template as applied from the chart. (Meaning if you add a secondary series with a different session, the script will use the selected session template of that secondary series on the chart)

    The issue here, is that you will not be able to add the same instrument with the same interval to your chart twice in NinjaTrader 7.

    If the Bars object does not exist on the chart, the session template of the added Bars object will be the session template of the primary Bars object (whatever the chart is set to). If the primary Bars object is using the "<Use instrument settings>" session template then the additional Bars objects will use the default session templates as defined for their particular instruments in the Instrument Manager.

    This would not achieve your goal of using different session templates for the same instrument.


    So that I know of, you can you get the hours of any session template if you would like, but you would not be able to add two data series of the same instrument with the same interval to a script or to a chart that use different session templates in NinjaTrader 7.


    That said, this has been resolved in NinjaTrader 8. NinjaTrader 8 NinjaScript has a TradingHours object that can be selected with AddDataSeries and can be called directly.

    AddDataSeries(string instrumentName, BarsPeriod barsPeriod, int barsToLoad, string tradingHoursName, bool? isResetOnNewTradingDay)

    AddDataSeries - http://ninjatrader.com/support/helpG...dataseries.htm

    TradingHours - http://ninjatrader.com/support/helpG...adinghours.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you ChelseaB,
      for your answer and really great detailed explanation! It is completely clear now.

      Very good, that you pointed out possibilitiy to do it in NT8.
      This was very helpful to me.

      As I understand the limitations of NT7 and possibilities of NT8,
      I decided to implement it it NT8 for backtesting purposes.
      Thank you!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 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
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X