Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1497
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
Good day all!
Question about for() statement in mql4. The loop header contains a sequential decrease or increase of some variable value
for(int A=14; A>=0;A--) or for(int A=0; A<14;A++) or for(int A=0; A<14;A=+2) The sizes of A variable increase , or decrease are assumed to be always the same in the given examples 1 or 2.
QUESTION: If A variable is a timeframe value (1 (minute),5,15,30,60,240,1440), it is obvious that the sizes of increasing or decreasing this variable cannot be equal. In this case, how to format the for header so that variable A starts with 1 and then is incremented at each iteration by the required number of minutes, non-uniformly.
The example with variable A is a special case. In general, how do I format a loop if the change in the variable in the loop header should be done non-uniformly at the desired intervals.
Or is there some other operator to be used for these cases? But as it seems to me other operators are very bulky in comparison with for. Please help me to solve my problem exactly with the help of for statement , and exactly with its header. Because to solve my problem inside of the body of for statement , of course, you can use if statements, but it will be very cumbersome andfor statementwill have to do 1440 iterations for the sake of filtering 7 correct values.
Thank you.
There is an error here. It should be for(int A=0; A<14;A+=2)
The easiest thing I can think of is to put the periods into the array
The simplest thing that comes to mind is to score the periods in an array
Thanks, I could use it too)
There is an error here. It should be for(int A=0; A<14;A+=2)
The easiest thing I can think of is to store the periods in an array
Thanks a lot for the tip. It turned out to be much simpler than I thought.
I don't understand only one thing. The name of the array is per. And ENUM_TIMEFRAMES is an identifier of a variable type? I haven't found such an identifier in mql4 Reference. There are only
Thank you very much for the tip. It turned out to be a lot easier than I thought.
Only one thing I didn't understand. The name of the array per. And ENUM_TIMEFRAMES is an identifier of the variable type? I haven't found such an identifier in mql4 Reference. There are only
here
here
Did I understand correctly that you sent me information about mql 5 ? Or does this information also apply to mql 4 ?
Did I understand correctly that you sent me information about mql 5? Or does this information also apply to mql 4 ?
I've corrected it.
Thank you.
Thank you.
A small recommendation: Get used to ENUM_TIMEFRAMES immediately and forget about numerical representation as number of minutes.
Firstly PERIOD_W1 is more informative than 10080, it's clearer that it is a week.
Secondly, in mql5 the period doesn't correspond to the number of minutes and it won't be an unnecessary problem during migration to mql5, and it's inevitable.
Well, if you really need the number of minutes in a period, then you can