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

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 PaulMohn, Today, 05:00 AM
      0 responses
      7 views
      0 likes
      Last Post PaulMohn  
      Started by ZenCortexAuCost, Today, 04:24 AM
      0 responses
      6 views
      0 likes
      Last Post ZenCortexAuCost  
      Started by ZenCortexAuCost, Today, 04:22 AM
      0 responses
      3 views
      0 likes
      Last Post ZenCortexAuCost  
      Started by SantoshXX, Today, 03:09 AM
      0 responses
      16 views
      0 likes
      Last Post SantoshXX  
      Started by DanielTynera, Today, 01:14 AM
      0 responses
      5 views
      0 likes
      Last Post DanielTynera  
      Working...
      X