Here is a test indicator. There are two data arrays. One is set as a series, the other, not. Both data arrays are filled with the same data. The values are bar closing price. Then, iMAOnArray is taken on each data array The result is a 10 period moving average of closing price
Using "normal" array fill methods, yes. If you put bar0 data into array0, bar1 into array1, etc, then use ArraySetAsSeries on the array before using the built in iXxxOnArray function.
Forgive me for taking up so much of your time with this. Thanks for all your help, but I'm afraid I have a second question.
Is it possible to have an array within an array? In other words, let us say that we have put RSI data in an array. We want to run an MA on this RSIarray. But then we want to store this data in a second array, MAofRSIarray, and run a further function, such as Momentum, on this MAofRSIarray. In the end, we will then have MomentumofMAofRSIArray. Obviously we need to use iMAonArray and iMomentumonarray in combination.
Thanks for the quick reply. If I understand correctly, a multidimensional array is just a collection of data that can be from different sources. However, here we want to create an array, run xxxonarray on that array, store the new data in an array, and then run yyyonarray on this new array. I don't see how a multidimensional array applies here. Or did I miss something?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Here is a test indicator.
There are two data arrays. One is set as a series, the other, not.
Both data arrays are filled with the same data. The values are bar closing price.
Then, iMAOnArray is taken on each data array
The result is a 10 period moving average of closing price
#property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 Lime double arraySeries[]; double arrayNot[]; int init() { SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,arrayNot); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,arraySeries); SetIndexDrawBegin(0, Bars - 490); SetIndexDrawBegin(1, Bars - 490); return(0); } int deinit() { return(0); } int start() { int i; double dataNot[501]; double dataSeries[501]; ArraySetAsSeries(dataNot, false); ArraySetAsSeries(dataSeries, true); for(i = 500; i >=0 ; i--){ dataNot[i] = Close[i]; dataSeries[i] = Close[i]; } for(i = 490; i >= 0; i--){ arrayNot[i] = iMAOnArray(dataNot, 0, 10, 0, 0, i); // red } for(i = 490; i >= 0; i--){ arraySeries[i] = iMAOnArray(dataSeries, 0, 10, 0, 0, i); // green } return(0); }Thank you.
Note which method in the test gives a valid moving average line, and how it is acheived.
Thanks
Is it possible to have an array within an array? In other words, let us say that we have put RSI data in an array. We want to run an MA on this RSIarray. But then we want to store this data in a second array, MAofRSIarray, and run a further function, such as Momentum, on this MAofRSIarray. In the end, we will then have MomentumofMAofRSIArray. Obviously we need to use iMAonArray and iMomentumonarray in combination.
Can this be done, and if so, how?
47steps
array[5][11][7] for example, 3 dimensios..
5 elements, 11 wide, each of which is somehow 7 deep
"Arrays are allowed to be maximum four-dimensional. Each dimension is indexed from 0 to dimension size-1."