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

TD Ameritrade Data?

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

    TD Ameritrade Data?

    When I run the following script I get historical minute data from TD Ameritrade's API. Is there a way to get this data in Ninja Trader? I am already getting $TICK

    Code:
    var tickSymbols = new string[] { "$TICK", "$TICKQ", "$TICKI", "$TICKD", "$TICKR" };
    
    var httpClient = new HttpClient();
    var apiKey = "xxxxx";
    
    
    // Print out the tick index values
    Console.WriteLine("Tick Index Values:");
    foreach (var symbol in tickSymbols) {
        var baseUrl = $"https://api.tdameritrade.com/v1/marketdata/{tickSymbols[0]}/pricehistory";
    
        var requestParams = $"?apikey={apiKey}&periodType=day&frequencyType=minute&frequency=60&period=5";
        var requestUrl = baseUrl + requestParams;
    
        var response = await httpClient.GetAsync(requestUrl);
    
        var responseContent = await response.Content.ReadAsStringAsync();
        Console.WriteLine($"---------------------------------------------");
        Console.WriteLine($"{symbol}: {responseContent}");
    }​

    #2
    Hello ErikHR1969,

    Just connect to TD Ameritrade and the minute historical data will automatically download for any chart, and will be available (as the Open, High, Low, and Close series) in any NinjaScript Indicator or Strategy.

    Below is a link to the connection guide for TD Ameritrade.


    As well as a link to a forum post with helpful resources on getting started with NinjaScript and C#.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      The code against TD Ameritrade's API (above) actually returns historical data for all of these symbols:

      Code:
      var tickSymbols = new string[] { "$TICK", "$TICKQ", "$TICKI", "$TICKD", "$TICKR", "^TICKQ" };
      var trinSymbols = new string[] { "$TRIN", "$TRINQ", "$TRINX" };
      var putcallSymbols = new string[] { "$PCX", "$PCZ", "$SPXPC" };​
      Can you try to connect to TD Ameritrade with NinjaTrader and see what data you get. All I get is:

      ^TICK --> historical and realtime data.
      ^TRIN --> historical and realtime data.
      ^TICKQ --> realtime data.
      ^TRINQ --> realtime data.
      ^PCR and all the rest --> No data

      Thanks,
      Erik



      Comment


        #4
        Hello Erik,

        I would not have a TD Ameritrade test account to connect with, and unfortunately I would not have a list of the index symbols they support or provide data for in the API.

        If the instrument will load on a chart, that data can also be used in NinjaScript.

        If the instrument cannot load on a chart, contact TD Ameritrade to confirm the instrument is available through the API and then ensure the symbol mapping for the instrument is correct.
        https://ninjatrader.com/support/help...mbolMapSection
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,406 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        98 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        8 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        160 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        9 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X