Dieser einfache Code sichert die Gewinne ihres Handelssystems.
Über den Input “visuals” können sie entscheiden, ob der Code den Stop am Chart anzeigen soll oder nicht.
// % trailing stop. Meta: Synopsis("Trailing Stop in %"); Inputs: PercentTrailing(10.0), visuals(true), StopOnEntryBar(false); Variables: hh, ll; If barssinceentry>=0 then begin hh=highest(high,maxlist(1,barssinceentry+1)); ll=lowest(low,maxlist(1,barssinceentry+1)); if marketposition=1 then sell next bar at hh-percentTrailing*hh/100 stop; if marketposition=-1 then cover next bar at ll+percentTrailing*ll/100 stop; end; setstopcontract; If StopOnEntryBar then setstoploss(close/100*percenttrailing*lotsize); // close used, as entryprice is not available at first bar if visuals=true then drawsymbol(getactiveorderprice(1));