Trailing Stop
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © OztheWoz

//@version=4
study("Trailing Stop", overlay=true)

tssmot = input(false, "Trailing Stop Smoothing?")
tslen  = input(4, "Trailing Stop Smooth")
prc = input(3, "Trailing Stop Percentage")

trailstop = close[1] - (close[1] * prc/100)
tssma = sma(trailstop, tslen)

plot((tssmot ? tssma : trailstop), color=color.fuchsia)

