Hi to all! I have a simple question. I need in my ea to enter buy, for example, if ALL the last 3 candles are Above a moving average.
Example:
If ((Close[1]&&Close[2]&&Close[3])>ima(......))
Is there another method instead of out all this close&&..?
Like Close[1+2+3]?
Manu Hanks to you
- How to copy deals of successful traders in MetaTrader 5
- Flexible MetaTrader 5 trading system with all order types
- Download the MetaTrader 5 mobile app for Android
-
If ((Close[1]&&Close[2]&&Close[3])>ima(......))
Bogus. True = non-zero and false = zero so you get true && true && Close[3]>ima
if( 3 < 2 < 1 ) if( false < 1 ) if( 0 < 1 ) if( true )
if( 3 > 2 > 1 ) if( true > 1 ) if( 1 > 1 ) if( false )
- Like Close[1+2+3]?Equivalent to Close[6]
- There are no short cuts. Try one of these:
if (Close[1])>iMA(…) && Close[2])>iMA(…) && Close[3])>ima(…)) …
double ma=iMA(…); if (Close[1])>ma && Close[2])>ma && Close[3])>ma) …
template<typename T> T MathMax(T a, T b, T c){ return MathMax(a, MathMax(b, c)); } ⋮ if (MathMAx(Close[1], Close[2], Close[3]) > iMA(…)) …
William Roeder:
-
Bogus. True = non-zero and false = zero so you get true && true && Close[3]>ima
- Equivalent to Close[6]
- There are no short cuts. Try one of these:
3. This won't catch it. Actually you need:
template<typename T> T MathMin(T a, T b, T c){ return MathMin(a, MathMin(b, c)); } ⋮ if (MathMin(Close[1], Close[2], Close[3]) > iMA(…)) …
correct

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