• Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)

reduce EA Code

momo2077

New Member
Credits
0
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 " , "");
}
 
Back
Top