OPEN-SOURCE SCRIPT
已更新 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.
版本注释
• 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.
版本注释
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.
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。