Hello everybody,
I have an EA code with three "blocks" for the order "buy". Only the text changes ("buy now", "buynow", "buy.now"). I want to reduce the EA code, only make one out of three blocks. Can I put the blocks in a block?
//-- buy now
k = StringFind(text, " buy now " );
if (k > 0)
{
Done = false;
Trade_Type[NumOfTrades] = OP_BUY;
pos = k + StringLen(" buy now ");
pos2 = StringFind(text, " ", pos);
len = pos2-pos;
Trade_Price[NumOfTrades] = (double) StringSubstr(text, pos, len);
NumOfTrades++;
StringReplace(text, " buy now " , "");
}
k = StringFind(text, "buynow ");
if (k > 0)
{
Done = false;
Trade_Type[NumOfTrades] = OP_BUY;
pos = k + StringLen( "buynow " );
pos2 = StringFind(text, " ", pos);
len = pos2-pos;
Trade_Price[NumOfTrades] = (double) StringSubstr(text, pos, len);
NumOfTrades++;
StringReplace(text, " buynow " , "");
}
k = StringFind(text, " buy.now ");
if (k > 0)
{
Done = false;
Trade_Type[NumOfTrades] = OP_BUY;
pos = k + StringLen(" buy.now ");
pos2 = StringFind(text, " ", pos);
len = pos2-pos;
Trade_Price[NumOfTrades] = (double) StringSubstr(text, pos, len);
NumOfTrades++;
StringReplace(text, " buy.now " , "");
}
I have an EA code with three "blocks" for the order "buy". Only the text changes ("buy now", "buynow", "buy.now"). I want to reduce the EA code, only make one out of three blocks. Can I put the blocks in a block?
//-- buy now
k = StringFind(text, " buy now " );
if (k > 0)
{
Done = false;
Trade_Type[NumOfTrades] = OP_BUY;
pos = k + StringLen(" buy now ");
pos2 = StringFind(text, " ", pos);
len = pos2-pos;
Trade_Price[NumOfTrades] = (double) StringSubstr(text, pos, len);
NumOfTrades++;
StringReplace(text, " buy now " , "");
}
k = StringFind(text, "buynow ");
if (k > 0)
{
Done = false;
Trade_Type[NumOfTrades] = OP_BUY;
pos = k + StringLen( "buynow " );
pos2 = StringFind(text, " ", pos);
len = pos2-pos;
Trade_Price[NumOfTrades] = (double) StringSubstr(text, pos, len);
NumOfTrades++;
StringReplace(text, " buynow " , "");
}
k = StringFind(text, " buy.now ");
if (k > 0)
{
Done = false;
Trade_Type[NumOfTrades] = OP_BUY;
pos = k + StringLen(" buy.now ");
pos2 = StringFind(text, " ", pos);
len = pos2-pos;
Trade_Price[NumOfTrades] = (double) StringSubstr(text, pos, len);
NumOfTrades++;
StringReplace(text, " buy.now " , "");
}