Download MetaTrader 5
To add comments, please log in or register
Have you developed an application? Publish it in Code Base!
Pierre Rougier
386
Pierre Rougier 2014.04.29 13:37 

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
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.29 13:46  

Have you tried ..

 NormalizeDouble() 

?

Pierre Rougier
386
Pierre Rougier 2014.04.29 13:54  

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 
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.29 14:00  
Not PrintFormat, just Print
qjol
3243
qjol 2014.04.29 14:13  
%.2f
Pierre Rougier
386
Pierre Rougier 2014.04.29 14:45  


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 
/
To add comments, please log in or register