OPEN-SOURCE SCRIPT
%-to-Tick Trailing Stop & Visualizer

Percent-to-Tick Trailing Stop (strategy.exit Framework + Visualizer)
Overview
This script focuses on exit management and visualization, not entry performance. The included MA crossover entry is intentionally simple and replaceable.
Core idea (Percent → Tick conversion)
strategy.exit() trailing parameters are tick-based (trail_points, trail_offset, and loss).
This script lets you input distances in percent (%) and converts them into integer ticks using syminfo.mintick, making the same exit logic portable across most tick-based symbols/exchanges with different tick sizes.
//==What it provides==//
1. % → tick conversion for:
- Fixed stop loss (loss)
- Trailing activation distance (trail_points)
- Trailing offset distance (trail_offset)
2. On-chart visualization:
- Entry average price
- Trailing activation threshold
- Fixed stop-loss line
- Trailing stop line (with an exit-bar alignment attempt to reduce gaps)
//==How to use==//
1. Keep the included MA crossover entries, or replace them with your own entries.
2. Configure:
- Fixed Stop Loss % (loss_pct)
- Trailing Activation % (t_points_pct)
- Trailing Offset % (t_offset_pct)
3. Adjust commission/slippage defaults to match your market.
//==Important limitations (must read)==//
- calc_on_every_tick=true recalculates on realtime bars only; historical bars are evaluated differently. Backtests can differ from realtime behavior and may change after reload.
- Tick rounding: percent distances are rounded to integer ticks, so small differences can occur depending on tick size and price level.
- For more realistic intrabar backtesting, consider enabling Bar Magnifier in Strategy Properties (if available).
# Average Entry Price (Basis):
"Calculations are based on the position's average entry price (strategy.position_avg_price)."
# Pine Script v6:
"Written in the latest Pine Script v6."
[KOR] 요약
이 스크립트의 핵심은 “진입 전략”이 아니라 **strategy.exit()의 tick 기반 트레일링 파라미터를 % 입력으로 일반화(%→ticks 변환)**하여, 다양한 심볼/거래소의 서로 다른 tick size 환경에서도 동일한 exit 로직을 재사용할 수 있게 만든 “청산 프레임워크”입니다. 또한 calc_on_every_tick=true 환경에서 트리거/손절/트레일 라인을 실시간에 가깝게 시각화하는 데 중점을 두었습니다.
단, calc_on_every_tick은 실시간 바에서만 틱 단위 재계산이 적용되며, 히스토리 바/백테스트는 평가 방식이 달라 결과가 다를 수 있습니다.
Overview
This script focuses on exit management and visualization, not entry performance. The included MA crossover entry is intentionally simple and replaceable.
Core idea (Percent → Tick conversion)
strategy.exit() trailing parameters are tick-based (trail_points, trail_offset, and loss).
This script lets you input distances in percent (%) and converts them into integer ticks using syminfo.mintick, making the same exit logic portable across most tick-based symbols/exchanges with different tick sizes.
//==What it provides==//
1. % → tick conversion for:
- Fixed stop loss (loss)
- Trailing activation distance (trail_points)
- Trailing offset distance (trail_offset)
2. On-chart visualization:
- Entry average price
- Trailing activation threshold
- Fixed stop-loss line
- Trailing stop line (with an exit-bar alignment attempt to reduce gaps)
//==How to use==//
1. Keep the included MA crossover entries, or replace them with your own entries.
2. Configure:
- Fixed Stop Loss % (loss_pct)
- Trailing Activation % (t_points_pct)
- Trailing Offset % (t_offset_pct)
3. Adjust commission/slippage defaults to match your market.
//==Important limitations (must read)==//
- calc_on_every_tick=true recalculates on realtime bars only; historical bars are evaluated differently. Backtests can differ from realtime behavior and may change after reload.
- Tick rounding: percent distances are rounded to integer ticks, so small differences can occur depending on tick size and price level.
- For more realistic intrabar backtesting, consider enabling Bar Magnifier in Strategy Properties (if available).
# Average Entry Price (Basis):
"Calculations are based on the position's average entry price (strategy.position_avg_price)."
# Pine Script v6:
"Written in the latest Pine Script v6."
[KOR] 요약
이 스크립트의 핵심은 “진입 전략”이 아니라 **strategy.exit()의 tick 기반 트레일링 파라미터를 % 입력으로 일반화(%→ticks 변환)**하여, 다양한 심볼/거래소의 서로 다른 tick size 환경에서도 동일한 exit 로직을 재사용할 수 있게 만든 “청산 프레임워크”입니다. 또한 calc_on_every_tick=true 환경에서 트리거/손절/트레일 라인을 실시간에 가깝게 시각화하는 데 중점을 두었습니다.
단, calc_on_every_tick은 실시간 바에서만 틱 단위 재계산이 적용되며, 히스토리 바/백테스트는 평가 방식이 달라 결과가 다를 수 있습니다.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
Created by Surirang | 📺 YouTube: youtube.com/@surirangdotcom
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
Created by Surirang | 📺 YouTube: youtube.com/@surirangdotcom
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。