mtsTrader:
Hello all,
weeks ago I had a C-programming training. Now I will start to learn MQL5. I read some tutorials but I don`t know how I can get the maximum and minimum of bars to copy them into an own array.
Concretely I would like to create an array (e.g. double array_maximum[20]) and safe the maxima of the last 20 bars in that array.
Can someone please tell me which function I need to get the maxima of the last bars?
Welcome to mql5.com forum,
The maxima of a bar is high price, so for the maxima of the last 20 bars :
double maxima[]; CopyHigh(_Symbol,PERIOD_CURRENT,1,20,maxima);
Is it what you asked for ?
Thank you for promp reply. Thats exactly what I asked for!
Thank you!
mtsTrader:
Thank you for promp reply. Thats exactly what I asked for!
Thank you!
//+---------------------------------RETORNA EL MAYOR VALOR DE nBARRAS----------------------+ double iHighest(string simb, ENUM_TIMEFRAMES marcoTmp, int modo, int nBars, int nVela= 0) { double resp= 0, arPrecios[]; ulong arVolum[]; int posicion=0, nCopiado= 0; ArrayResize(arPrecios, nBars); ArrayResize(arVolum, nBars); ArraySetAsSeries(arPrecios, true); ArraySetAsSeries(arVolum, true); switch(modo) { case 0 : nCopiado= CopyOpen(simb,marcoTmp,nVela,nBars,arPrecios); break; case 1 : nCopiado= CopyClose(simb,marcoTmp,nVela,nBars,arPrecios); break; case 2 : nCopiado= CopyHigh(simb,marcoTmp,nVela,nBars,arPrecios); break; case 3 : nCopiado= CopyLow(simb,marcoTmp,nVela,nBars,arPrecios); break; case 4 : nCopiado= CopyTickVolume(simb,marcoTmp,nVela,nBars,arVolum); break; case 5 : nCopiado= CopyRealVolume(simb,marcoTmp,nVela,nBars,arVolum); break; } if(nCopiado==nBars) { if(modo<4) { posicion= ArrayMaximum(arPrecios,0,WHOLE_ARRAY); resp= arPrecios[posicion]; } else { posicion= ArrayMaximum(arVolum,0,WHOLE_ARRAY); resp= arVolum[posicion]; } } return(resp); }
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello all,
weeks ago I had a C-programming training. Now I will start to learn MQL5. I read some tutorials but I don`t know how I can get the maximum and minimum of bars to copy them into an own array.
Concretely I would like to create an array (e.g. double array_maximum[20]) and safe the maxima of the last 20 bars in that array.
Can someone please tell me which function I need to get the maxima of the last bars?