trailingstop

Back to topics list To post a new topic, please log in or register
avatar
41
KeepMarcos 2016.02.28 23:24
 

Heey gus!!!

Please, help me!!

Why my code does not work to change the stoploss?

Thhank you very much! 

double MyPoint=Point;

  if(Digits==3 || Digits==5) MyPoint=Point*10;

 if(Ask > NormalizeDouble(OrderOpenPrice()+StopLoss*MyPoint,Digits)) stnew = NormalizeDouble(OrderOpenPrice()+TrailingStop*MyPoint,Digits);

          int MyOrderSelect=OrderSelect(result,SELECT_BY_TICKET);

            int MyOrderModify=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(stnew,Digits),0,0,Green);
avatar
49
maleas_k 2016.02.29 00:41 #
 
KeepMarcos:

Heey gus!!!

Please, help me!!

Why my code does not work to change the stoploss?

Thhank you very much! 

Are you sure that you are storing the ticket in the result var?

OrderSelect(result,SELECT_BY_TICKET)

If yes, you need to check if the OrderSelect() is true. Like

if(OrderSelect(results,SELECT_BY_TICKET) == TRUE)

and many others but.... start with those first.


avatar
Moderator
3427
GumRai 2016.02.29 00:45 #
 

You need to select the order before using OrdeOpenPrice()

You don't check that it is a buy order

Your TS calculation is not a TS, the SL will only be modified once.

You don't check whether the SL has already been modified.

avatar
41
KeepMarcos 2016.02.29 21:52 #
 

problem resolved.

thanks!!

 

 

avatar
41
KeepMarcos 2016.02.29 21:53 #
 
int cnt, total=OrdersTotal();
   for(cnt=0;cnt<total;cnt++)
   {
      OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
      {
         if(OrderType()==OP_BUY)
         {
            double stnewprice = OrderOpenPrice();
            SLbuy = stnewprice+AutoStop*MyPoint;
            
            if(Ask>SLbuy)   OrderModify(OrderTicket(),OrderOpenPrice(),SLbuy,OrderTakeProfit(),0,Blue);
            
             
         }
=]
Back to topics list  

To add comments, please log in or register