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

Fetch the price of another instrument within a strategy

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

    Fetch the price of another instrument within a strategy

    Hi,
    I am writing a strategy for "instrument A" and I need:
    - the price of "instrument B" the day before at 23:00
    - the price of B the same day at 3:00

    What is the most simple way to get these values?

    Thanks

    #2
    Hello Vincere,

    Thanks for your post and welcome to the NinjaTrader forums!

    You would need to add the "instrument B" using AddDataSeries to your strategy, reference: https://ninjatrader.com/support/help...dataseries.htm You would need to decide what type bars to add, ie: 1 minute, 5 minute, daily, etc.

    To obtain the price from 23:00 on the previous day, your code would need to use a time filter so that at 3:00 you can pull the value of instrument B at 3:00 (which would be Closes[1][0]) and then "instrument B" at 23:00 the day before. To obtain data from 23:00 the day before you could use GetBar(): https://ninjatrader.com/support/help...us/?getbar.htm where you specify a date/time and the method returns the 'bars ago" that the bar occurred which you can then use to obtain the bar value (see the example in the help guide).

    Working with a multi-instrument script can be complex and we recommend a good read of: https://ninjatrader.com/support/help...nstruments.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      Thanks for the quick answer! I should have had a look at the documentation before asking. It's well explained.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      3 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      1 view
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      6 views
      0 likes
      Last Post Javierw.ok  
      Started by timmbbo, Today, 08:59 AM
      2 responses
      10 views
      0 likes
      Last Post bltdavid  
      Working...
      X