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

Session Time Frame for added instruments

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

    Session Time Frame for added instruments

    Hi Folks!
    It's hard to find so I open a new thread.
    Developing a multi instrument code, I have the right session time for Stocks (9:30 am to 4:00pm) when BarsArray = 0, but when it access other than 0, it seems session equal 'Default 24x7'.


    Is there any setting for sessions template?
    I tried this code below:
    Print(CurrentDayOHL(BarsArray[1]).CurrentOpen[0]);
    Print(PriorDayOHLC(BarsArray[1]).PriorClose[0]);



    I got the same result or 1 tick close, never shows me the gap.



    Thanks
    mcosta72
    NinjaTrader Ecosystem Vendor - Quant-Wise

    #2
    Hello mcosta72,

    Thanks for your post.

    Regarding the session templates, this note in the NT7 helpguide applies: 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. 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. 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. the note can be found in the section, "True Event Driven OnBarUpdate() Method" here: https://ninjatrader.com/support/help...nstruments.htm


    Based on this specific line: "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.", you may want to set the session template for the chart series from its default to US_Equities_RTH to force the other series to follow.


    You might try the following code for finding the gap:

    if (Bars.FirstBarOfSession)
    {
    myCurrentOpen = Open[0]; // get the session current open price
    myPriorClose = Close[1]; // get the last close price of prior session
    }


    I'm just using myCurrentOpen and myPriorClose as two double variables.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks you PAUL!
      mcosta72
      NinjaTrader Ecosystem Vendor - Quant-Wise

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Christopher_R, Today, 12:29 AM
      0 responses
      9 views
      0 likes
      Last Post Christopher_R  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      166 responses
      2,235 views
      0 likes
      Last Post sidlercom80  
      Started by thread, Yesterday, 11:58 PM
      0 responses
      3 views
      0 likes
      Last Post thread
      by thread
       
      Started by jclose, Yesterday, 09:37 PM
      0 responses
      8 views
      0 likes
      Last Post jclose
      by jclose
       
      Started by WeyldFalcon, 08-07-2020, 06:13 AM
      10 responses
      1,415 views
      0 likes
      Last Post Traderontheroad  
      Working...
      X