max decimals for total lot size indicator code

 
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  double totalOpenLotsbuy = 0,
         totalOpenLotssell = 0;
  string pairname = Symbol();
  
    for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--)
    if (OrderSelect(iPos, SELECT_BY_POS)
       &&  OrderSymbol()       == pairname    )
       {
    if(OrderType() == OP_BUY)
      {
       totalOpenLotsbuy += OrderLots();
      }
    if(OrderType() == OP_SELL)
      {
       totalOpenLotssell += OrderLots();
      }
      }
    if(totalOpenLotsbuy>0 || totalOpenLotssell > 0)
      {
     Comment("BUY ",totalOpenLotsbuy,
             " SELL ",totalOpenLotssell);
      
      }
  }
//+------------------------------------------------------------------+

I used some code from mql5 and it's showing up with long decimals.

It's showing:

Buy 0.230000000000001 Sell 1.750000000000001

Is there a way to shorten the amount of decimals showing up?

 
martymcfry666 it's showing up with long decimals.

Floating-point has an infinite number of decimals, it's you, not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia

See also The == operand. - MQL4 programming forum (2013)

If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
          question about decima of marketinfo() - MQL4 programming forum (2016)

 
William Roeder #:

Floating-point has an infinite number of decimals, it's you, not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
          Double-precision floating-point format - Wikipedia

See also The == operand. - MQL4 programming forum (2013)

If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
          question about decima of marketinfo() - MQL4 programming forum (2016)

Thanks dude
 
     Comment("BUY ",DoubleToString(totalOpenLotsbuy,2),
             " SELL ",DoubleToString(totalOpenLotssell,2));
Reason: