Download MetaTrader 5

Struggling with "Array out of range" message - page 3

To add comments, please log in or register
Carl Schreiber
7112
Carl Schreiber  
Stevetrade:

Okay, so if I'm understanding correctly, and apologies for my denseness.

I should not use arrays. I should declare a buffer for each pair I wish to take the values for and then use the buffers for the calculation, outputting to the final buffer which I wish to show on the chart?

Best regards Steve 

Steve,

please read a bit than fighting against basics - we all had to learn them, some the hard way, some in a smarter way!

You can use up to 8 indicator-buffers (IndicatorBuffers(), its as well in the docs).

As you need more arrays you have to use Arrays! To find out how to use them you can

  a) google for ArraySetAsSeries(),

  b) seek here (top left search-field)

  c) read the docs..

Look for examples - you find them as well in the reference!

Keith Watford
Moderator
10572
Keith Watford  
Stevetrade:

Okay, so if I'm understanding correctly, and apologies for my denseness.

I should not use arrays. I should declare a buffer for each pair I wish to take the values for and then use the buffers for the calculation, outputting to the final buffer which I wish to show on the chart?

Best regards Steve 

 

It was just a suggestion that you use additional buffers instead of arrays. Using arrays will work, but buffers are easier.
honest_knave
Moderator
2328
honest_knave  

Since build 600+, you can now use up to 512 buffers.

You can also make a distinction with your buffers between INDICATOR_CALCULATIONS and INDICATOR_DATA.

Personally, I'd be using buffers for this. 

Keith Watford
Moderator
10572
Keith Watford  
gooly:

You can use up to 8 indicator-buffers (IndicatorBuffers(), its as well in the docs).

 You can use a lot more buffers since the new builds

EDIT: I see that honest knave replied at the same time as me. Thanks, I couldn't remember the actual amount of buffers that can be used now.

I agree.

 Personally, I'd be using buffers for this. 

Steve Boardman
84
Steve Boardman  
gooly:

Steve,

please read a bit than fighting against basics - we all had to learn them, some the hard way, some in a smarter way!

You can use up to 8 indicator-buffers (IndicatorBuffers(), its as well in the docs).

As you need more arrays you have to use Arrays! To find out how to use them you can

  a) google for ArraySetAsSeries(),

  b) seek here (top left search-field)

  c) read the docs..

Look for examples - you find them as well in the reference!

Thanks, I'm more than happy to read and learn. It's just a bit daunting knowing where to go to find the relevant information. Thanks for pointing out some things to read.

I'm fine coding EA's, just always found indicators difficult and I'm trying to remedy that.

Best regards Steve 

Carl Schreiber
7112
Carl Schreiber  
Stevetrade:

I'm fine coding EA's, just always found indicators difficult and I'm trying to remedy that.

Just take an existing and working indicator and change it acc. to your ideas.
Steve Boardman
84
Steve Boardman  

That's what I did and this was the result. I'll check out some other ones and see if I can find some examples that better instruct me.

Best regards Steve 

Ian Venner
2584
Ian Venner  

If I were you I would try to do a simple 1 buffer indicator first and make it work correctly.

Also consider not using IndicatorCounted(). That is the old way of doing it, if you are learning you might as well learn the new way using rates_total and prev_calculated.

Study the code for the alligator indicator. It is quite simple. When you have figured out how that works you will be able to code your own.

rates_total == number of bars on the chart

prev_calculated == number of bars there were at the last tick

when you first load an indicator prev_calculated == 0

123
To add comments, please log in or register