![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Apr 2007
Location: Austin, Texas
Posts: 226
Thanks: 4
Thanked 2 times in 2 posts
|
I am trying to build a simple Sto cross indicator that alerts when the Sto 100 crosses below the 80 mark and I continue to get an index error.
The error is on the following line: if (StochasticsFast(5,100)[0] < 80.0 && StochasticsFast(5,100)[1] > 80.0) It has problems with "StochasticsFast(5,100)[1]" . Index out of range. I have tried this with StochasticsFast(5,100).K[1] and quite a few other variations but have the same issue. Is this the correct way to obtain the previous value or is there a better way. Thanks, |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
The following link will provide you the answer - http://www.ninjatrader-support.com/v...ead.php?t=3170
Alternatively, you can use the following methods - CrossAbove() - http://www.ninjatrader-support.com/H...rossAbove.html CrossBelow() - http://www.ninjatrader-support.com/H...rossBelow.html
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Apr 2007
Location: Austin, Texas
Posts: 226
Thanks: 4
Thanked 2 times in 2 posts
|
That worked. Thanks.
BTW - CrossAbove/Below will only work in situations where the %K and %D cross, not for when the Moving Average pass a threshold. |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Jul 2007
Location: Fairfax, VA
Posts: 216
Thanks: 0
Thanked 0 times in 0 posts
|
|
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Apr 2007
Location: Austin, Texas
Posts: 226
Thanks: 4
Thanked 2 times in 2 posts
|
I need to read the documentation better next time :-(
You are correct. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| EMA cross Question | Ninja Learner | Strategy Development | 23 | 05-28-2009 07:13 AM |
| MTF Ema Cross | buderim | Market Analyzer | 1 | 10-17-2007 04:17 AM |
| How to write second cross over of MACD? | Jenny | Strategy Development | 2 | 07-18-2007 06:23 AM |
| Alert on cross over/under | scjohn | Market Analyzer | 5 | 05-25-2007 07:21 AM |
| Problems with simple donchian cross test | zoltran | Strategy Development | 2 | 04-02-2007 10:21 AM |