NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 02-28-2011, 08:29 PM   #1
marcusplexus
Member
 
Join Date: Jan 2010
Posts: 73
Thanks: 11
Thanked 1 time in 1 post
Default Monitoring the data connection

Hi,

I need to monitor my data feed for disconnection. For whatever reason my broker's servers are sometimes completely unavailable for a few minutes at night (eastern time zone). I would like to send myself an email and/or generate a looping sound to notify me that NT is unable to act on (protective stop) orders while I am sleeping with open positions.

I know how to email myself alerts and play sounds but I don't know what to use to monitor the data feed.

Can this be done? If so, what functions/methods/etc should I be looking at?

Thanks in advance.

-mp
marcusplexus is offline  
Reply With Quote
Old 03-01-2011, 05:41 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

mp, you can monitor OnConnectionStatus() for these tasks - http://www.ninjatrader.com/support/h...tionstatus.htm
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-01-2011, 06:09 AM   #3
MXASJ
Senior Member
 
Join Date: May 2009
Location: Asia
Posts: 304
Thanks: 0
Thanked 9 times in 5 posts
Default

Marcus this might give you some ideas:

PHP Code:
#region OnConnectionStatus()
protected override void OnConnectionStatus(ConnectionStatus orderStatusConnectionStatus priceStatus)
//This method is caled once for every change in connection status
 
{//Open OnConnectionStatus()
 
priceDataFeed priceStatus;
orderDataFeed orderStatus;
 
Print(
DateTime.Now " Connection '" Bars.MarketData.Connection.Options.Provider.ToString() + "' Order Server: "
orderStatus ". Price Server: " priceStatus ".");
 
if (
orderDataFeed == ConnectionStatus.ConnectionLost && alertsWindowAlert("orderconnectionlost"NinjaTrader.Cbi.Priority.High"Order Server Connection Lost""triple_klaxon.wav"10Color.RedColor.White);
if (
priceDataFeed == ConnectionStatus.ConnectionLost && alertsWindowAlert("priceconnectionlost"NinjaTrader.Cbi.Priority.High"Price Server Connection Lost""triple_klaxon.wav"10Color.RedColor.White);
if (
priceDataFeed == ConnectionStatus.Connected && orderDataFeed == ConnectionStatus.Connected && alertsWindowAlert("connectionsOK"NinjaTrader.Cbi.Priority.Low"Price and Order Server Connected""Connected.wav"10Color.GreenColor.White);
 
// NOTE: If you connect to a second data source or broker, the connection name will always refer to the primary connection.
// That is a Known Issue with NT as of NT7b15.
 
}//CloseOnConnectionStatus
#endregion 
Remember to declare these in the Variables region first:
PHP Code:
private ConnectionStatus priceDataFeed ConnectionStatus.Connected;
private 
ConnectionStatus orderDataFeed ConnectionStatus.Connected
Change wav files as appropriate.
MXASJ is offline  
Reply With Quote
Old 03-01-2011, 07:16 AM   #4
marcusplexus
Member
 
Join Date: Jan 2010
Posts: 73
Thanks: 11
Thanked 1 time in 1 post
Default

NinjaTrader_Bertrand: thank you for the info.
MXASJ: Thanks a lot! I was not expecting a ready made solution...
marcusplexus is offline  
Reply With Quote
Old 05-30-2011, 10:31 AM   #5
dawdler
Member
 
Join Date: Dec 2010
Posts: 37
Thanks: 1
Thanked 1 time in 1 post
Default

Code:
if (orderDataFeed == ConnectionStatus.ConnectionLost && alertsWindow) Alert("orderconnectionlost", NinjaTrader.Cbi.Priority.High, "Order Server Connection Lost", "triple_klaxon.wav", 10, Color.Red, Color.White);

The alerts from the above code by MXASJ are not rearming after 10 seconds. How is it possible to get the alerts to re-arm? how would a looping command work especially if the connection is lost/disconnected? any suggestions?


thanks in advance
Last edited by dawdler; 05-30-2011 at 10:34 AM.
dawdler is offline  
Reply With Quote
Old 05-31-2011, 11:31 AM   #6
dawdler
Member
 
Join Date: Dec 2010
Posts: 37
Thanks: 1
Thanked 1 time in 1 post
Default

any suggestions on how to re-arm an alert after a connection loss?
dawdler is offline  
Reply With Quote
Reply

Tags
data feed, feed, monitoring

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with monitoring Stop orders jonmoron Strategy Development 3 08-04-2010 12:35 PM
Monitoring in Real Time bobbyvl Strategy Development 1 03-25-2010 04:29 AM
Monitoring Strategy Orders/Fills Richard Von Strategy Development 11 01-29-2010 12:48 PM
Quotes Monitoring Screen NickF Miscellaneous Support 4 01-20-2010 12:39 PM
Placing orders for multiple instruments without monitoring data palinuro General Programming 3 06-03-2008 07:32 AM


All times are GMT -6. The time now is 06:37 PM.