String Split
Good day,
May i just enquire if i have a string sent via Pipeline where said string goes as ""EURUSD",OP_Buy,0.1,Ask,2,0,0"
How can i split it into using String Split
Symbol="EURUSD"
cmd=OP_Buy
volume=0.1
so on so forth using the following codes
- www.mql5.com
Hi Heijden,
Many thanks for the prompt reply.
Have a great day.
Regards,
JD
StringSubstr will not help you
for example
if your broker price 4 digit and your StringSubstr function calculate depended on 5 digit price
maybe your symbols have prefix like eurusd.m
it will not help you in this case so you must use your code
void OnStart() { string to_split="EURUSD,OP_BUY,0.1,1.12309,3,1.12109,1.12409,mycomment"; string sep=","; ushort u_sep; string result[]; u_sep=StringGetCharacter(sep,0); int k=StringSplit(to_split,u_sep,result); string symbol=result[0]; int cmd=ordertype(result[1]); double Volume=StrToDouble(result[2]); double Price=StrToDouble(result[3]); int Slippage=StrToInteger(result[4]); double StopLoss=StrToDouble(result[5]); double TakeProfit=StrToDouble(result[6]); string Comment=result[7]; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int ordertype(string value) { if(value=="OP_BUY")return(0); if(value=="OP_SELL")return(1); return(-1); }
so in your case the code will be like this
Good day Omar,
Many thanks for the enlightenment.
Its really of great help.
Sincerely,
JD
Good day,
May i just enquire if i have a string sent via Pipeline where said string goes as ""EURUSD",OP_Buy,0.1,Ask,2,0,0"
How can i split it into using String Split
Symbol="EURUSD"
cmd=OP_Buy
volume=0.1
so on so forth using the following codes