PDA

View Full Version : Strategy self-termination


billitin
07-08-2008, 08:06 AM
Hi, there's been an issue with self-termination of a strategy run on a chart that has been bugging me for a while. I'm running latest NT version connected to TWS API. The stop happens in two cases:

(i) Order is rejected due to margin limit violation - in this case strategy halts, NT and TWS are still running
(ii) API connection is lost for a moment (e.g. IB reboots their servers) - then strategy and TWS halt, NT stays running (although without NT hooked TWS would keep up and would restore connection as soon as it re-appears)

This strategy halting is extremely annoying and is even somewhat ridiculous in the first case. What can be done to keep a strategy running?

Thanks in advance

mrlogik
07-08-2008, 08:23 AM
I can comment on (i).

You have to add this line of code in the Initialize() function

RealtimeErrorHandling = RealtimeErrorHandling.TakeNoAction;

Read in the manual about this. In the event of a rejected order you may need extra logic in your strategy to handle it.

Anthony

NinjaTrader_Ray
07-08-2008, 08:24 AM
Nothing can be done at this time. Just curious, what would you have your strategy do as it submits and order and you run into a margin limitation? Anthony is correct, there is this setting but you really would need to have some elaborate handling of order rejections. This is advanced stuff as if you don't know what you are doing you can easily create code that does not do what you expect.

billitin
07-08-2008, 09:21 AM
Thanks for the tip, now I've got something to play around with. The situation with margin is related to adding on a position when a trend evolves; the problem is that with IB I can't retrieve current account value and so I hit the limit at a certain point.