Just get the highest value of that array range and verify that it is in fact at index [i] (use function ArrayMaximum).
For other situations, you can use a "for" loop to build up your boolean condition.
Just get the highest value of that array range and verify that it is in fact at index [i] (use function ArrayMaximum).
For other situations, you can use a "for" loop to build up your boolean condition.
Thanks Mr. Fernando , but what if the code is :
if(Close[i] > Close [1+i]
&& Close [i] > Close [2+i]
&& Close [i] > Close [3+i]
&& Close [i] > Close [4+i]
&& Close [i] > Close [5+i]
&& Close [i] > Close [6+i]
&& Close [i] > Close [7+i]
&& Close [i] > Close [8+i]
&& Close [i] > Close [9+i]
&& Close [i] > Close [10+i]
&& Close [i] > Close [11+i]
&& Close [i] > Close [12+i]
)
How can i use a "for" loop to build up my boolean condition?
As an example of an "and (&&)" loop, here is sample code (compiled but untested):
bool boolHighest = true; for( int j = i + 1; j <= i + 12; j++ ) boolHighest = boolHighest && ( Close[ i ] > Close[ j ] ); if( boolHighest ) { /* your code for the valid condition */ };
if(Close[i] > Close [1+i] && Close [i] > Close [2+i] && Close [i] > Close [3+i] && Close [i] > Close [4+i] && Close [i] > Close [5+i] && Close [i] > Close [6+i] && Close [i] > Close [7+i] && Close [i] > Close [8+i] && Close [i] > Close [9+i] && Close [i] > Close [10+i] && Close [i] > Close [11+i] && Close [i] > Close [12+i] )
How can i use a "for" loop to build up my boolean condition?
-
Please edit your two posts and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor -
MT5 has no predefined High[]/Close[]. Why did you post your MT4 question in the MT5 EA section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. The moderators will likely move this thread there soon. No loop is required for that. if(Close[i] > Close [ ArrayMaximum(Close, i+1, 12) ])
Or simplified. if(i == ArrayMaximum(Close, i, 13))
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I wonder if there is a function enable me to shorten this conditions:
if(High[i] > High[1+i]
&& High[i] > High[2+i]
&& High[i] > High[3+i]
&& High[i] > High[4+i]
&& High[i] > High[5+i]
&& High[i] > High[6+i]
&& High[i] > High[7+i]
&& High[i] > High[8+i]
&& High[i] > High[9+i]
&& High[i] > High[10+i]
&& High[i] > High[11+i]
&& High[i] > High[12+i]
)
To become for example:
if(High[i] > (High[1+i] : High[12+i] )
@William Roeder "Please say something useful or be silent" :)