Nice and useful stoploss indicator placement. Similar to a “supertrend” a bit, as the price goes above or below the recent high/low plus or minus a percent to change direction.
I changed a bit the drawing to add a second line to act as a band, more visual indeed.
// TrailingStop%
// JWK, 20091016
//p=1
perc = p // input Trailing Loss % - median term: 5 - 10
longloss = high*perc/100
shortloss = low*perc/100
If high < shorttrail[1] and direction[1] = -1 then // staying short
shorttrail = Min(shorttrail[1],low + shortloss)
longtrail = Min(longtrail[1],high - longloss)
plot = shorttrail
direction = -1
elsif high > shorttrail[1] and direction[1] = -1 then // short stopped out, going long
shorttrail = Max(shorttrail[1], low + shortloss)
longtrail = high - longloss
plot = longtrail
direction = 1
elsif low > longtrail[1] and direction[1] = 1 then // staying long
longtrail = Max(longtrail[1],high - longloss)
shorttrail = Max(shorttrail[1], low + shortloss)
plot = longtrail
direction = 1
elsif low < longtrail[1] and direction[1] = 1 then // long stopped out, going short
longtrail = Min(longtrail[1],high - longloss)
shorttrail = low + shortloss
plot = shorttrail
direction = -1
else
shorttrail = low + shortloss
longtrail = high - longloss
plot = longtrail
direction = 1
endif
return plot AS "TrailStop%", plot+10*pipsize AS "TrailStop% band"
//indicator from Kevin Britains archive.