Hi guys! I need some help.
Ive included 2 types of trailing stop loss, found on this forum. I belive the MFE calculates the maximum profit you see in a trade, while the TSL calculates after candle is finished. am i right? Or are both the stop losses calculating when candle is closed only?
If the MFE is calculating from the EQ curve at all times, is it possible to combine these 2?
as an example to show what i mean: ive seen a trade go to 85€ in profit and the stop loss should be activated when im above 80€, but in this example the trade fell down to only 75€ in profit when the candle closed, meaning my trailing stop loss didnt activate and i had to watch the trade go all the way down to 0.
just to be extra clear: i want the TSL trailing stop, but i want it to be able to see that my trade peaked above 80€ even tho it was below 80€ when the candle closed.
MFE:
//************************************************************************
// MFE trailing stop function
//************************************************************************
///trailing stop
trailingstop = 80
StartTrailingStopValue = 10
//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
priceexit = 0
endif
//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if close-tradeprice(1) > StartTrailingStopValue*pointsize then
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
endif
endif
endif
//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif
9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
//************************************************************************
// TSL trailing stop function
//************************************************************************
//************************************************************************
//trailing stop function
trailingstart = 80// 20trailing will start @trailinstart points profit
trailingstep = 10// 5trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************
All calculations will always be done at the close of a candle so if price has gone really high and then fallen back a long way you will always miss that action and only be able to calculate new a stoploss once the candle has closed.
You could try changing the MFE trailing stoploss calculations to be calculated on the high rather than the close and see if you can get that to work better for you as technically the close is not the maximum MFE the high is.
I’m a bit too tired to try it out myself right now but would be glad to see your results 🙂
All calculations will always be done at the close of a candle so if price has gone really high and then fallen back a long way you will always miss that action and only be able to calculate new a stoploss once the candle has closed. You could try changing the MFE trailing stoploss calculations to be calculated on the high rather than the close and see if you can get that to work better for you as technically the close is not the maximum MFE the high is. I’m a bit too tired to try it out myself right now but would be glad to see your results 
Aha, okay, damn 😀
I guess ill try to just change it to high then, thanks. Im done for the evening but will post results using different stops to show difference.