Created
August 9, 2013 12:51
-
-
Save currencysecrets/6193393 to your computer and use it in GitHub Desktop.
Simple MQL4 Utility Functions. Converting datetime to string. Converting double to a specific number of decimal places. Converting price to string.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @double price to convert to string | |
* @int number of decimal places to show (default = Digits of active currency) | |
*/ | |
string D( double price, int num = -1 ) { | |
if ( num == -1 ) { num = Digits; } | |
return( DoubleToStr( price, num ) ); | |
} | |
/** | |
* @double price to clip | |
* @int number of decimal places to show (default = Digits of active currency) | |
*/ | |
double N( double price, int num = -1 ) { | |
if ( num == -1 ) { num = Digits; } | |
return( NormalizeDouble( price, num ) ); | |
} | |
/** | |
* @datetime datetime to convert to string | |
* @int format of datetime (default = TIME_DATE|TIME_MINUTES|TIME_SECONDS; 0 = TIME_DATE; else = TIME_DATE|TIME_MINUTES) | |
*/ | |
string T( datetime d, int type = 1 ) { | |
if ( type == 1 ) { | |
return( TimeToStr( d, TIME_DATE|TIME_MINUTES|TIME_SECONDS ) ); | |
} else if ( type == 0 ) { | |
return( TimeToStr( d, TIME_DATE ) ); | |
} else { | |
return( TimeToStr( d, TIME_DATE|TIME_MINUTES ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment