Download MetaTrader 5
To add comments, please log in or register
Find out the most discussed Forum topics. Have a look at the Wall section!
Pierre Rougier
386
Pierre Rougier 2014.03.22 21:56 

Hello,

How to remove the warnings ?

'Sample.mq4'    Sample.mq4      1       1
implicit conversion from 'number' to 'string'   Sample.mq4      48      22
implicit conversion from 'number' to 'string'   Sample.mq4      48      38
0 error(s), 2 warning(s)                1       3

//+------------------------------------------------------------------+
//|                                                       Sample.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
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int i,limit;
   ArraySetAsSeries(time,false);

   limit=prev_calculated-1;
   if(limit<0)
     {
      limit=0;
     }

//--- main loop
   for(i=limit; i<rates_total && !IsStopped(); i++)
     {
      Print("Time :"+time[i]+"   i:"+i);
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
Keith Watford
Moderator
8009
Keith Watford 2014.03.22 22:39  
Print("Time :"+(string) time[i]+"   i:"+ (string) i);
Alain Verleyen
Moderator
28672
Alain Verleyen 2014.03.22 23:19  
tintin92:

Hello,

How to remove the warnings ?

Yes, as GumRai wrote, to remove warnings about implicit conversion, you have to do an explicit conversion. An other way :

      printf("Time :%s   i:%i",TimeToString(time[i]),i);
Pierre Rougier
386
Pierre Rougier 2014.03.23 07:01  
Thanks all, I keep the answer from angevoyageur.
Keith Watford
Moderator
8009
Keith Watford 2014.03.23 08:00  
angevoyageur:

Yes, as GumRai wrote, to remove warnings about implicit conversion, you have to do an explicit conversion. An other way :



If it is not too complicated, can you explain what

%s i:%i

does?

Toast
220
Toast 2014.03.23 08:45  
Keith Watford
Moderator
8009
Keith Watford 2014.03.23 09:12  


Thanks for that :)

You really would think that by putting % in the reference index, that it would at least give a pointer to that :(

/
To add comments, please log in or register