Download MetaTrader 5

operator "If" ignores the second condition

To add comments, please log in or register
Glaramara LLC
283
Mikayil Mammadov  

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
2342
honest_knave  

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

Glaramara LLC
283
Mikayil Mammadov  

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
17063
whroeder1  
Spenta: Is it the quotes provider to blame?
  1. Did you download history from your broker?
Glaramara LLC
283
Mikayil Mammadov  
Yes, it's the broker to blame. The recent values are correct.
To add comments, please log in or register