Trailing Stops Loss

‎14517‎ مشاهدة
Simple indicator to track trailing stops for long positions in intraday trading.
When applied initially shows trailing stop based on previous day close.
When going long go to "Format" and enter
- Buy Price (default - current bar close)
- Stop Range (default - $0.2)
- Time of trade.

Graph will change to reflect stop loss by Stop Range below Buy Price.
Going forward Stop Loss line will rise with price going up or stay at highest achieved level when price goes down.
Sell when price is close to current level of Stop Loss.

In chart above trade was made at 11:05 AM at $43.70
Initial Stop Loss set 43.70 - 0.2 = 43.50
Since bar close was 43.75 stop loss moved to 43.75

Works on different intraday intervals.
Does not work on first bar of the day
Starts on second bar of the day.
Previous days lines should be ignored.
نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الكود في منشور تحكمه قواعد الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟
// Intraday Trailing Stop Loss
study(title="Trailing Stops Loss", overlay = true)
StopLossRange = input(0.2)

highTimeFrame = "1"
sessSpec = input("0931-1600", type=session)
BuyPrice = input (close, type = float)

is_newbar(res, sess) =>
    t = time(res, sess)
    change(t) > 0 ? 1 : 0

TrailingStop = (BuyPrice >= close)? BuyPrice - StopLossRange : close >= open[1]? close - StopLossRange: TrailingStop[1]

new_TrailingStop = if is_newbar(highTimeFrame, sessSpec)
    if TrailingStop < new_TrailingStop[1]
plot_color = is_newbar(highTimeFrame, sessSpec)? color(red, 0): color(blue, 100) 
plot(new_TrailingStop, linewidth=2, color = plot_color )
//plot(TrailingStop, color=blue)


Just what I need. How can I convert it to work on a weekly chart?
+10 رد
Nice! can you make it worth with percentages?
+8 رد
Can this be changed for a short. Tks
+4 رد
Thank you for this, I have been looking something like this for ages. All other ATR based stop losses doesnt count ur entry price and they just go up above price. I wanted to use something which will follow the price and stop me from any big drops.
not working on my charts :((