Download MetaTrader 5

operator "If" ignores the second condition

To add comments, please log in or register
Spenta
76
Spenta 2017.04.20 15:11 

Hi there,

I'm new to mql. I've done my research but couldn't find the answer. My issue is that the second condition is ignored while the first is true. What can be wrong here?

if(Use_MACD_divergence) {  // Check MACD filter
           double OsMA_1 = iOsMA(NULL,Timeframe,Fast_ema_period,Slow_ema_period,Signal_period,Applied_price,i);
            if((macd<macd_0) && (OsMA_1<0))
honest_knave
Moderator
2422
honest_knave 2017.04.20 15:14  

To help your debugging, use Print() statements to show the values of OsMA_1 i.e.

if(Use_MACD_divergence) {  // Check MACD filter
           double OsMA_1 = iOsMA(NULL,Timeframe,Fast_ema_period,Slow_ema_period,Signal_period,Applied_price,i);
           Print(OsMA_1);
           if((macd<macd_0) && (OsMA_1<0))

You are looking for 2 things:

  • A value is printed when you expect it to be printed (and not printed when you expect it not to be printed)
  • The value itself makes sense

Spenta
76
Spenta 2017.04.20 15:57  

Tested with Print.

For an unknown reason, not all values are printed to the journal. Logs jump from September to January. During this period I have false values when the second condition is ignored. Is it the quotes provider to blame?

whroeder1
14756
whroeder1 2017.04.20 16:46  
Spenta: Is it the quotes provider to blame?
  1. Did you download history from your broker?
Spenta
76
Spenta 2017.04.20 16:52  
Yes, it's the broker to blame. The recent values are correct.
To add comments, please log in or register