Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Provider name OnConnectionStatus

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

    Provider name OnConnectionStatus

    Hi,

    How do I get the Provider name of the OnConnectionStatus event handler?
    - My primary connection is Zen-Fire broker account
    - Second data feed Kinetick Realtime

    Thank you in advance.

    Sam

    #2
    Bars.MarketData.Connection.Options.Provider.ToStri ng()

    A Known Issue with NT7 is the name of the second connection is always the same as the first.For Zen that returns "Hosted".

    Comment


      #3
      Bars.MarketData.Connection.Options.Provider

      protectedoverridevoid OnConnectionStatus(ConnectionStatus orderStatus, ConnectionStatus priceStatus)

      It would be ideal if we have:

      1) Bars.MarketData.Connections[] or
      2) receive provider info via OnConnectionStatus to identify which conection is beeing handled in this instance of event...

      Thanks MXASJ for your reply.


      Sam

      Comment


        #4
        You might find this code handy. Its part of a Strat I run whenever I'm trading, though it doesn't trade itself and just monitors things. Note ConnectionStatus appears to be called OnStartUp() as well.

        In Variables:

        Code:
        [COLOR=blue]private[/COLOR] [COLOR=#2b91af]ConnectionStatus[/COLOR] badPriceDataFeed = [COLOR=#2b91af]ConnectionStatus[/COLOR].Connected;
        [COLOR=blue]private[/COLOR] [COLOR=#2b91af]ConnectionStatus[/COLOR] badOrderDataFeed = [COLOR=#2b91af]ConnectionStatus[/COLOR].Connected;
        And the main code

        Code:
        [COLOR=blue]#region[/COLOR] OnConnectionStatus()
        	[COLOR=blue]protected[/COLOR] [COLOR=blue]override[/COLOR] [COLOR=blue]void[/COLOR] OnConnectionStatus([COLOR=#2b91af]ConnectionStatus[/COLOR] orderStatus, [COLOR=#2b91af]ConnectionStatus[/COLOR] priceStatus)
        	[COLOR=green]//This method is caled once for every change in connection status[/COLOR]
        	
        		{[COLOR=green]//Open OnConnectionStatus()[/COLOR]
        		[COLOR=blue]if[/COLOR] (BarsInProgress != 0) [COLOR=blue]return[/COLOR];
        		badPriceDataFeed = priceStatus;
        		badOrderDataFeed = orderStatus;
        			
        		Print([COLOR=#2b91af]DateTime[/COLOR].Now + [COLOR=#a31515]" Connection '"[/COLOR] + Bars.MarketData.Connection.Options.Provider.ToString() + [COLOR=#a31515]"' Order Server: "[/COLOR]
        			+ orderStatus + [COLOR=#a31515]". Price Server: "[/COLOR] + priceStatus + [COLOR=#a31515]"."[/COLOR]);
        		
        		[COLOR=blue]if[/COLOR] (badOrderDataFeed == [COLOR=#2b91af]ConnectionStatus[/COLOR].ConnectionLost && alertsWindow)  Alert([COLOR=#a31515]"orderconnectionlost"[/COLOR], NinjaTrader.Cbi.[COLOR=#2b91af]Priority[/COLOR].High, [COLOR=#a31515]"Order Server Connection Lost"[/COLOR], [COLOR=#a31515]"triple_klaxon.wav"[/COLOR], 10, [COLOR=#2b91af]Color[/COLOR].Red, [COLOR=#2b91af]Color[/COLOR].White);
        		[COLOR=blue]if[/COLOR] (badPriceDataFeed == [COLOR=#2b91af]ConnectionStatus[/COLOR].ConnectionLost && alertsWindow)  Alert([COLOR=#a31515]"priceconnectionlost"[/COLOR], NinjaTrader.Cbi.[COLOR=#2b91af]Priority[/COLOR].High, [COLOR=#a31515]"Price Server Connection Lost"[/COLOR], [COLOR=#a31515]"triple_klaxon.wav"[/COLOR], 10, [COLOR=#2b91af]Color[/COLOR].Red, [COLOR=#2b91af]Color[/COLOR].White);
        		[COLOR=blue]if[/COLOR] (badPriceDataFeed == [COLOR=#2b91af]ConnectionStatus[/COLOR].Connected && badOrderDataFeed == [COLOR=#2b91af]ConnectionStatus[/COLOR].Connected && alertsWindow)  Alert([COLOR=#a31515]"connectionsOK"[/COLOR], NinjaTrader.Cbi.[COLOR=#2b91af]Priority[/COLOR].Low, [COLOR=#a31515]"Price and Order Server Connected"[/COLOR], [COLOR=#a31515]"Connected.wav"[/COLOR], 10, [COLOR=#2b91af]Color[/COLOR].Green, [COLOR=#2b91af]Color[/COLOR].White);
        		[COLOR=green]// NOTE: If you connect to a second data source or broker, the connection name will always refer to the primary connection.[/COLOR]
        		[COLOR=green]// That is a Known Issue with NT as of NT7b15.[/COLOR]
        			
        		}[COLOR=green]//CloseOnConnectionStatus[/COLOR]
        [COLOR=blue]	#endregion[/COLOR]

        Comment


          #5
          sammano, please try out the provided code and let us know if you have any other questions/concerns.
          AustinNinjaTrader Customer Service

          Comment


            #6
            Multiple connections

            As I mentioned in the bottom of my thread I’ve two simultaneous connections and I need to check precisely which of the connection lost.

            I found another way of checking the Provider of the trading account price/data feed by enumerating “Bars.MarketData.Connection.Accounts” object. I’ve just coded it and test for couple of days. If that works I will post back here.

            Thanks guys.

            Sam

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Damocoleman, 03-30-2022, 09:49 AM
            17 responses
            1,235 views
            0 likes
            Last Post Mykro
            by Mykro
             
            Started by junkone, Yesterday, 02:19 PM
            5 responses
            69 views
            1 like
            Last Post junkone
            by junkone
             
            Started by reynoldsn, Today, 07:19 PM
            0 responses
            9 views
            0 likes
            Last Post reynoldsn  
            Started by reynoldsn, 04-21-2024, 07:53 PM
            2 responses
            19 views
            0 likes
            Last Post reynoldsn  
            Started by stafe, 04-15-2024, 08:34 PM
            13 responses
            85 views
            0 likes
            Last Post stafe
            by stafe
             
            Working...
            X