Newbie Array's: Why cant I use an array as an array why Must it be an indicator buffer in order to get data to be displayed

 

I am very perplexed as to why #1 Meta quotes would limit the buffers to 8 rather than 16 or 32.... it's the 21st century and we have the memory now....


secondly I have tried my darnedest to try to emulate the trend indicator "Bollinger Bands" use of levels. Through the levels one can resolve double std deviation of Bollinger Band Channel envelopes. With this indicator you are able to set 32 Channel envelopes using levels. If I knew this secret technological coding method I would be in programmers Heaven. But alas I have been struggling off and on for weeks on this dilemma.


SO... My current problem is the reasoning of WHY I can not use simple arrays to calculate intermediate steps needed to generate the data being displayed in an indicator buffer. For instance, the TRIX indicator need only display 2 indicator buffers for the TRIX and the signal, but I must loose 3 additional indicator buffers during the calculation of iMA's. This means that one has the potential to run out of buffers very easily.


To try and solve this problem I attempt to use a function library to do the necessary calculation and return the result similar to what an iTRIX function. To my dismay, while one can dimension arrays in a function, it seems that their data is extracted as 0.0 and must STILL be assigned somehow to an indicator buffer. Am I to understand that I will need to purchase c compilers to do my dirty work for me?


I am so hoping that I am missing a very fundamental programming aspect or trick that will allow me to build finish a somewhat complex agent that I am working on.



Thanks for the help

John McGlaughlin

Vampire Trading Network

 

"SO... My current problem is the reasoning of WHY I can not use simple arrays to calculate intermediate steps "

Who said you can't?

 

Maybe some history reason, MT limited the buffers to 8.

Maybe you do not know, now MT use dateime format based on seconds from 1970.1.1.0:0:0.

so such datetime format only can be used to 2038 of this century, this is that 2nd Millennium Bug.

I think, MT will change it in future.

 
phy:

"SO... My current problem is the reasoning of WHY I can not use simple arrays to calculate intermediate steps "

Who said you can't?

phy:

"SO... My current problem is the reasoning of WHY I can not use simple arrays to calculate intermediate steps "

Who said you can't?

IndicatorShortName("FORESIGHT");
SetIndexLabel(0,"FORESIGHT");
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,Foresight_Buffer);
SetIndexLabel(1,"Signal");
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,Signal_Buffer);
SetIndexLabel(2,NULL);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,Zero_buffer);
//---- no drawing of EMA's
SetIndexBuffer(3,EMA1_buffer);
SetIndexBuffer(4,EMA2_buffer);
SetIndexBuffer(5,EMA3_buffer);

One HAS TO SetIndexBuffers of the Moving Average buffers which will compute the Triple exponential moving average.
//---- no drawing of EMA's

IndicatorBuffer(3); //--- no longer need EMA buffers...

/*
SetIndexBuffer(3,EMA1_buffer);
SetIndexBuffer(4,EMA2_buffer);
SetIndexBuffer(5,EMA3_buffer);

*/

effectively removes the declaration of the Exponential MA calculation array as an indicator buffer.


The code compiles and runs fine, aside from the divide by zero bug now introduced since all array data is 0.0.



Returning IndicatorBuffers to 6 and SetIndexBuffer code allows the arrays to compute their desired numbers.



John

 

John, MT4 is limited to 8 index buffers for drawing, or, you can use some of those 8 for "convenient" data storage for caluclation of the drawing indexes.

You can also use regular array for data storage for calculation of drawing index, but you will need to manage the size and array type yourself. See ArrayResize() and ArraySetAsSeries().

 
phy:

John, MT4 is limited to 8 index buffers for drawing, or, you can use some of those 8 for "convenient" data storage for caluclation of the drawing indexes.

You can also use regular array for data storage for calculation of drawing index, but you will need to manage the size and array type yourself. See ArrayResize() and ArraySetAsSeries().

Ah.... This would be a great missing lesson tp be added by guru.

In short, I need to dimension my array requirements. I remember seeing ArraySetAsSeries

Thank you for your insight.

John

 
Use ArraySetAsSeries() when you are going to use the iMAOnArray() or similar built-in functions on your self managed data array. If not set as a series array, for some reason the data is read "backwards".
Reason: