Download MetaTrader 5

question on a code line

To add comments, please log in or register
musetti
51
musetti  

Hello, I see a trailing stop code on internet wich is activate after cross up breakeven, but i don't understand a line

int trailing_stop = 20;
double ts;

for (int i = OrdersTotal()-1; i >= 0; i --)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol())
{
if (OrderType() == OP_BUY)
{
ts = Bid-(Point*trailing_stop);
if (OrderStopLoss()=(Point*trailing_stop)) // why oderstoploss have to be = Point*trailing stop ??? if orderstoploss return 11200, 20*Point can never be equal with value of Orderstoploss 
OrderModify(OrderTicket(),OrderOpenPrice(),ts,OrderTakeProfit(),0,White);
}
Keith Watford
Moderator
10612
Keith Watford  
It is poorly written code and the logic fails
musetti
51
musetti  
lol :D, it's the reason why I try to learn programmation. I just searched a model but on youtube there is a good indian programmer who explain how to code a perfect trailing stop with creation of functions etc...it's more professional
To add comments, please log in or register