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 > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 02-17-2008, 06:14 AM   #1
gyoung
Senior Member
 
Join Date: Apr 2007
Location: Austin, Texas
Posts: 226
Thanks: 4
Thanked 2 times in 2 posts
Default Simple STO Cross problem

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,
gyoung is offline  
Reply With Quote
Old 02-17-2008, 08:08 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

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
NinjaTrader_Ray is offline  
Reply With Quote
Old 02-18-2008, 04:37 AM   #3
gyoung
Senior Member
 
Join Date: Apr 2007
Location: Austin, Texas
Posts: 226
Thanks: 4
Thanked 2 times in 2 posts
Default

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.
gyoung is offline  
Reply With Quote
Old 02-18-2008, 05:33 AM   #4
Pete S
Senior Member
 
Join Date: Jul 2007
Location: Fairfax, VA
Posts: 216
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by gyoung View Post
BTW - CrossAbove/Below will only work in situations where the %K and %D cross, not for when the Moving Average pass a threshold.
Nope. There are 2 signatures, one that takes 2 data series and one that takes a constant.
Pete S is offline  
Reply With Quote
Old 02-18-2008, 11:19 AM   #5
gyoung
Senior Member
 
Join Date: Apr 2007
Location: Austin, Texas
Posts: 226
Thanks: 4
Thanked 2 times in 2 posts
Default

I need to read the documentation better next time :-(
You are correct.
gyoung 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
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


All times are GMT -6. The time now is 08:57 AM.