anybody have some code to reformat dollars, like:
1234567.89 to 1,234,567.89
OR - is there a built in MT4 function, if so, I can not find it...
1234567.89 to 1,234,567.89
OR - is there a built in MT4 function, if so, I can not find it...
From 50 Dollars To 1 Million Dollars Trading Challenge 70 replies
I Will Learn Coding in 1 Month - Give me the 80/20 of MT4 Coding 14 replies
TP dollars amount and SL dollars amount columns (MT4) 0 replies
Auto Pivot Point in MetaTrader coding assist please 10 replies
Dollars, Dollars, Everywhere! 2 replies
//+------------------------------------------------------------------+
//| Test.mq4 |
//| Copyright © 2010, Kenny Hubbard |
//| [url]http://www.compu-forex.com[/url] |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Kenny Hubbard"
#property link "[url]http://www.compu-forex.com[/url]"
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
double
My_Money = 1234567890.89;
Print(Comma_Format(My_Money));
return(0);
}
//+------------------------------------------------------------------+
string Comma_Format(double l_My_Money)
{
string
sMy_Money = DoubleToStr(l_My_Money,2),
My_New_Money,
Get_3,
sOrphans;
double
Get_Groups = MathFloor(StringLen(sMy_Money)/3);
int
Orphans = StringLen(sMy_Money)-3*Get_Groups;
for(int i=StringLen(sMy_Money)-Orphans;i>0;i=i-3){
Get_3 = StringSubstr(sMy_Money,Orphans+i-3,3);
if(i==StringLen(sMy_Money)-Orphans)My_New_Money = Get_3;
else{
if(StringSubstr(My_New_Money,0,1)==".")My_New_Money = StringConcatenate(Get_3, My_New_Money);
else My_New_Money = StringConcatenate(Get_3,",", My_New_Money);
}
}
if(Orphans==0)return(My_New_Money);
sOrphans = StringSubstr(sMy_Money,0,Orphans);
if(StringLen(sMy_Money)>5)My_New_Money = StringConcatenate(sOrphans,",",My_New_Money);
else My_New_Money = StringConcatenate(sOrphans,My_New_Money);
return(My_New_Money);
}
string CSdouble(double Din) { string orgs,ress; int spos; orgs = DoubleToStr(Din,2); spos = StringLen(orgs)-1; ress = StringSubstr(orgs,spos-2,3); spos -= 3; while (spos >= 0) { if (spos >=2) { ress = ","+StringSubstr(orgs,spos-2,3)+ress; spos -=3; if (spos < 0) ress = StringSubstr(ress,1,StringLen(ress)); } else { ress = StringSubstr(orgs,0,spos+1)+ress; spos = -1; } } return(ress); }