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 02-27-2010, 01:06 PM   #1
sharkie
Junior Member
 
Join Date: Dec 2009
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default Using EMA in an array

Hi ,

I am trying to use EMA function to enter values in an array in the following way
for (i=-24 ;i==0;i++)
{
EMA_val[i]=EMA(480)[i];
EMA_sum[1]+=EMA_val[i];
}

getting an error saying that I am trying to use a field like a mathod , I looked in documantion and I am using the script as I should.

Can someone explain what I am doing worng.

Thanks
sharkie is offline  
Reply With Quote
Old 02-27-2010, 06:03 PM   #2
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

Since you are using [indx], I assume you are trying to enter values that you can then access later via bar references. Here is a better way to do it:
http://www.ninjatrader-support.com/H...iesObject.html
NinjaTrader_Ben is offline  
Reply With Quote
Old 03-01-2010, 03:02 AM   #3
sharkie
Junior Member
 
Join Date: Dec 2009
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi Ben,

I tried to do what you instructed but , I am stil l getting the same error when compiling. I attached a screen shot of what I see.

Thanks.
Attached Images
File Type: jpg ninja code error_JPG.JPG (99.0 KB, 8 views)
sharkie is offline  
Reply With Quote
Old 03-01-2010, 11:45 AM   #4
NinjaTrader_RyanM
NinjaTrader Customer Service
 
NinjaTrader_RyanM's Avatar
 
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
Default

Hello Sharkie,

Ben's suggestion was to create a DataSeries object.
This tutorial may help illustrate this concept.

Create a data series and you could then run sum method against the data series you created.
http://www.ninjatrader-support.com/HelpGuideV6/SUM.html


Using arrays is outside of NinjaScript support. I did notice you're trying to access negative index values. If you pursue this array approach, this is one thing to change. Current bar is accessed with index [0]. The bar prior to this (on the left) is accessed with [1]
Close[0]
Close[1]
NinjaTrader_RyanM is offline  
Reply With Quote
Reply

Tags
array, ema, error

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
Iorder array binwang2 General Programming 1 10-27-2009 12:52 PM
Double EMA needs a price option (OHLC)for each EMA simpletrades Indicator Development 9 08-31-2009 07:20 AM
Dispose of array irurn General Programming 2 01-27-2009 06:01 AM
Array pipsheker General Programming 1 05-24-2008 03:45 AM
Using the Strategizer how do I write the entry EMA & exit using another EMA gygraham Strategy Development 1 02-05-2008 01:48 PM


All times are GMT -6. The time now is 08:39 PM.