View Full Version : Nt + Ib + Ts
StockMaster
10-12-2009, 12:22 PM
I am working with Sim NT trying to figure out if i can automate my trading strategy from TS to IB using NT Dlls
But now i am getting this error message
"Order Event Warning.Attribute 'Outside Regular Trading Hours's ignored based on the order type and destination. Place order is now being processed. (2109)
When i try to place a DAX OCO stop and limit.
I browsed over the forum and i saw many users reported this problem but that was back in 2008.
I am using latest Ninja + Latest TWS.
Is this issue still unsolved?
Is there any workarround?
Best Regards
SM
NinjaTrader_Jason
10-12-2009, 12:33 PM
Hello SM,
The error message is related to your default order settings in TWS. I believe orders outside regular hours are disbaled in TWS on your end. However, the order is processed anyway based on the order type and destination.
In addition, please have TWS version 895 installed as per the IB connection guide at the link below.
http://www.ninjatrader.com/webnew/support_interactivebrokers.htm
StockMaster
10-12-2009, 12:56 PM
Hi Jason
Actually i found something interesting
Order is only rejected if i use the NT Command function as follows
NT Command ("Place","","BUY",1"stop",0,5900,"","123","MyOrderID","","");
NT Command ("Place","","BUY",1"Limit",0,5700,"","123","MyOrderID2","","");
If i use the NTBuyStop i do get the warning message but the order is accepted.
I used NT Command in order to send OCO orders.
Is it possible the OCO is creating the problem?
Best Regards
NinjaTrader_Josh
10-12-2009, 01:36 PM
For your order type, you should just use STOPLIMIT instead of two separate orders. Wouldn't that do what you want or am I missing something?
StockMaster
10-12-2009, 02:28 PM
I want to send an OCO order after a Position is taken.
So if i am Short, after recieving fill confirm i want to send a Stop to buyand a limit to buy linked by OCO Id.
IF i try to do so by NTCommand:
IF fill then ...
NTCommand ("Place","","BUY",1"stop",0,5900,"","123","MyOrder ID","","");
NTCommand ("Place","","BUY",1"Limit",0,5700,"","123","MyOrder ID2","","");
both orders get canceled.
BUT if i send the same orders but by using the NTBuyLimit and NTBuyStop (not linked by OCO) i dont get the error.
So i wonder IF it can be something related to the OCO link that is bing rejected by IB.
Regarding the IB default order settings in TWS, i have selected Futures and "alow orders to be triggered outside..." something something (forgot the exact saying there).
Pic Below shows the settings
NinjaTrader_Josh
10-12-2009, 02:43 PM
Make sure you are filling out the proper NTCommand fields.
It seems as if both your NTCommands are sending stop prices and not one stop and one limit. You are also missing a comma before the orderType parameter.
StockMaster
10-12-2009, 02:50 PM
Hello Josh, i think i may have commited a typo while typing in the code here in the forum.
Lets do it propperly and use copy paste
Here is the 2 command lines i used
Success =NTCommand("place", "", "Buy", 1, "Stop", 0, 5900, "Day", "OCO123", "MyOrderIdStp", "", "");
Success =NTCommand("place", "", "Buy", 1, "Limit", 5700, 0, "Day", "OCO123", "MyOrderIdLmt", "", "");
I reviewed it line by line and i dont think i done anything wrong. Still the orders are being canceled. Unless i use them by NTBuyStop and NTBuyLimit commands, which again makes me think it can be related to the OCO or TimeInForce ID's.
The log wont especify why the order is canceled except the error showed in the 1st image.
But then again, the BUYLimit and BUYstop commands show the same warning message but orders are not canceled.
Best regards
NinjaTrader_Josh
10-12-2009, 03:09 PM
Please try submitting your orders to Sim101 instead of IB to isolate if it is IB or something with the order submission process causing the issue.
StockMaster
10-12-2009, 03:15 PM
Will try first thing tomorrow morning when dax reopens
Thank you Josh!
StockMaster
10-13-2009, 12:38 PM
I encontered a diferent problem now, not so much related to the DLL but maybe someone here has a clue of what i may do to fix this.
I went deeper in the coding of my strategy:
Basicly what i have is the Starting position trades to get triggered at the end of the bar.
Although, i thought about ONLY sending the positions protective orders, Stop and Limit after getting the report back from IB about the fill, as well the fill price.
My problem is as i cant wait one more bar to send Stop and Limit orders i have to send them with update every tick enabled on TS.
The problem is this makes the code send Multiple Stop and Limit orders, basicly it sends so many that IB starts rejecting them. The code only stops sending this orders when the bar closes.
Does anyone of the members of the forum, or maybe the NT support knows this behaviour and or any work arround for it?
Best Regards
NinjaTrader_Josh
10-13-2009, 12:45 PM
StockMaster,
I guess I am not following you. Why would your TS code submit the same order so many times? Could you not limit it with some if-statements? Once submitted, stop resubmitting?
StockMaster
10-13-2009, 12:49 PM
Hello Josh
First of all, i am testing the OCO orders and after several reviews of the settings i think i got that working. I still get the Warning messaged in the Log of NT but they are submitted and not canceled.
Regarding the Multimple orders.
Yes, that seems to be the case. The way TS works, on each tick of each bar it will resubmit the orders. I think i may have to work in a way to make TS Lock inside the bar the variable so i can STOP the code to resubmitting. I was reading about a paramenter "intrabarpersist".
But i thought about inquiring to be sure there was no other work arround
Best Regards
NinjaTrader_Josh
10-13-2009, 12:53 PM
StockMaster,
The message may occur. If your orders go through, it can be ignored.
I think that workaround will be the best way to continue with the constant resubmissions.
evanscje
05-13-2011, 03:04 PM
If I use the NTBuyStop() command in a TS strategy can I insert
open next bar + .25*Avgtruerange(20) as my stop level ?
- (just like I do in TS/EL normally)
NinjaTrader_Josh
05-13-2011, 03:14 PM
evanscje,
Unfortunately we are not EL experts so could not comment on EL code. But in general, what you would want to do is call NTBuyStop() and in the stop price pass in whatever you want the stop price to be. When the code is reached, it will submit a buy stop order to NT. I would imagine you would need to wait till the next bar to be able to get that bar's open price in correctly, but again, since I am not a TS/EL expert you would have to try. I suggest just printing out the values of what you get when you try something like open enxt bar + .25*Avgtruerange(20) and see if that matches what you were looking for.