![]() |
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
|
|||||||
| 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. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jul 2009
Location: Victoria BC
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
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?
Last edited by sharpie; 08-12-2009 at 05:48 PM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,420
Thanks: 252
Thanked 981 times in 963 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jul 2009
Location: Victoria BC
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
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".
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Jul 2009
Location: Victoria BC
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
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?
|
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Jul 2009
Location: Victoria BC
Posts: 57
Thanks: 0
Thanked 0 times in 0 posts
|
Many thanks. I'll look into testing on tick vs previous tick.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |