![]() |
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
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2009
Location: Melbourne
Posts: 178
Thanks: 3
Thanked 0 times in 0 posts
|
NT Team,
It appears the CrossAbove and CrossBelow indicators may have a bug. Using CrossAbove(IDataSeries series1, IDataSeries series2, int lookBackPeriod), where lookBackPeriod = 1, it appears the indicator is designed along the lines of if the prior series1 value is less than the prior series2 value and the current series1 value is greater than the current series 2 value than return true, else false. That is: if (series1[1] <= series2[1] && series1[0] > series2[0])While this will be correct most the time there is an exception. In the event series1 has been above series2 for the last several bars, then in the next bar series1 dips to EQUAL series2, and in the following bar series1 remains above series two this would result in the CrossAbove indicator returning "true" when a cross above has not occurred. Any input would be appreciated. Thanks Shannon |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 977 times in 960 posts
|
Shannon, thanks for your post - do you have a reproducible scenario so we can check into this?
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2009
Location: Melbourne
Posts: 178
Thanks: 3
Thanked 0 times in 0 posts
|
Bertrand,
Apologies for the tardy reply. Logically, CrossAbove and CrossBelow formulas, with the same settings should alternate when both placed in a script as price moves from above to below Series2 and vice versa. As shown the in the below listing this is not the case where CrossAboves or CrossBelows can occur consecutively. This occurs where the bar prior to the second consecutive CrossAbove / CrossBelow has its Close equal to the SMA(24). On the ES 09-09 1min, while there are many many CrossAboves / Crossbelows, below are two examples where there are two consecutive CrossAboves / Crossbelows: 'UpBar' = CrossAbove(Close, SMA(Close, 24),1) = 13/06/2009 2:24:00 AM 'Downbar' = CrossBelow(Close, SMA(Close, 24),1) = 13/06/2009 2:25:00 AM 'Downbar' = CrossBelow(Close, SMA(Close, 24),1) = 13/06/2009 2:41:00 AM 'UpBar' = CrossAbove(Close, SMA(Close, 24),1) = 13/06/2009 2:43:00 AM 'UpBar' = CrossAbove(Close, SMA(Close, 24),1) = 15/06/2009 11:26:00 PM 'Downbar' = CrossBelow(Close, SMA(Close, 24),1) = 15/06/2009 11:32:00 PM 'UpBar' = CrossAbove(Close, SMA(Close, 24),1) = 15/06/2009 11:59:00 PM 'UpBar' = CrossAbove(Close, SMA(Close, 24),1) = 16/06/2009 12:06:00 AM 'Downbar' = CrossBelow(Close, SMA(Close, 24),1) = 16/06/2009 12:15:00 AM Happy hunting Regards Shannon |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Shannon,
Not sure I entirely follow you. Once you have "crossed above" you need to come back down for it to be able to cross above another time. If you are running with CalculateOnBarClose = false, it is very possible to get a cross above = true while the bar is building, but ultimately have a cross above = false at the end of the bar which when coupled with a future bar may seem like two consecutive cross aboves.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jan 2009
Location: Melbourne
Posts: 178
Thanks: 3
Thanked 0 times in 0 posts
|
Josh,
Thank you for the reply. Apologies for my less than clear explanation. I agree 100% with your first statement, "Once you have 'crossed above' you need to come back down for it to be able to cross above another time". Though, to be complete I understand it to be "Once you have 'crossed above' you need to 'cross below' for it to be able to cross above another time". The script was run with CalculateOnBarClose = true. Please investigate the examples provided. Thanks Shannon |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Shannon,
Please try printing evaluations on every single bar and see what the values are between those events.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jan 2009
Location: Melbourne
Posts: 178
Thanks: 3
Thanked 0 times in 0 posts
|
Josh,
Not sure what you're asking. Just run the following script on the ES 09-09 1min. protectedoverridevoid OnBarUpdate() { if (CurrentBar < 100) return; // Set past SMA CrossAbove bars if (CrossAbove(Close, SMA(Close, 24),1)) { Print ( "'UpBar' = CrossAbove(Close, SMA(Close, 24),1) = " + Time.ToString()); } // Set past SMA CrossBelow bars if (CrossBelow(Close, SMA(Close, 24),1)) { Print ( "'Downbar' = CrossBelow(Close, SMA(Close, 24),1) = " + Time.ToString()); } } Shannon |
|
|
|
|
|
#8 | |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Quote:
Ray
NinjaTrader Customer Service |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| CrossAbove | GreenTrade | Strategy Development | 1 | 02-26-2009 06:56 AM |
| What does CrossAbove/Below do? | tradefaz | General Programming | 1 | 08-23-2008 12:56 PM |
| CrossBelow and Compiled Strategies | tony900hwk | Strategy Development | 4 | 07-18-2008 11:46 PM |
| Correct argument passing, CrossBelow, Stochastics | MarkBN | General Programming | 3 | 04-16-2008 07:06 AM |
| No CrossAbove/CrossBelow condition for alerts? | Elliott Wave | Market Analyzer | 1 | 04-11-2008 01:39 PM |