Finding an optimal stop loss value

 

hi,


does anybody know a good method to find the optimal stop loss?

to set it fix seems to be a stupid idea because if you want to trade on different currencies 100 pips could be really much or really little.


best regards,

mike

 
mk77ch:

hi,


does anybody know a good method to find the optimal stop loss?

to set it fix seems to be a stupid idea because if you want to trade on different currencies 100 pips could be really much or really little.


best regards,

mike

mk77ch,

optimal stop loss depends on pair, timeframe, your strategy. A good way to find the optimal s/l for a strategy is to run an optimization on the backtester.

 

mk77ch

Yes I have gone away from fixed levels, saves so much time by making an EA self-optimising and the resuts are generally better

This is an example of a hypothetical trend-following EA calculating SL, TP & TS for EURJPY on the H1 chart

The values are then ready for entering three orders on signal

Also shows how to handle full & sub-pip accounts on the fly :)

As ever, OTTOMH

//+------------------------------------------------------------------+
//|                                                       Barrow Boy |
//|                                            briandee@selectfx.net |
//+------------------------------------------------------------------+
#property copyright "SelectFX"
#property link      "www.selectfx.net"




extern int ATR.Period = 14;
extern int Slippage = 5;


int StopLoss.1, StopLoss.2, StopLoss.3,  TrailingStop.1, TrailingStop.2, TrailingStop.3, TakeProfit.1, TakeProfit.2, TakeProfit.3;

int Real.StopLoss.1, Real.StopLoss.2, Real.StopLoss.3,  Real.TrailingStop.1, Real.TrailingStop.2, Real.TrailingStop.3, Real.TakeProfit.1, Real.TakeProfit.2, Real.TakeProfit.3, Real.Slippage;




start
{

   
   
   double d_ATR = NormalizeDouble(iATR(strSymbol, PERIOD_D1, ATR.Period, 1), 2); // Get the Daily range

   
   int i_ATR = d_ATR*100;  // Turn it into (full) pips
   
   StopLoss.1 = i_ATR/2;
   StopLoss.2 = i_ATR/3;
   StopLoss.3 = i_ATR/4;
   
   TrailingStop.1 = i_ATR/2;
   TrailingStop.2 = i_ATR/3;
   TrailingStop.3 = i_ATR/4;
   
   TakeProfit.1 = i_ATR;
   TakeProfit.2 = i_ATR/2;
   TakeProfit.3 = i_ATR/4;
   

   // ======== Handle full or sub-pip account =============
   
   if (Digits == 2) // i.e. for yen pair
     {
                       
       Real.StopLoss.1     =    StopLoss.1;   
       Real.TrailingStop.1 =          TrailingStop.1;  
       Real.TakeProfit.1   =          TakeProfit.1;    
                       
       Real.StopLoss.2      =        StopLoss.2;       
       Real.TrailingStop.2  =         TrailingStop.2;    
       Real.TakeProfit.2    =         TakeProfit.2;    
                       
       Real.StopLoss.3      =        StopLoss.3;      
       Real.TrailingStop.3  =         TrailingStop.3;   
       Real.TakeProfit.3    =         TakeProfit.3;     
                       
       Real.Slippage        =          Slippage;             
                       

    }
  
    if (Digits == 3) // i.e. for yen pair
     {

                       
       Real.StopLoss.1     =         StopLoss.1*10;   
       Real.TrailingStop.1 =          TrailingStop.1*10;  
       Real.TakeProfit.1   =          TakeProfit.1*10;    
                       
       Real.StopLoss.2      =        StopLoss.2*10;       
       Real.TrailingStop.2  =         TrailingStop.2*10;    
       Real.TakeProfit.2    =         TakeProfit.2*10;    
                       
       Real.StopLoss.3      =        StopLoss.3*10;      
       Real.TrailingStop.3  =         TrailingStop.3*10;   
       Real.TakeProfit.3    =         TakeProfit.3*10;     
                       
       Real.Slippage        =          Slippage*10;             
                       


    } 



//============= Do Order stuff using the Real. values ===============================


   return (0);
  }

Good Luck

-BB-

 

thank you very much!


best regards,

mike

 

One thing about using ATR (by itself) to determine SL/TP is you could have a very active day yesterday (large range) and an quiet day today, or vice versa.


Which may or may not be OK, depending on the rest of your strategy.


But certainly, if you were to fix your SL/TP, it would have to be different fixed values for different Symbols(), at least.

 

> you could have a very active day yesterday (large range) and an quiet day today

Theres always that risk unfortunately - but this general ATR-based method is better in more strategies on more occasions than the fixed-pip approach when on the M15 chart or above

I would go with fixed targets for M1/M5

The ATR approach also makes it simpler to develop a multicurrency EA

For more sophistication, one could plot the Moving Average of the ATR, so if the ATR is below the MA, you would pull in the values and extend them if ATR is above its MA

You would thus, even more, be ahead of the game :)

FWIW

-BB-

Reason: