Download MetaTrader 5
To add comments, please log in or register
Launch your trading signal and add account monitoring!
Opengates
165
Opengates 2015.06.09 03:22 

Hello Gurus in the house,

I am trying to convert date and time string to function as date and time real time in my ea but keeps giving error 'StrToDate' - wrong parameter count", below are the codes:


extern string        NewsDate         = "09/06/2015"; // Year for the News to be released
extern string        NewsTime         = "12:30";   // Time for the News to be released

string  StrToDate();

 //variables defined
string   DateTime=StringConcatenate(NewsDate," ",NewsTime);
datetime Startdate=StrToDate(DateTime, "dd/mm/yyyy hh:mi"); 

if(TimeCurrent()==Startdate) {
//perform certain tasks
} 


pls check and let me know where I got it wrong.

Thanks in advance

Keith Watford
Moderator
7906
Keith Watford 2015.06.09 03:33  

You haven't written the function StrToDate()

Maybe you could use StrToTime(), but that uses   "yyyy.mm.dd hh:mi " format

Opengates
165
Opengates 2015.06.09 03:55  
GumRai:

You haven't written the function StrToDate()

Maybe you could use StrToTime(), but that uses   "yyyy.mm.dd hh:mi " format

Thanks GumRai, I changed to StrToTime() but it says "no one of the overloads can be applied to the function call", pls what do you think that can mean and what do I do OR how do I write the function StrToDate() to produce the right result? Thanks
Keith Watford
Moderator
7906
Keith Watford 2015.06.09 05:03  
Opengates:
Thanks GumRai, I changed to StrToTime() but it says "no one of theoverloads can be applied to the function call", pls what do you thinkthat can mean and what do I do OR how do I write the function StrToDate() to produce the right result? Thanks

StrToTime() only uses 1 parameter, if you are using more than 1, you are overloading the function

  extern string        NewsDate         = "2015.06.09"; // Date for the News to be released
  extern string        NewsTime         = "12:30";   // Time for the News to be released

//In your main code

  string   DateTime=StringConcatenate(NewsDate," ",NewsTime);
  datetime Startdate=StrToTime(DateTime);


  if(TimeCurrent()==Startdate)    //Be careful of using == in case of missed ticks
    {
    //perform certain tasks
    }

Change the format for entering the date as above.

Avoid using DateTime to name a string variable, it can be confusing 

Opengates
165
Opengates 2015.06.09 09:32  
GumRai:

StrToTime() only uses 1 parameter, if you are using more than 1, you are overloading the function

Change the format for entering the date as above.

Avoid using DateTime to name a string variable, it can be confusing 

 

Thanks so much, just as you corrected me, it works fine. You are blessed
whroeder1
13610
whroeder1 2015.06.09 13:22  
/
To add comments, please log in or register