Announcement

Collapse
No announcement yet.

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.
    https://ninjatrader.com/support/foru...626#post793626


    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 emapleq, Today, 04:01 AM
          0 responses
          2 views
          0 likes
          Last Post emapleq
          by emapleq
           
          Started by varun12343, Today, 03:09 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Marco  
          Started by Lance El Camino, Yesterday, 04:14 PM
          2 responses
          23 views
          0 likes
          Last Post NT-Roland  
          Started by MatthewLesko, Yesterday, 11:13 PM
          1 response
          13 views
          0 likes
          Last Post NT-Roland  
          Started by kevinenergy, Today, 01:44 AM
          0 responses
          4 views
          0 likes
          Last Post kevinenergy  
          Working...
          X