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 05-24-2008, 12:30 AM   #1
pipsheker
Junior Member
 
Join Date: Feb 2008
Posts: 16
Thanks: 0
Thanked 0 times in 0 posts
Default Array

Hi,

I am not very good in "C". I have tried to use array but always encounter error. Below is my simple code for experiment:

protected override void OnBarUpdate()
{
if (CurrentBar == 0)
Value.Set(0);
else
{
double mean = 0;
double trend = 0;
double[] w;
for (int idx = Math.Min(CurrentBar, k3m - 1); idx >= 0; idx--)
w[idx]=idx;


What is my problem?
******************
1) I am not sure whether I have define the array correctly:

for example: double[] w;


2) I am also not sure how to place the array command correctly:

for (int idx = Math.Min(CurrentBar, k3m - 1); idx >= 0; idx--)
w[idx]=idx;

Can someone give some advise please? Thanks.

Shek
pipsheker is offline  
Reply With Quote
Old 05-24-2008, 03:45 AM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Unfortunately plain C# coding support is beyond the scope what we can provide.

Hint:
Code:
double[] w;
only declares an array object. You need to allocate an actual object like
Code:
double[] w = new double[yourSize];
NinjaTrader_Dierk 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
Array question... funk101 Indicator Development 14 01-21-2009 07:37 AM
Array problem kuroro13 General Programming 12 05-13-2008 01:33 AM
Array Index Errors in Help Guide KBJ Suggestions And Feedback 1 12-16-2007 09:12 PM
Strategy Array out of Bounds Error or Output CancelAllOrders: BarsInProgress = 0 Learning1 Strategy Development 16 09-25-2007 11:02 PM
Array manipulation goldfly General Programming 1 07-01-2007 03:58 AM


All times are GMT -6. The time now is 06:19 AM.