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

How do you check if you are subscribed to a certain instrument? C# ninja trader

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

    How do you check if you are subscribed to a certain instrument? C# ninja trader

    Var inst = "ES 06-20";
    if("ES" is NOT subscribed)
    {
    NTClient.SubscribeMarketData(inst);
    }else
    {

    }

    How do i do this? how do i check if 'inst' is subscribed?

    **note:
    var wtf = NTClient.Connected(0);
    this ^ always returns 0, whether im connected or not.

    #2
    Hello DarkCapital,

    Welcome to the NinjaTrader forums.

    To clarify, this is a question specifically for the API (Application Programming Interface), correct?

    Below is a link to a forum post on using the NinjaTrader API.



    When calling SubscribeMarketData(), if this returns a negative -1 there was an error and there is no subscription.

    If MarketData() is called when there is no subscription, this would cause a run-time exception in the external application. This exception could be caught in a try and catch to determine if the call to MarketData() is failing.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea, i clicked on the link and checked the documentation, all of the functions are returning 0, there is nothing to let me know whether im subscribed to an instrument or not

      Comment


        #4
        Hello DarkCapital,

        To confirm, you are asking about the API or are you asking about a NinjaScript method?

        Which method are you referring to?

        In the documentation linked from the forum post about the API are you asking about SubscribeMarketData()?
        From the help guide:
        "int SubscribeMarketData(string instrument)

        Starts a market data stream for the specific instrument. Call the MarketData() function to retrieve prices. Make sure you call the UnSubscribeMarketData() function to close the data stream. A return value of 0 indicates success and -1 indicates an error."
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I am using the API

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by AttiM, 02-14-2024, 05:20 PM
          11 responses
          184 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by fernandobr, Today, 09:11 AM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by timmbbo, Today, 08:59 AM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by KennyK, 05-29-2017, 02:02 AM
          2 responses
          1,281 views
          0 likes
          Last Post marcus2300  
          Started by itrader46, Today, 09:04 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X