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

Back to topics list To post a new topic, please log in or register
avatar
3
patagonia2015 2015.10.14 00: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. 

avatar
Moderator
3427
GumRai 2015.10.14 02: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

Back to topics list  

To add comments, please log in or register