Solve Stoploss Slippage - page 4

 
Let's make an example, maybe you can finally understand it correctly.

You opened a SELL trade at 27171.05, with SL at 23718.05.
Ask price (where your SELL SL will be triggered is now for example at 23711.50.
Market moves for some seconds, reaching price 23718.00, lower than your SL => SL not triggered yet.
On the very next tick, Ask price reached price 23719.55, higher than your SL => SL triggered.

It happened in 1 single tick. The difference of that Ask price of that tick was of 150 points. (Very common, considering that DE40 can move at minimum 50 points on each tick, but often 100-150-200 or even more).

Your SELL trade got closed on 23719.55 (the first valid price >= of your SL price).
Your total slippage was 23719.55 - 23718.05 = 150 points.

You lost, due to slippage, 0.015 EUR. (0.01 lots)
 
Scalper8 #:

I've added this function on my pending orders assuming it would solve my problems but no, price does not close at my stop loss.

 

Please help if you know the problem

do a search of this website, there will be several threads discussing pending orders, and also the use of freeze level. I think that you will find that freeze level only applies to the opening price of a pending order.

i would also print the freezelevel and such info to journal when you create the pending order, so you can check if it is working as you want. including the trail stop step also. You may find that it is not working as you plan it to.
 
Scalper8 #:
double StopLevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
double FreezeLevel=MarketInfo(Symbol(),MODE_FREEZELEVEL); 
double TickSize=MarketInfo(Symbol(),MODE_TICKSIZE);

  MagicNumber=(int)TimeCurrent();

Those are not assignments; they are initialization of a common (globally declared), or static variable(s) with a constant. They work exactly the same way in MT4/MT5/C/C++.

  1. They are initialized once on program load.

  2. They don't update unless you assign to them.

  3. In C/C++ you can only initialize them with constants, and they default to zero. In MTx you should only initialize them with constants. There is no default in MT5, or MT4 with strict (which you should always use).

    MT4/MT5 actually compiles with non-constants, but the order that they are initialized is unspecified and don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), as there may be no connection/chart yet:

    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

  4. Unlike indicators, EAs are not reloaded on chart change, so you must reinitialize them, if necessary.
              external static variable - MQL4 programming forum #2 (2013)

 
Michael Charles Schefe #:

do a search of this website, there will be several threads discussing pending orders, and also the use of freeze level. I think that you will find that freeze level only applies to the opening price of a pending order.

i would also print the freezelevel and such info to journal when you create the pending order, so you can check if it is working as you want. including the trail stop step also. You may find that it is not working as you plan it to.

I've done some research over the past few days & the only close solution I came across the information below and It still does not work. 

if(OrdersTotal()==0)
  {
    if(PendingPrice-SLBuy<StopLevel*Pips()){SLBuy=NormalizeDouble(PendingPrice-StopLevel*Pips(),Digits());}
    if(MathAbs(PendingPrice-SLBuy)<=FreezeLevel*Pips()){return;}
    {
     if(PSAR<Bid)
     {
      int BuyStop=OrderSend(Symbol(),OP_BUYSTOP,1.00,PendingPrice,0,SLBuy,0,"TestSL",MagicNumber,Expire,clrBlue);
    }
  }
}
if(OrdersTotal()==0)
  {
    if(SLSell-PendingPrice<StopLevel*Pips()){SLSell=NormalizeDouble(PendingPrice+StopLevel*Pips(),Digits());}
    if(MathAbs(SLSell-PendingPrice)<=FreezeLevel*Pips()){return;}
    {
     if(PSAR>Ask)
     {
      int SellStop=OrderSend(Symbol(),OP_SELLSTOP,1.00,PendingPrice,0,SLSell,0,"TestSL",MagicNumber,Expire,clrRed);
     }
    }
   }
 
Scalper8 #:

I've done some research over the past few days & the only close solution I came across the information below and It still does not work. 

I've read this thread, and I think that the concept that you're missing is:

Michael Charles Schefe #:
[F]reeze level only applies to the opening price of a pending order (emphasis added).

It seems that you're trying to use stop level and freeze level to solve an execution price issue occurring upon automatic conversion of your stop order to a market order.

It also seems that you've verified that your broker-dealer is pretty much square, so:

  • What's your trade server connection latency/speed?
  • Are you using a wireless connection?
  • MT5 is exponentially faster than MT4 on trade execution. Can you switch to MT5?
  • Indicator conflicts can also cause such issues.