///// trailingstop for long and short and stoploss /////////////////////
////////////////////////////////////////////////////////////////////////////
//// Version 1.0 dd 21-05-2024//////////////////////////////////////////
/// Reset variables
IF NOT ONMARKET THEN
LaagsteKoers=1000000
HoogsteKoers=0
ENDIF
once UitstapOpTSL=45 // points to trail for long
once UitstapOpTSS=55 // points to trail for short
////////////// LONG /////////////////////////////
If LongOnMarket AND HoogsteKoers=0 THEN
OpeningsprijsL= close
Hoogstekoers=openingsprijsL
ENDIF
// Determine highest high
If LONGONMARKET THEN
DezeHigh= high
If DezeHigh > HoogsteKoers then
Hoogstekoers=DezeHigh
ENDIF
ENDIF
//Sell trade if close< highest high- x points (UitstapOpTSL )
IF (close < (Hoogstekoers - UitstapOpTSL)) and LONGONMARKET then
SELL AT MARKET
ENDIF
///////////////// SHORT ////////////////////////////////////////////
IF ShortOnMarket AND LaagsteKoers=1000000 THEN
OpeningsprijsS= close
Laagstekoers=openingsprijsS
ENDIF
IF ShortOnMarket THEN
DezeLow= low
If DezeLow < laagsteKoers then
LaagsteKoers=DezeLow
endif
ENDIF
IF (close > (Laagstekoers + UitstapOpTSS)) and SHORTONMARKET then
EXITSHORT AT MARKET
endif
SET TARGET pPROFIT 75
SET STOP pLOSS 35
/// Exit by trailingstop is at market, only use this on small timeframes!!