NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 08-31-2007, 03:57 PM   #1
Wataizo
Junior Member
 
Join Date: Aug 2007
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
Default Indicator value set and get question (n00b)

Please correct my understanding of the following:

I set an indicator's value with
Value.Set = High + 3;

and I can get "previous bar" values of the indicator by
double foo = Value.Get(0); //gets current value
foo = Value.Get(1); //previous bar?

From the manual it implies I could also
double foo = Values[1]; // previous bar?

Thanks!
Regards,
Raj
Wataizo is offline  
Reply With Quote
Old 09-01-2007, 09:36 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

Hi Raj,

Always use for setting:

Value.Set(High[0] + 3);

For getting, always use:

Values[int barsAgo]
NinjaTrader_Ray is offline  
Reply With Quote
Old 09-02-2007, 04:49 PM   #3
Wataizo
Junior Member
 
Join Date: Aug 2007
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
Default Comparing Values

Ray, hi,
Thanks for the advice.
I am setting the indicator value with what should be a "double", such as

double foo = ...some math...;
Value.Set(foo);


Then I want to compare current/previous-bar indicator values, for example,
if((Values[0] > Values[1]) & (Values[1]< Values[2]))
{. . . }

But I get the compiler warning
"Operator '>' cannot be applied to operands of type 'NinjaTrader.Data.DataSeries and NinjaTrader.Data.DataSeries"

So I'm still doing something wrong. Thanks again for your help!
Regards,
Raj
Wataizo is offline  
Reply With Quote
Old 09-02-2007, 05:22 PM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

"Values" is an array that holds DataSeries objects so you are comparing a DataSeries object in slot 0 to one in slot 1. What you need to do is something like:

Values[0][0] > Values[0][1] && Values[0][1] > Values[0][2]....
NinjaTrader_Ray 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
Latest Pivot Indicator question Greg1 Charting 13 12-09-2009 11:48 AM
Using Strategy Wizard to develope Indicator on Indicator mrlucky1x Indicator Development 3 08-25-2007 04:09 PM
Question about "Split Volume Indicator" RedDuke Indicator Development 1 04-25-2007 02:46 AM
Indicator Titling Question Greg1 Charting 1 04-05-2007 11:57 PM
Question about Linear Regression indicator Lupus Charting 5 02-16-2006 07:31 PM


All times are GMT -6. The time now is 11:00 PM.