%-to-Tick Trailing Stop & Visualizer — Strategy by surirang
By surirang
Performance Metrics
- Author: surirang
- Symbol: BINANCE:BTCUSDT.P
- Timeframe: 4 hours
- Net P&L: +890.57 USD (+8.91%)
- Win Rate: 41.5%
- Profit Factor: 1.137
- Max Drawdown: 427.49 USD (3.85%)
- Total Trades: 557
Description
Percent-to-Tick Trailing Stop (strategy.exit Framework + Visualizer)OverviewThis 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은 실시간 바에서만 틱 단위 재계산이 적용되며, 히스토리 바/백테스트는 평가 방식이 달라 결과가 다를 수 있습니다.