OPEN-SOURCE SCRIPT
Telah dikemas kini ATR RS 10/11

ATR RS — What it does (English)
• Purpose: A compact risk-sizing helper that plots Daily ATR(10, RMA) in a separate panel and shows a live sizing summary (ATR used, Stop, Per-unit risk, Risk, Size, Bet). Works on any chart timeframe.
• Daily ATR logic (robust intraday handling):
– Before first trade of the session: use yesterday’s daily ATR only.
– During the session (daily candle unconfirmed): use max(today’s daily ATR, yesterday’s daily ATR) to avoid underestimating volatility early in the day.
– After the daily candle closes: use today’s daily ATR.
• Stop rule (long bias):
Stop = Today’s Daily Low − Multiplier × ATR_used
• Position sizing:
Per-unit risk = max(Entry − Stop, 0) × PointValue
Raw size = RiskAmount / Per-unit risk
Final size = floor(Raw size / LotSize) × LotSize
(Optional cap via Max Position Cap; negatives coerced to 0.)
• “Entry” price: current chart close (i.e., real-time last for intraday, or close for historical/confirmed bars).
• Panel fields:
– ATR(10): Daily ATR(10, RMA)
– ATR used: the volatility value selected by the intraday rule above
– Stop: computed stop price (you can snap to tick if desired)
– Per-unit: risk per share/contract = (Entry − Stop) × PointValue
– Risk: user input, account currency
– Size: position size after lot rounding and cap
– Bet: Entry × Size × PointValue
• Inputs:
– ATR Length (Daily RMA), Multiplier (for stop), Risk Amount, Point Value (stocks=1; futures=contract point value), Lot Size, Max Position Cap, Show summary table.
• Notes:
– Uses request.security(“D”, …) with no lookahead, so the same ATR is used consistently regardless of the chart timeframe.
– If your venue has fractional ticks, consider snapping the Stop to tick size so labels and price markers match perfectly.
• Purpose: A compact risk-sizing helper that plots Daily ATR(10, RMA) in a separate panel and shows a live sizing summary (ATR used, Stop, Per-unit risk, Risk, Size, Bet). Works on any chart timeframe.
• Daily ATR logic (robust intraday handling):
– Before first trade of the session: use yesterday’s daily ATR only.
– During the session (daily candle unconfirmed): use max(today’s daily ATR, yesterday’s daily ATR) to avoid underestimating volatility early in the day.
– After the daily candle closes: use today’s daily ATR.
• Stop rule (long bias):
Stop = Today’s Daily Low − Multiplier × ATR_used
• Position sizing:
Per-unit risk = max(Entry − Stop, 0) × PointValue
Raw size = RiskAmount / Per-unit risk
Final size = floor(Raw size / LotSize) × LotSize
(Optional cap via Max Position Cap; negatives coerced to 0.)
• “Entry” price: current chart close (i.e., real-time last for intraday, or close for historical/confirmed bars).
• Panel fields:
– ATR(10): Daily ATR(10, RMA)
– ATR used: the volatility value selected by the intraday rule above
– Stop: computed stop price (you can snap to tick if desired)
– Per-unit: risk per share/contract = (Entry − Stop) × PointValue
– Risk: user input, account currency
– Size: position size after lot rounding and cap
– Bet: Entry × Size × PointValue
• Inputs:
– ATR Length (Daily RMA), Multiplier (for stop), Risk Amount, Point Value (stocks=1; futures=contract point value), Lot Size, Max Position Cap, Show summary table.
• Notes:
– Uses request.security(“D”, …) with no lookahead, so the same ATR is used consistently regardless of the chart timeframe.
– If your venue has fractional ticks, consider snapping the Stop to tick size so labels and price markers match perfectly.
Nota Keluaran
• What it doesCalculates a daily ATR(10, RMA) that is independent of your chart timeframe, then builds a simple risk‐sizing panel. It also shows an optional stop-price tag on the chart.
• ATR logic (intraday aware)
– Before the first trade of the day: use yesterday’s daily ATR.
– After the first trade, before the daily candle is confirmed: use max(today’s ATR, yesterday’s ATR).
– After the daily candle closes: use today’s ATR.
All numbers are snapped to the symbol’s tick size; for long setups the stop is floored to the nearest tick.
• Stop & risk
– Stop (long): Daily Low − Multiplier × ATR_used.
– Per-unit risk: max(Entry − Stop, 0) × PointValue, with Entry = current close.
– Position size: floor( RiskAmount / PerUnitRisk ) rounded down to your LotSize, and capped by MaxPosition (if set).
– Bet amount: Entry × Size × PointValue.
• Inputs
ATR Length, Multiplier, Risk Amount, Point Value (stocks=1, futures=contract point value), Lot Size, Max Position Cap, Show table, Show stop tag.
• Outputs
– Panel: ATR(10), ATR used, Stop, Per-unit, Risk, Size, Bet.
– Optional on-chart label showing the stop price (tick-snapped).
– Thin pink line in a separate pane plotting the daily ATR.
• Notes
If Per-unit risk is 0 or negative, size becomes 0 by design. For non-USD or futures, set PointValue accordingly to reflect P&L per price point.
Nota Keluaran
ATR RS (Daily ATR) • What it does
Calculates a daily ATR(10, RMA) that is independent of your chart timeframe, then builds a simple risk‐sizing panel. It also shows an optional stop-price tag on the chart.
• ATR logic (intraday aware)
– Before the first trade of the day: use yesterday’s daily ATR.
– After the first trade, before the daily candle is confirmed: use max(today’s ATR, yesterday’s ATR).
– After the daily candle closes: use today’s ATR.
All numbers are snapped to the symbol’s tick size; for long setups the stop is floored to the nearest tick.
• Stop & risk
– Stop (long): Daily Low − Multiplier × ATR_used.
– Per-unit risk: max(Entry − Stop, 0) × PointValue, with Entry = current close.
– Position size: floor( RiskAmount / PerUnitRisk ) rounded down to your LotSize, and capped by MaxPosition (if set).
– Bet amount: Entry × Size × PointValue.
• Inputs
ATR Length, Multiplier, Risk Amount, Point Value (stocks=1, futures=contract point value), Lot Size, Max Position Cap, Show table, Show stop tag.
• Outputs
– Panel: ATR(10), ATR used, Stop, Per-unit, Risk, Size, Bet.
– Optional on-chart label showing the stop price (tick-snapped).
– Thin pink line in a separate pane plotting the daily ATR.
• Notes
If Per-unit risk is 0 or negative, size becomes 0 by design. For non-USD or futures, set PointValue accordingly to reflect P&L per price point.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.