double high = 0, low = 0; ^
You need a semicolon after the low declaration. You can double click the error messages and the editor will point the line with the error.
Oh I see. I'm an idiot.
Now it compiles, however it is not sending any information to the terminal.
The print/comment/alert functions do not work until I take out the rest of the code.
Is there something else I'm doing wrong?
void OnStart() { //--- MqlRates rates[]; ArraySetAsSeries (rates, true); int PriceDataPoints = CopyRates (_Symbol, 0, 0, 100, rates); double high = 0, low = 0; for (int x = 0; x <= 100; x++) {if (x > 0 && rates[x].high > rates[x-1].high) {high = rates[x].high; } } Alert ((string) NormalizeDouble (high, _Digits)); Alert ("hi"); //Print ((string) NormalizeDouble (low, _Digits)); }
Oh I see. I'm an idiot.
Now it compiles, however it is not sending any information to the terminal.
The print/comment/alert functions do not work until I take out the rest of the code.
Is there something else I'm doing wrong?
Use ArraxMax
void OnStart() { //--- MqlRates rates[100]; ArraySetAsSeries(rates, true); int PriceDataPoints = CopyRates(_Symbol, 0, 0, 100, rates); double high = 0, low = 0; for(int x = 0; x < 100; x++) { if(high == 0 || rates[x].high > high ) { high = rates[x].high; } } Alert((string) NormalizeDouble(high, _Digits)); Alert("hi"); //Print ((string) NormalizeDouble (low, _Digits)); }
iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, 100, 0));
combination of: https://docs.mql4.com/series/ihighest and https://docs.mql4.com/series/ihigh
![iHighest - Timeseries and Indicators Access - MQL4 Reference iHighest - Timeseries and Indicators Access - MQL4 Reference](https://c.mql5.com/36/49/ihighest-timeseries-and-indicators.png)
- docs.mql4.com
Interesting, yours prints properly but mine doesn't. Why is this?
Interesting, yours prints properly but mine doesn't. Why is this?
cause it is not same.
cause it is not same.
Mine should still print.....
![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
Hello,
I'm currently trying to write a script that prints the maximum price within the last 100 days.
I know that ArrayMaximum exists but I want to avoid using it for now.
There is some error in the code that I cannot find.
Currently I am only getting a " 'for' - semicolon expected " error on
I am also not sure if
rates[x-1]
is a proper way to indicate the previous index value, if it is not I would appreciate guidance on the correct way to do it, however that is not what is preventing it from compiling.
If you could inform me of my mistakes I would appreciate it :)