Help with Arrays not DataSeries Compiles won't run - NinjaTrader Programming | futures io social day trading
futures io futures trading


Help with Arrays not DataSeries Compiles won't run
Updated: Views / Replies:2,678 / 4
Created: by Crassius Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Help with Arrays not DataSeries Compiles won't run

  #1 (permalink)
Elite Member
Shenandoah Valley, VA
 
Futures Experience: Advanced
Platform: NT7
Broker/Data: AMP, Zen-fire, MB Trading
Favorite Futures: EUR/USD
 
Crassius's Avatar
 
Posts: 13 since Jan 2011
Thanks: 4 given, 1 received

Help with Arrays not DataSeries Compiles won't run

I'm working on some code from John Ehler's. In his notes he says of the code,

"First the entire code is completed for each bar and the values of the variables are retained from bar to bar. However, the values of the arrays are not automatically indexed to each price bar."

So I used arrays instead of DataSeries.... At first I declared and initalized in one step in the variables section. They are all the same size and all hold a double value.

double[] q = new double[50];

That compiles but on bar six, at the first line, and first time I try to address the first array by looping through it and storing some computed values, the script fails and I get the error message in the log, Error on calling 'OnBarUpdate' method for indicator CycleSpectrum on bar 6: Index was outside the bounds of the array.

The first index I tried to access is q[8] to assign a value to it inside a loop.

So I tried splitting up the declaration in the variables section:

double[] q;

and then under protected override void Initialize()

q = new double[50];

but that didn't help... I still get the "Index was outside the bounds of the array." error message in the log.

Any help greatly appreciated.

Relevant snippets:

In Variables region:
private int n = 0;
double[] q;

In protected override void Initialize() method:
q = new double[50];

Here's the loop:

quotientForQ = 7;
for (n = 8; n <51; n++)
{
beta = Math.Cos((360/n)*(Math.PI/180));
gamma = 1/(Math.Cos((720*delta/n)*(Math.PI/180)));
alpha = gamma - (Math.Sqrt(gamma*gamma-1));

quotientForQ += 1;
q[n] = (quocientForQ/6.283185)*(smoothHP[0] - smoothHP[1]);

l[n] = smoothHP[0];

real[n] = .5*(1 - alpha)*(l[n] - olderL[n])+ beta * (1+alpha) * oldReal[n] - alpha*olderReal[n];

lMag[n] = .5*(1-alpha)*(q[n] - olderQ[n]) + beta*(1+alpha)*oldlMag[n] - alpha*olderlMag[n];
}

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,220 received


The index of smoothHP[1] doesn't exist until after bar 1.

Add at the top of #onbarupdate

if (CurrentBar < 1) return;

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #4 (permalink)
Elite Member
Shenandoah Valley, VA
 
Futures Experience: Advanced
Platform: NT7
Broker/Data: AMP, Zen-fire, MB Trading
Favorite Futures: EUR/USD
 
Crassius's Avatar
 
Posts: 13 since Jan 2011
Thanks: 4 given, 1 received

I thought of that too, but that's not it

Code removed by poster.

Problem SOLVED.


Last edited by Crassius; February 25th, 2011 at 06:36 PM.
Reply With Quote
 
  #5 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,220 received

Sorry, just saw the bar 6 reference.

Probably a math error, division by zero, reference to an index that doesn't exist, this kinda stuff. Hard to troubleshoot code snippets, plus I don't use NT. Hopefully someone else can help.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:

Reply



futures io > > > > > Help with Arrays not DataSeries Compiles won't run

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple dataseries Breakout NinjaTrader 28 March 30th, 2015 01:14 PM
This is how you do Global Arrays. bjschwenzer EasyLanguage Programming 4 January 27th, 2012 12:19 AM
Multiple dataseries intrabarpersist ohlc Big Mike EasyLanguage Programming 17 December 27th, 2011 01:14 AM
Question with arrays in MultiCharts Xyzzy EasyLanguage Programming 5 March 14th, 2011 08:52 AM
catching dataseries from DoubleMA max-td NinjaTrader Programming 1 June 12th, 2009 07:56 AM


All times are GMT -4. The time now is 05:48 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-12 in 0.10 seconds with 19 queries on phoenix via your IP 54.167.44.32