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

Bars.GetDayBar(1).Close for multi-instrument

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

    Bars.GetDayBar(1).Close for multi-instrument

    hi,

    I'm trying to add 2nd instrument to the program,

    under Initialize(),
    Add("ES 03-12", PeriodType.Minute, 5);

    any idea how can i get px change this additional instrument??

    Closes[1][0] - Bars.GetDayBar(1).Close ??

    if i use Bars.GetDayBar(1).Close, it will gimme the previous closing px of Closes[0][0],

    many thanks,

    Adam

    #2
    Hi Adam,
    Thanks for the post. Can you please clarify what calculation you're looking for?
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      hi Ryan,

      thanks for fast reply,

      im trying to calculate price change relative to previous day close,

      thanks,

      Comment


        #4
        I don't feel you would need a multitime frame script for this. The last price is available with value Close[0] when CalculateOnBarClose = false. You can then make comparisons with this value and the built in PriorDayOHLC()


        GetDayBar() is similar to this, but is intended for session data beyond the current, and previous day.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          thanks for telling me about the PriorDayOHLC(), i guess i make you confuse, my bad,

          the case like this, im trying to print 2 instrument price changes to output window at the same time , let say "msft" and "intel", 5 minutes bars, price change = close[0] - PriorDayOHLC().PriorClose[1],

          under "if( BarsInProgress == 0)", PriorDayOHLC().PriorClose[1] is the prior closing price for the default instrument, "msft"

          my question is how can i get PriorDayOHLC().PriorClose[1] for "intel"??

          Comment


            #6
            Thanks for clarifying. I'm happy to help. You would need to include an Add() statement adding intel. You can access its values with Closes, or filtering updates within a specific BarsInProgress, which would allow you to access the same PriorDayOHLC.

            There is a sample multi instrument strategy available through Tools > Edit NinjaScript > Strategy. Documentation for this is here:
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            59 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Today, 06:52 PM
            4 responses
            36 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Today, 07:39 PM
            0 responses
            7 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Today, 03:01 PM
            2 responses
            21 views
            0 likes
            Last Post helpwanted  
            Started by cre8able, Today, 07:24 PM
            0 responses
            10 views
            0 likes
            Last Post cre8able  
            Working...
            X