• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to determine the current data provider

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

    How to determine the current data provider

    Hello

    I am using NT 8.0.18.0 64-bit.

    I have a Continuum account and a TD Ameritrade account, and will be adding other accounts with other providers.

    In my custom strategy, is there a way to programmatically determine which provider is currently providing data to the strategy?

    I have tried various options using Account.Connection syntax, but have been only able to return information from the primary (first) connection.

    Thank you

    #2
    Hello Zigfried,

    From the strategies Account object you would not be able to tell as the strategy can only be applied to a single account at once. The Accounts connection would be reported here.

    You could loop over the active connections, however if you add more and they are not associated with the strategy that still won't really help:

    Code:
    foreach (Connection connection in Connection.Connections)
    {
          Print(connection.Options.Provider.ToString());
    }
    In more advanced situations where you may have an account with one provider and then get data from another, that is not really apparent from the strategies point of view as it only knows about the trading account it is applied to. What is the use case where knowing the connection is required? Perhaps there is a different way to approach the task.

    As a side note, there is a new update available.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse

      I want to terminate the Strategy under 2 conditions:
      1) Preferred Connection/Fallback - the Strategy is not started with the preferred connection, or falls back to a non-preferred provider
      2) Configuration Error - the User configures the Strategy to trade a TD Ameritrade account, and to modify orders in a manner that is not compatible with TD Ameritrade. This question is different from my first one - How to tell the account provider for the account being traded, without using Account.Name?

      Thank you

      Comment


        #4
        Hello Zigfried,

        Thank you for the additional details.

        For the first situation, you may be able to utilize the OnConnectionStatusUpdate override for situations where a connection changes/fails. For identifying that the strategy was started with the right connections would really only be possible to check the accounts connection directly. Otherwise to the strategy it would only know you are connected to some providers, they are not specifically linked to your strategy. You could potentially use the connection collection to loop over the connections however if you had two fallback connections it would be up to your logic to know the difference or if the strategy should work based on that info.

        https://ninjatrader.com/support/help...b=onconnection

        For the second question you have already provided the way to do that, you would just need the .Options.Provider part:

        Code:
         Print(connection.Options.Provider.ToString());
        or
        Account.Connection.Options.Provider

        The Provider enum can be used to match providers however they are not named pretty so you would need to Print the loop of connections to find out what provider names you have, this will report something similar to Provider7.



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Benjaminf, Today, 02:21 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by grayfrog, 05-24-2020, 09:29 PM
        4 responses
        30 views
        0 likes
        Last Post natgasguy  
        Started by chrismcdermut, Today, 01:46 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by dpolyakov, Today, 01:13 PM
        3 responses
        14 views
        0 likes
        Last Post dpolyakov  
        Started by tjendra, Today, 12:15 PM
        3 responses
        9 views
        0 likes
        Last Post tjendra
        by tjendra
         
        Working...
        X