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은 실시간 바에서만 틱 단위 재계산이 적용되며, 히스토리 바/백테스트는 평가 방식이 달라 결과가 다를 수 있습니다.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Created by Surirang | 📺 YouTube: youtube.com/@surirangdotcom
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
Created by Surirang | 📺 YouTube: youtube.com/@surirangdotcom
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.