Forex Forum - EarnForex
Serving Traders Since 2005
 

Go Back   Forex Forum - EarnForex > MetaTrader > MetaTrader 5

MetaTrader 5 MT5 is already out of its beta stage, but the development is ongoing. Some brokers already offer real accounts and the interest of traders is growing. You can discuss anything related to MetaTrader 5 in this forum.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 25th October 2011, 22:31
Default Avatar
Senior Member
 
Join Date: Aug 2011
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default TimeToString(_Period)

Hi

How can I get this to work?

thx

MQL5 Code:
if(TimeToString(_Period) == "H4")

it does not evaluate.
Reply With Quote
  #2 (permalink)  
Old 26th October 2011, 10:34
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,548
Thanks: 18
Thanked 20 Times in 16 Posts
Default

And it won't. Use this instead:

MQL5 Code:
if (_Period == PERIOD_H4)
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #3 (permalink)  
Old 26th October 2011, 16:02
Default Avatar
Senior Member
 
Join Date: Aug 2011
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default

how do I get
MQL5 Code:
FileWrite(filehandle, _Period)
to output PERIOD_H4 instead of 16408
Reply With Quote
  #4 (permalink)  
Old 26th October 2011, 16:35
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,548
Thanks: 18
Thanked 20 Times in 16 Posts
Default

Something like this:

MQL5 Code:
string P;
if (_Period == PERIOD_H4) P = "PERIOD_H4";
...
FileWrite(filehandle, P);

Of course, it's better to write a function PeriodToString(ENUM_TIMEFRAMES).
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #5 (permalink)  
Old 26th October 2011, 17:03
Default Avatar
Senior Member
 
Join Date: Aug 2011
Posts: 115
Thanks: 0
Thanked 0 Times in 0 Posts
Default

how about this?

MQL5 Code:
string PeriodToString(ENUM_TIMEFRAMES et)
{
string p;
switch(et)
  {
   case 1: P=PERIOD_M1; break;
   default: p=_Period; break;
  }
return (p);
}
Reply With Quote
  #6 (permalink)  
Old 26th October 2011, 19:03
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,548
Thanks: 18
Thanked 20 Times in 16 Posts
Default

It will return timeframes, not strings.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:34.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Inactive Reminders By Icora Web Design

SEO by vBSEO 3.3.2