Please help with my EA, I would like to buy on the EURUSD & sell on USDJPY (same time) .The problems I encounter are when I place my EA on EURUSD (buy) & sell on the USDJPY (2 or 3 digits) my stop losses & take profits are TOO close to price. On 5 digit (USDCHF & USDCAD) pairs everything works fine. Please if you know the problem.
I just glanced at this and as I don't use MQL4, may not be correct, but I see you are storing Digit as a double prior to comparing.
double Digit=MarketInfo(Symbol(),MODE_DIGITS); if(Digit==1||Digit==2||Digit==3)
Doubles can often be subtly different so these comparisons can fail unexpectedly, unless you are precise about the same number of decimal places on both sides - I suggest casting Digit to int to make this comparison more reliable.
Also do you need this if/else if logic? It looks like you do the same calculation in both casesif(Digit==1||Digit==2||Digit==3){PipPoint=Point*10;} else if(Digit==4||Digit==5){PipPoint=Point*10;}
I just glanced at this and as I don't use MQL4, may not be correct, but I see you are storing Digit as a double prior to comparing.
Doubles can often be subtly different so these comparisons can fail unexpectedly, unless you are precise about the same number of decimal places on both sides - I suggest casting Digit to int to make this comparison more reliable.
Also do you need this if/else if logic? It looks like you do the same calculation in both casesI made the changes but still encounter the same problem with 2 and 3 digits pairs.
double Pips() { double PipPoint=0; int Digit=(int)MarketInfo(Symbol(),MODE_DIGITS); if(Digit==1||Digit==2||Digit==3){PipPoint=Point*10;} if(Digit==4||Digit==5){PipPoint=Point*10;} return(PipPoint); }
I tried simulating but as I use MQL5 can't debug this - can you print out the return values of
MarketInfo(Symbol(),MODE_DIGITS);
If we see what they are, in both cases of when the logic succeeds and fails, if could help me understand the issue better
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Please help with my EA, I would like to buy on the EURUSD & sell on USDJPY (same time) .The problems I encounter are when I place my EA on EURUSD (buy) & sell on the USDJPY (2 or 3 digits) my stop losses & take profits are TOO close to price. On 5 digit (USDCHF & USDCAD) pairs everything works fine. Please if you know the problem.