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 tsantospinto, 04-12-2024, 07:04 PM
            7 responses
            126 views
            0 likes
            Last Post aligator  
            Started by futtrader, 04-21-2024, 01:50 AM
            5 responses
            56 views
            0 likes
            Last Post NinjaTrader_Eduardo  
            Started by PeakTry, Today, 10:49 AM
            0 responses
            2 views
            0 likes
            Last Post PeakTry
            by PeakTry
             
            Started by llanqui, Today, 10:32 AM
            0 responses
            5 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Started by StockTrader88, 03-06-2021, 08:58 AM
            45 responses
            3,992 views
            3 likes
            Last Post johntraderuser2  
            Working...
            X