Download MetaTrader 5
To add comments, please log in or register
Interested in the Market activity? Come and track!
musetti
51
musetti 2015.02.26 19:50 

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
7979
Keith Watford 2015.02.26 22:08  
It is poorly written code and the logic fails
musetti
51
musetti 2015.02.28 19:19  
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