Hi everyone,
For the first time i would like to use an array in my EA but i have no idea how to do it. I read a lot about the topic but I still don't understand how it actually works so I hope someone could be so kind to give me a push in the right direction.
what i want to achieve :
At the close of every candle I have a variable X that contains either 0 or 1, based on some calculated actions. I would like to push this value in the last position of an Array[3] so I could read the results from the last three candle calculations at the end of each candle
so if the last three values of X were 0 (candle close -2),1 (candle close -1) and 0 (last candle close) I would like to do Y = Array[2]+"-"+ Array[1]+"-"+ Array[0] , so in this case the result would be 0-1-0
basically at each candle close i have a new X value so i need to get rid of the oldest position, move the other two one up and fill (last candle close) with the new X value.
How could I do this?
Thank you all for any kind of help, it would be highly appreciated..
The best option is to write an indicator. The indicator can visualize a line (or three lines).
int array[]; int as=5; ArrayResize(array,as); for(int x=0; x<as; x++) array[x]=x; string text; for(int x=0; x<as; x++) text+=(string)array[x]+" "; Print(text); ArraySetAsSeries(array,true); ArrayResize(array,as-1); ArraySetAsSeries(array,false); ArrayResize(array,as); array[as-1]=5; text=""; for(int x=0; x<as; x++) text+=(string)array[x]+" "; Print(text); ArraySetAsSeries(array,true); ArrayResize(array,as-1); ArraySetAsSeries(array,false); ArrayResize(array,as); array[as-1]=6; text=""; for(int x=0; x<as; x++) text+=(string)array[x]+" "; Print(text);
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone,
For the first time i would like to use an array in my EA but i have no idea how to do it. I read a lot about the topic but I still don't understand how it actually works so I hope someone could be so kind to give me a push in the right direction.
what i want to achieve :
At the close of every candle I have a variable X that contains either 0 or 1, based on some calculated actions. I would like to push this value in the last position of an Array[3] so I could read the results from the last three candle calculations at the end of each candle
so if the last three values of X were 0 (candle close -2),1 (candle close -1) and 0 (last candle close) I would like to do Y = Array[2]+"-"+Array[1]+"-"+Array[0] , so in this case the result would be 0-1-0
basically at each candle close i have a new X value so i need to get rid of the oldest position, move the other two one up and fill (last candle close) with the new X value.
How could I do this?
Thank you all for any kind of help, it would be highly appreciated..