Hello,
I have noticed strange results after using a trailingstop and a stoploss together.
See picture, the trade is closed by the trailingstop instead by the stoploss.
System on DAX:
SET TARGET pPROFIT 61
SET STOP pLOSS 34
SET STOP PTRAILING 55
Could you share the code?
Sorry, I don’t want to share the code, because I’ve put a lot of time and money into this to get as far as I have now.
The code of the stop loss etc. is below the programming instructions.
I have often encountered it in other systems I have created that one of the two does not work.
Yes the lower / last instruction re a stop loss cancels any previous instruction re a stop loss.
pTrailing cancels / negates / renders ineffective pLoss as written below.
SET TARGET pPROFIT 61
SET STOP pLOSS 34
SET STOP PTRAILING 55
Yes, is GraHal right. You can’t have two different kind of STOP LOSS, the last one always overrides any previous one.
This should do the trick….
///// trailingstop for long and short /////////////////////
//////////////////////////////////////////////////////////////
/// Reset variables
IF NOT ONMARKET THEN
LaagsteKoers=1000000
HoogsteKoers=0
ENDIF
once UitstapOpTSL=15 // points to trail for long
once UitstapOpTSS=20 // 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 45
/// Exit by trailingstop is at market, only use this on small timeframes!!
BTW, points for trailingstops must be larger then your stoploss, this was only for test purposes.