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 > 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 08-12-2009, 05:45 PM   #1
sharpie
Member
 
Join Date: Jul 2009
Location: Victoria BC
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
Default CrossOver not detected

If a crossover occurs one way in a bar and then reverses and crosses the other way in the same bar, what test is true if checking OnBarUpdate for both conditions?
Attached Images
File Type: jpg URE.JPG (30.5 KB, 13 views)
File Type: jpg URE2.JPG (38.9 KB, 8 views)
Last edited by sharpie; 08-12-2009 at 05:48 PM.
sharpie is offline  
Reply With Quote
Old 08-13-2009, 05:37 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,420
Thanks: 252
Thanked 981 times in 963 posts
Default

sharpie, which CalculateOnBarClose setting do you use in realtime trading? In backtesting it would always be evalutated on the Close of the bar, as the intrabar tick formation is not known.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 08-13-2009, 07:16 AM   #3
sharpie
Member
 
Join Date: Jul 2009
Location: Victoria BC
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
Default

I ran 2 parallel tests against reat time data. On one, CalculateOnBarClose was set to "true" and on the other "false". On the "false" one, nothing happened. On the case presented, it was set to "true".
sharpie is offline  
Reply With Quote
Old 08-13-2009, 07:30 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

sharpie,

There is no test for both of these. If you want to know what happens intrabar you have to use CalculateOnBarClose = false. CrossAbove/Below conditions do not check current tick versus previous tick though. It checks last tick versus previous bar or whichever bar the lookback period is set to.

You would need to keep track of the previous tick yourself to be able to check current tick versus last tick for crosses.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-13-2009, 07:53 AM   #5
sharpie
Member
 
Join Date: Jul 2009
Location: Victoria BC
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
Default

Back to my original question. OnBarClose, I tested first for CrossBelow and exited any long position I may have had (I didn't have one). Then I tested for CrossAbove and triggered a buy. This morning I reversed the order of the two tests. On that basis, the CrossAbove should still trigger a buy, but the test for CrossBelow should also be positive (was the last crossover to occur) and cancel the long entry. Y/N?
sharpie is offline  
Reply With Quote
Old 08-13-2009, 07:57 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

No. CrossAbove/Below checks current bar versus previous bar. It does NOT check current tick vs previous tick. There is no way you can be true on cross above and below for the same bar.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-13-2009, 08:11 AM   #7
sharpie
Member
 
Join Date: Jul 2009
Location: Victoria BC
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
Default

Many thanks. I'll look into testing on tick vs previous tick.
sharpie 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
MACD Crossover nybangali General Programming 25 10-29-2010 02:11 PM
MACDBBLines - How To Specify Crossover? dkrumholz Strategy Development 1 08-10-2009 05:36 AM
Crossover (Intraday) BillCh Automated Trading 1 02-09-2009 12:41 AM
Once per crossover? 5iver Strategy Development 6 12-13-2008 12:37 PM
Common Language Runtime detected an invalid program. VagyokC4 Miscellaneous Support 3 10-15-2007 12:25 AM


All times are GMT -6. The time now is 10:17 AM.