NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM 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 > Automated Trading

Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader.

Reply
 
Thread Tools Display Modes
Old 01-20-2012, 05:46 PM   #1
jupiejupe
Senior Member
 
Join Date: Aug 2009
Location: bay area
Posts: 127
Thanks: 1
Thanked 2 times in 1 post
Default OnBarUpdate Processes

during OnBarUpdate i am checking is this is serialized or not.


i have a strategy that reverses on the same bar, an exit and an entry order.
the problem is that during backtesting the orders always fire exit followed by the entry order, forward testing this is not the case. entry orders can be executed before the exit.

i can only figure this happens because OnBarUpdate processes are not serialized within this process.

if they are then exit orders or not confirmed before the entry order is sent.

i can not figure out any other reason for this to happen.
jupiejupe is offline  
Reply With Quote
Old 01-21-2012, 01:26 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

jupiejupie, I'm not exactly sure why you feel it would matter for use but yes that could happen - in realtime trading / simulation you're not processing events according to a historically known sequence but it would depend then on realtime market dynamics seen, the command to reverse will issue 2 orders to achieve that, whoever fills first will be the exit order and the other will serve to get you into the new desired direction.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-21-2012, 01:35 AM   #3
jupiejupe
Senior Member
 
Join Date: Aug 2009
Location: bay area
Posts: 127
Thanks: 1
Thanked 2 times in 1 post
Default

it matters because every once in a while the strategy places double my contract for the position. but it never does this in backtesting only forward testing, so it is not something that i have control over, it's totally how nt7 places and receives orders.

i only want my contacts double if i choose to do so not because nt7 gets confused as to the orders placed.
jupiejupe is offline  
Reply With Quote
Old 01-21-2012, 01:38 AM   #4
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

There would be normally 2 reasons seen for this :

a) strategy vs account position not in sync as needed

b) you're placing doubled up orders on your conditions such as placing an Exit order on the reversal signal when the enter method would do the reverse for you automatically

This could only be understood by simplifying and debugging your strategies order event sequence. One very useful tool is the TraceOrders feature :

http://www.ninjatrader.com/support/f...ead.php?t=3627
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 01-21-2012, 01:44 AM   #5
jupiejupe
Senior Member
 
Join Date: Aug 2009
Location: bay area
Posts: 127
Thanks: 1
Thanked 2 times in 1 post
Default

yes i am placing a exit order and then a entry order, so if i just reverse instead that will take care of the problem?

thanks so much

can you also look at this reply, the ninja assist left work before it was resolved, i'd like to get some coding finished this weekend

http://www.ninjatrader.com/support/f...ad.php?t=46985
jupiejupe is offline  
Reply With Quote
Old 01-21-2012, 01:46 AM   #6
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

Quote:
Originally Posted by jupiejupe View Post
yes i am placing a exit order and then a entry order, so if i just reverse instead that will take care of the problem?

thanks so much

can you also look at this reply, the ninja assist left work before it was resolved, i'd like to get some coding finished this weekend

http://www.ninjatrader.com/support/f...ad.php?t=46985
I will look into the thread - correct in case of a reverse don't issue an Exit individually, let the Enter() methods do this as needed for you.
NinjaTrader_Bertrand is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Bertrand for this post:
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
How do I kill ALL NT processes in Task Manager? Rocket130713 Automated Trading 1 08-19-2010 04:31 AM
OnBarUpdate eqtrader General Programming 5 07-28-2010 10:37 AM
OnBarUpdate() Rhyshaelkan General Programming 0 01-09-2010 03:11 PM
Twice through OnBarUpdate()? cybertunerone Strategy Development 4 02-08-2009 01:52 AM
OnBarUpdate SystemTrading Miscellaneous Support 3 08-20-2008 10:38 AM


All times are GMT -6. The time now is 12:50 AM.