Download MetaTrader 5

Decimal Problem

To add comments, please log in or register
Barno_07
41
Barno_07  
I am a beginner learning to code an EA. well in my EA i m calculating a percentage of range of a candle in Hourly candles. But in calculation 1 extra decimal place arriving such as in WTI.oil my BSO is 49.64 but it is coming 49.645. How can i code to ignore the last decimal place and take 2 places after decimal.. Please help me..
void openbuystop()
{
  int a= ((High[1]-Low[1])*6*10/100);
  double t = (a*2);
   if (OrderSend(Symbol(),OP_BUYSTOP,lot,a+High[1],3,High[1],a+High[1]+t,NULL,magic,0,NULL)== true)
   {
      Alert("Order Sent");
   }
   else
   fun_err(GetLastError());
}         
whroeder1
16105
whroeder1  
Barno_07: How can i code to ignore the last decimal place and take 2 places after decimal..
Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
To add comments, please log in or register