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 > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 06-13-2009, 09:08 AM   #1
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default problem with dataseries... I think

Hello,

I"m not at all a "good" coder, but have had some success using dataseries in the past. The script code below doesn't work (doesn't paint anything in pane, just blank). I did some debugging (commenting out things one at a time) and it seems that the problem stems from when the code tries to access myDataSeries[1]. When the code calls for myDataSeries[0], it seems ok.

Here is the code:

myValue = EMA(Typical,period)[0];
myDataSeries.Set(myValue);

myValue1 = 2*(myDataSeries[0]-myDataSeries[1])/(myDataSeries[0]+myDataSeries[1]);
myDataSeries2.Set(myValue1);
Plot0.Set(100*EMA(myDataSeries2,3)[0]);

And yes, I have the proper variables declared and the dataseries initialized in the proper place. Any ideas? I'm hoping I've done something really stupid

Thanks much for any help!
coolmoss is offline  
Reply With Quote
Old 06-13-2009, 10:17 AM   #2
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

Isn't this what you want as the last statement

Value.Set(100*EMA(myDataSeries2,3)[0]);
whitmark is offline  
Reply With Quote
Old 06-13-2009, 10:33 AM   #3
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default

Hello and thanks for your help.

I don't think that's what I want, but I can tell you during debugging, I just commented out my last line (with the Plot0) in it and instead just had Plot0.Set(High[0]). Even that didn't work. If I remove all reference to myDataSeries[1] and replace it with something trivial, then the indicator will plot.
coolmoss is offline  
Reply With Quote
Old 06-13-2009, 10:41 AM   #4
astra
Senior Member
 
Join Date: Mar 2008
Posts: 142
Thanks: 0
Thanked 0 times in 0 posts
Default

Do you have on top of BarUpdate() something like:
if (CurrentBar < Period) return; ?
astra is offline  
Reply With Quote
Old 06-13-2009, 12:01 PM   #5
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default

no I do not, I'll give that a try, thanks.
coolmoss is offline  
Reply With Quote
Old 06-13-2009, 12:04 PM   #6
coolmoss
Senior Member
 
Join Date: Dec 2007
Posts: 365
Thanks: 36
Thanked 28 times in 24 posts
Default

S W E E T!!!

Thank you both for your help. Testing for enough bars present seems to have done the trick.
coolmoss 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
Plotting DataSeries gg80108 Charting 4 11-22-2009 03:01 PM
DataSeries Object Help zenith1107 General Programming 1 05-21-2009 07:43 AM
DataSeries converting gg80108 General Programming 3 04-24-2009 02:58 PM
How to copy DataSeries to another DataSeries xewoox General Programming 8 12-02-2008 07:53 AM
Indicator on a DataSeries jriverac Strategy Development 17 06-09-2008 11:42 AM


All times are GMT -6. The time now is 07:44 AM.