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 04-01-2009, 07:44 AM   #1
sebastienb
Junior Member
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 0 times in 0 posts
Default Oco

Hi All,

Does an OCO order submited thanks to the NTCommand function has to be linked with an ATMStrategy ? I want to use OCO orders but not the SuperDOM is this possible ?

I have this in my code :
Success = NTCommand("PLACE", AccountID, "SELL", TG1Qty, "LIMIT", PivotLevel + TicksTarget1, 0, "DAY", "StopLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "TargetLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "", "");

I don't have any error message, NT is processing, but nothing happen there is no order placed in the market :

01/04/2009 14:50:38;ATI;AT,
'PLACE;Sim101;FESXM09;BUY;1;LIMIT;1961;0;DAY;StopS hort1_FESXM09_NT_Cassure_v1_A_14:50:31;TargetShort 1_FESXM09_NT_Cassure_v1_A_14:50:31;;' processing ;

Regards.
sebastienb is offline  
Reply With Quote
Old 04-01-2009, 08:44 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, you don't have to call an ATM strategy template with the Command function however when you do this the stop and target will be linked via OCO. So you don't see a limit order 'Working' under the orders tab with your command?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 04-01-2009, 08:50 AM   #3
sebastienb
Junior Member
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 0 times in 0 posts
Default

Correct I don't see neither the limit order nor the stop order working under th orders tab.

I don't know why, is something wrong with my NTCommand (I use TradeStation for signal generation) ?
sebastienb is offline  
Reply With Quote
Old 04-01-2009, 09:24 AM   #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

sebastienb,

Just to be clear, the way you place OCO orders for stops and targets is you need to call NTCommand() twice and place in a stop order and a target order. Then you want to be sure that on the OCO parameter for the NTCommand() that you use the same OCO id for both the stop and target orders.
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-01-2009, 09:59 AM   #5
sebastienb
Junior Member
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 0 times in 0 posts
Default

What's surprising is that it looks like that what I did is correct.

Here is the NTCommand that I use in my TS code :

Success = NTCommand("PLACE", AccountID, "SELL", TG1Qty, "LIMIT", PivotLevel + TicksTarget1, 0, "DAY", "StopLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "TargetLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "", "");

Success = NTCommand("PLACE", AccountID, "SELL", TG1Qty, "STOP", 0, PivotLevel - TicksStop1, "DAY", "TargetLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "StopLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "", "");
sebastienb is offline  
Reply With Quote
Old 04-01-2009, 10:01 AM   #6
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

Are you still experiencing difficulties?
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-03-2009, 02:33 AM   #7
sebastienb
Junior Member
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 0 times in 0 posts
Default

Still experiencing difficulties. I'm currently using the Sim Mode does this have an impact on OCO orders placement ?
sebastienb is offline  
Reply With Quote
Old 04-03-2009, 05:21 AM   #8
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

No, the orders would then only be placed on the Sim101 internally. Are you connected to live data in NinjaTrader when you try your code?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 04-03-2009, 10:06 AM   #9
sebastienb
Junior Member
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 0 times in 0 posts
Default

Yes I'm connected to the TradeStation live date feed.

I tried to use the NTCommand to change on order and had the same problem, processing but nothing happen :

Success = NTCommand("CHANGE", "", "", RemainingPos_TBT, "", 0, PrixTheorique, "", "", "StopLong1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, "", "");

I didn't have any error message but my order wasn't changed and in the log tab I have this :

03/04/2009 18:04:25;ATI;AT, 'Cancel;;FESXM09;;0;;0;0;;;EnterLong_FESXM09_NT Color Switch_A_17:55:22;;' processing ;

I don't understand where is my mistake
sebastienb is offline  
Reply With Quote
Old 04-03-2009, 10:38 AM   #10
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

sebastienb, please contact me at support at ninjatrader dot com Attn Bertrand with your log and trace files and the TS code you used, I will then review this and get back to you - Thanks!
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 04-03-2009, 11:57 AM   #11
sebastienb
Junior Member
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 0 times in 0 posts
Default

Ok thanks Bertrand I will send to you the code.

I have another question I have this in my strategy :

If PositionLive_TBT < 0 then begin
Success = NTCancel("TargetShort1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID);
Success = NTCancel("TargetShort2" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID);
Success = NTCancel("StopShort1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID);
Success = NTSellMarket("ExitShortOnReverse" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID, RemainingPos_TBT);
End;

The SellMarket is correctly send in the but orders "TargetShort1" and TargetShort", "Stopshort1" are not canceled I'm not sure to understand why ?

ManyThanks,

Sebastien
sebastienb is offline  
Reply With Quote
Old 04-03-2009, 12:11 PM   #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

Thanks I will have a look at the code and comment - do you get an error for the order id not being found, I suspect and issue there, can you try with a simple one to verify like the "MyOrderId" used in the NTSample TS code?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 04-04-2009, 02:16 AM   #13
sebastienb
Junior Member
 
Join Date: Feb 2009
Posts: 16
Thanks: 0
Thanked 0 times in 0 posts
Default

Bertrand I'm not sure to understand what you want me to do, to replace

Success = NTCancel("TargetShort1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID);

by something simpler like (is my original order ID to long ?)

Succes = NTCancel("MyOrderId")

Or to do something like this :

MyOrderID = "TargetShort1" & "_" & SymbolID & "_" & StrategyID & "_" & StratSubID & "_" & OrderID

Succes = NTCancel(MyOrderId)

Regards,

Sebastien
sebastienb is offline  
Reply With Quote
Old 04-06-2009, 06:16 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

Hi Sebastien - yes I was suggesting simplifying your code to track down the issue and then work up from there. Did you already send me your code to support at ninjatrader dot com? Then I can have a look...Thanks!
NinjaTrader_Bertrand 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
OCO orders stefy Strategy Development 6 03-01-2010 03:53 AM
IOrder and OCO CashCache Strategy Development 5 01-11-2010 08:17 AM
OCO Bracket Bid/Ask rtj4201 Automated Trading 2 01-13-2009 12:42 PM
OCO support? adrian Strategy Development 2 04-11-2008 12:36 PM
Overiding OCO jlm0@infionline.net General Programming 5 09-13-2007 08:19 AM


All times are GMT -6. The time now is 09:33 PM.