operator "If" ignores the second condition

 

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))
 

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

 

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?

 
Spenta: Is it the quotes provider to blame?
  1. Did you download history from your broker?
 
Yes, it's the broker to blame. The recent values are correct.
Reason: