Announcement

Collapse
No announcement yet.

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

    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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      29 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      46 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X