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 > Application Technical Support > Connecting

Connecting Support for establishing connections to your broker or market data service provider.

Reply
 
Thread Tools Display Modes
Old 03-05-2009, 06:23 PM   #1
GerTrader
Member
 
Join Date: Aug 2008
Posts: 38
Thanks: 0
Thanked 0 times in 0 posts
Default Connection Problems followed by NT Strategy Problems

Hello,

I have a problem with the connection of NinjaTrader with ZenFire. The Connection get lost sometimes without any reason. I have monitored the network connection and there was no interruption of the network service. NinjaTrader reconnects automatically.

But the next problem occurs with the strategies. They stop tracing open positions, which means that, when a strategy automatically enters a trade short or long, the connection get lost and NT reconnects, the position will never be closed.

Problem 2 can be solved by solving Problem 1, but i would prefer to solve both problems so that in case of a short network interruption trades don't go crazy. But again: I have a reliable broadband network connection and the interrupts of the connection between NT and ZenFire are not due to my network connection. Maybe connection options?
GerTrader is offline  
Reply With Quote
Old 03-06-2009, 05:19 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

Hi GerTrader, unfortunately the strategies will terminate if the connection is lost. Please make sure you keep an eye on your task manager, maxing the system out can also lead to disconnects.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-06-2009, 08:32 AM   #3
GerTrader
Member
 
Join Date: Aug 2008
Posts: 38
Thanks: 0
Thanked 0 times in 0 posts
Default

Is there no other possibility? Does the strategy catch open positions when restarting them manually after a disconnect and reconnect?

The problem is that my strategies rely on tight StopLosses, but when there is a disconnect, some trades just ran crazy and procude major losses.
GerTrader is offline  
Reply With Quote
Old 03-06-2009, 12:38 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

GerTrader,

You can turn off all error handling with this property. Be very careful if you decide you want to use this and monitor your connection through OnConnectionStatus().

http://www.ninjatrader-support.com/H...rHandling.html

Ultimately though, if you get disconnected there is not much NinjaTrader can do. Your position runs the risk of being unprotected and you would want to immediately resolve handling of them over on your brokerage's end.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-06-2009, 01:54 PM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

More information.

When you lose internet, the strategy will be cancelled as Bertrand has stated. Upon cancellation and restart of your strategy, NinjaTrader recalculates out its strategy position. This strategy position may or may not be in sync with the prior account position you had. On restart, you will need to be sure these two are in sync or else things will be wacky.

Again, NinjaTrader does not "recover" your prior account position. It works off of its strategy position. Please read this article as it will provide more insight into the differences between the two: http://www.ninjatrader-support2.com/...ead.php?t=4033
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-11-2009, 12:45 PM   #6
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Question

Hey Josh,

A couple of days away from going live. I have been testing on a hosted server that is dedicated solely to NT with everything striped down to the bare minimum.

Regarding this issue and syncing, etc. Could I just set something up that would simple do the following IF THERE IS A DISCONNECT.

1. System rebooted.

2. I start NT, and then restart my strategy for let's say the ES.

3. In my code, I say flatten EVERYTHING on account either working or filled for the instrument this strategy is being started for. In this case, the ES.

4. Then begin the strategy with a clean fresh slate.

Flush the system if you will if a connection is lost and then assure that everything is in order. This would hurt one's track record, but a manual note could be made stating the system went down and a notation could be made I should think.

Please let me know your thoughts on what the SIMPLEST thing would be to do in this case as I want to get live asap.

Thank you,



Quote:
Originally Posted by NinjaTrader_Josh View Post
More information.

When you lose internet, the strategy will be cancelled as Bertrand has stated. Upon cancellation and restart of your strategy, NinjaTrader recalculates out its strategy position. This strategy position may or may not be in sync with the prior account position you had. On restart, you will need to be sure these two are in sync or else things will be wacky.

Again, NinjaTrader does not "recover" your prior account position. It works off of its strategy position. Please read this article as it will provide more insight into the differences between the two: http://www.ninjatrader-support2.com/...ead.php?t=4033
r2kTrader is offline  
Reply With Quote
Old 03-11-2009, 01:01 PM   #7
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

r2kTrader,

You cannot flatten a position outside of your strategy instance. It is unaware of it and as such cannot act upon it.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-11-2009, 01:11 PM   #8
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
r2kTrader,

You cannot flatten a position outside of your strategy instance. It is unaware of it and as such cannot act upon it.
Josh,

Thank you for quick turn around. I am trying to get most of the major issues understood so I can launch.

Regarding "flushing" of the orders both live and working for a given instrument. How can I "flatten everything" so I am in sync or start clean? Would I have to go to my DOM or something and click flatten manually?
r2kTrader is offline  
Reply With Quote
Old 03-11-2009, 04:15 PM   #9
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

That would be one approach. The idea is if you know you have any open positions, be sure to close those out with a reconciliation order. This order can be submitted from anywhere you want. Whether from a DOM, directly with your broker, etc.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-13-2009, 11:10 AM   #10
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Question

Quote:
Originally Posted by NinjaTrader_Josh View Post
That would be one approach. The idea is if you know you have any open positions, be sure to close those out with a reconciliation order. This order can be submitted from anywhere you want. Whether from a DOM, directly with your broker, etc.
Josh, in order to be in sync and make sure I start with a clean slate, I am willing to just close all existing orders and live positions. So...

Could you provide a code example, that will check ALL POSITIONS both WORKING and LIVE and flatten EVERYTHING for a given instrument. This should be independent of strategy. Say for example I have a dom order working and 1 car live on ES. Before the strategy runs, I want to flush that all out programmatically and then begin the strategy with live, not historical.

Thank you,
r2kTrader is offline  
Reply With Quote
Old 03-13-2009, 11:15 AM   #11
heech
Senior Member
 
Join Date: Nov 2008
Posts: 576
Thanks: 0
Thanked 1 time in 1 post
Default

Quote:
Originally Posted by r2kTrader View Post
Josh, in order to be in sync and make sure I start with a clean slate, I am willing to just close all existing orders and live positions. So...

Could you provide a code example, that will check ALL POSITIONS both WORKING and LIVE and flatten EVERYTHING for a given instrument. This should be independent of strategy. Say for example I have a dom order working and 1 car live on ES. Before the strategy runs, I want to flush that all out programmatically and then begin the strategy with live, not historical.

Thank you,
You can just click on File->Flatten Everything, in your control center.
heech is offline  
Reply With Quote
Old 03-13-2009, 11:23 AM   #12
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

Correct heech, you can't do this programmatically. So 'Flatten everything' would certainly do the job.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-13-2009, 11:26 AM   #13
r2kTrader
Senior Member
 
Join Date: Sep 2008
Posts: 483
Thanks: 0
Thanked 2 times in 2 posts
Default

Quote:
Originally Posted by heech View Post
You can just click on File->Flatten Everything, in your control center.
Thanks for the prompt replies guys.

Let me be more clear. I don't want to flatten everything, I want to flatten everything for an instrument. I am aware of flatten everything and also through the dom.

Bertrand, just to be clear. It can't be done programmatically, or you don't support this. Is there anyway to hook into the account info and see what is out there and manually take down what I want without manual intervention.

Otherwise, it sounds like a job for HotKey.exe

Which brings me to my next question, how do I call an external program from within a strategy?


Thanks,


r2kTrader
r2kTrader is offline  
Reply With Quote
Old 03-13-2009, 11:35 AM   #14
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

r2kTrader, accessing live account info from within a NinjaScript strategy is already on our list for future versions of NinjaTrader - it's unfortunately not possible at this time. Calling an external program from NinjaScript is not supported, but you can take a look at this thread and the tip in there - http://www.ninjatrader-support2.com/...ad.php?t=11391
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-13-2009, 11:42 AM   #15
heech
Senior Member
 
Join Date: Nov 2008
Posts: 576
Thanks: 0
Thanked 1 time in 1 post
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
Calling an external program from NinjaScript is not supported, but you can take a look at this thread and the tip in there - http://www.ninjatrader-support2.com/...ad.php?t=11391
I use Macros Express Pro for startup.

To access any program programmatically from your strategy... this is the wonder of using C# (as opposed to random toy languages). You can do anything C# + .NET can do.

So, that means:
http://www.developer.com/net/csharp/article.php/3707996

Until NT 7 is available... I personally plan on tying into the TWS API directly, and monitoring positions (just looking for discrepancies) directly through the API.
heech is offline  
Reply With Quote
Reply

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
Esignal Connection Problems jwanch1 Connecting 8 03-12-2010 10:34 AM
Esignal Connection Problems with NT V6.0.0.11 svrz Connecting 4 05-01-2009 09:26 AM
MBT connection problems dtf139 Connecting 5 09-10-2008 06:49 AM
Tradestation connection problems VTtrader Historical NinjaTrader 6.5 Beta Threads 8 03-06-2008 12:50 PM
Connection Problems 9Baller Miscellaneous Support 4 12-12-2005 03:28 PM


All times are GMT -6. The time now is 03:22 AM.