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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
// 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.
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :
Filename : download the ITF files
How to import ITF files into ProRealTime platform?
PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Hi
I tried to copy and paste the code, but recieve the message :
Syntax error:The following variable is undefined: p
Best regards
Hello, of course. You have 3 options : 1/ you download the file and import it into your platform and everything will be ok or 2/ add yourself the variable “p” into the indicator by manually adding it or 3/ uncomment the line p=1 by removing the “//”