PrintFormat No more than 2 decimal.

 

Hello,

PrintFormat No more than 2 decimal.

With this script :

//+------------------------------------------------------------------+
//|                                              TestPrintFormat.mq4 |
//|                                         Copyright 2014, Pierre8r |
//|                                              https://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Pierre8r"
#property link      "https://www.mql4.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   PrintFormat("Time:%s  Close:%f ",TimeToString(Time[0]),Close[0]);
  }
//+------------------------------------------------------------------+

I got this :

2014.04.29 15:31:27.493 TestPrintFormat GOLD,Weekly: Time:2014.04.27 00:00  Close:1298.050000 

How to have this ?

2014.04.29 15:31:27.493 TestPrintFormat GOLD,Weekly: Time:2014.04.27 00:00  Close:1298.05
 

Have you tried ..

 NormalizeDouble() 

?

 

In my case NormalizeDouble() seen to change nothing.

//+------------------------------------------------------------------+
//|                                              TestPrintFormat.mq4 |
//|                                         Copyright 2014, Pierre8r |
//|                                              https://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Pierre8r"
#property link      "https://www.mql4.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   PrintFormat("Time:%s  Close:%f ",TimeToString(Time[0]), NormalizeDouble(Close[0],2));
  }
//+------------------------------------------------------------------+

Give :

2014.04.29 15:53:41.868 TestPrintFormat GOLD,Weekly: Time:2014.04.27 00:00  Close:1298.050000 
 
Not PrintFormat, just Print
 
%.2f
 


Hi qjol,

Thanks.

Works.

//+------------------------------------------------------------------+
//|                                              TestPrintFormat.mq4 |
//|                                         Copyright 2014, Pierre8r |
//|                                              https://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Pierre8r"
#property link      "https://www.mql4.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   PrintFormat("Time:%s  Close:%.2f ",TimeToString(Time[0]),Close[0]);
  }
//+------------------------------------------------------------------+

2014.04.29 16:35:01.749 TestPrintFormat GOLD,Weekly: Time:2014.04.27 00:00  Close:1298.05 
Reason: