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

Get data from Ticker X while creating code for Ticker Y

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

    Get data from Ticker X while creating code for Ticker Y

    I want to get data from a different ticker from the one I am creating the strategy in.
    I know that GetCurrentAsk(); can be used to get the current ask price of the ticker the strategy is currently executing on, but how can I get the current ask price from a different ticker symbol?

    Thank you.

    #2
    Originally posted by joespo View Post
    I want to get data from a different ticker from the one I am creating the strategy in.
    I know that GetCurrentAsk(); can be used to get the current ask price of the ticker the strategy is currently executing on, but how can I get the current ask price from a different ticker symbol?

    Thank you.
    You will have to write a multi-time frame/instrument strategy.

    ref: http://www.ninjatrader.com/support/h...nstruments.htm

    Comment


      #3
      Exactly what I was looking for, thank you.

      One more question--

      How can I get the bid/ask for 20 minutes ago, how can I get it for a set time (say 10AM), and how can I get it for 20 bars ago? Will this same logic follow for indicators? (If I want MACD at 20 mins ago, at a certain time, and at 20 bars ago)

      Regards,
      Joe

      Comment


        #4
        joespo,

        I am happy to assist you.

        For this you would need to add a bid/ask data series and not all data providers offer bid/ask data. Here is some more information on the add() method.



        E.g. Add("ES 03-12", PeriodType.Minute, 1, MarketDataType.Ask);

        Would add a ES 03-12 , 1 minute data series using Ask data. If you needed to access 20 minutes ago you could use Closes[1][20] or something.

        Please let me know if I may assist fruther.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by joespo View Post
          Exactly what I was looking for, thank you.

          One more question--

          How can I get the bid/ask for 20 minutes ago, how can I get it for a set time (say 10AM), and how can I get it for 20 bars ago? Will this same logic follow for indicators? (If I want MACD at 20 mins ago, at a certain time, and at 20 bars ago)

          Regards,
          Joe
          To get the bar number for a specific time, you use the GetBar() function. Once you have the bar number you reference it by its index.

          Comment


            #6
            Thank you both for your help!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cre8able, 02-11-2023, 05:43 PM
            3 responses
            236 views
            0 likes
            Last Post rhubear
            by rhubear
             
            Started by frslvr, 04-11-2024, 07:26 AM
            8 responses
            113 views
            1 like
            Last Post NinjaTrader_BrandonH  
            Started by stafe, 04-15-2024, 08:34 PM
            10 responses
            46 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by rocketman7, Today, 09:41 AM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by traderqz, Today, 09:44 AM
            2 responses
            10 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X