Download MetaTrader 5

How to program that a stop or takeprofit is not close to a round number?

To add comments, please log in or register
Publish your articles and improve your rating!
patagonia2015
15
patagonia2015 2015.10.13 22:31 

Hello guys, just as the subject. I have an EA and is not doing well in round numers (for example 1.1400 in EURUSD or 136.00 in EURJPY, etc). How can I define that when it´s close to a round number (for example 15 pips of that number) doesn't take the trade?.

 Thanks in advance. 

Keith Watford
Moderator
9625
Keith Watford 2015.10.14 00:07  
  int distance=15;
  int multiplier=1;
  double pip_decimal=Point;
  if(Digits==3)
     {
     pip_decimal=Point*10;
     }
  if(Digits==5)
     {
     multiplier=100;
     pip_decimal=Point*10;
     }
  double round_number=MathRound(Bid*multiplier)/multiplier;
  if(MathAbs(round_number-Bid)>distance*pip_decimal)
     {
     //Do something
     }
  
  Print(DoubleToString(round_number,Digits));

 

 I don't know if this is the best way to do it, but it should work

To add comments, please log in or register