Problem in trailingstop (Slow and does not always work)

 

  Trailingstop Slow and does not always work See the example in the picture



 

 

 

extern int TrailingStop=10;
extern bool trailing = true;

//----------------------------------------
trailingstp();


void trailingstp()
{

if(trailing==true){
   TrailingPositionsBuy(TrailingStop);
   TrailingPositionsSell(TrailingStop);
   
}
}

//________________________________________________________________________________________________________________________//
void TrailingPositionsBuy(int trailingStop) {
   for (int z=0; z<OrdersTotal(); z++)
   {
      if (OrderSelect(z,SELECT_BY_POS,MODE_TRADES))
      {
         if (OrderSymbol()==Symbol())
         {
             if (OrderType()==OP_BUY && OrderMagicNumber()==magic)
             {
               if (Bid-OrderOpenPrice()>trailingStop*Point)
               {
                  if (OrderStopLoss() < Bid-trailingStop*Point)
                  ModifyStopLoss(Bid-trailingStop*Point);
               }
         }
       }
    }
  }
  
}
                

//________________________________________________________________________________________________________________________//
void TrailingPositionsSell(int trailingStop) {
   for (int w=0; w<OrdersTotal();w++)
   {
      if (OrderSelect(w,SELECT_BY_POS,MODE_TRADES))
      {
         if (OrderSymbol()==Symbol())
         {
             if (OrderType()==OP_SELL&&OrderMagicNumber()==magic) {
             if (OrderOpenPrice()-Ask>trailingStop*Point) {
                if (OrderStopLoss()>Ask+trailingStop*Point || OrderStopLoss()==0)
                     ModifyStopLoss(Ask+trailingStop*Point);
                     
               }
         }
       }
    }
  }
  
}
     
                          
//________________________________________________________________________________________________________________________//
void ModifyStopLoss (double ldStopLoss) {
 bool fm;
 fm = OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
}

  

That there was not something wrong Is there a way to make it faster

because I will use in scalping 

 

Try to use higher TrStop value. It could be too small to use only 10 points because normally your broker will not allow to use such to low value.

Ask broker for minimum Stoplevel or you could try it by yourself. 

If you want to use lower than broker values, then you need to use an other EA to follow up all open trades by using hidden SL, TP and TrStop as well like the attached one.

 
Osama Shaban:

Try to use higher TrStop value. It could be too small to use only 10 points because normally your broker will not allow to use such to low value.

Ask broker for minimum Stoplevel or you could try it by yourself. 

If you want to use lower than broker values, then you need to use an other EA to follow up all open trades by using hidden SL, TP and TrStop as well like the attached one.

 

 Thanks very much :D 

I want to ask just what is the difference between TrailingStop and TrailingStep 

Reason: