OPEN-SOURCE SCRIPT
CORNELUS LA PIRAMIDE

ATR Risk Dashboard (FX)
A minimal position-sizing dashboard for forex. It reads the ATR of the
current chart timeframe, converts it into a stop distance, and shows how
many lots you can trade while keeping the theoretical risk at or below a
fixed dollar amount.
Four lines, nothing else:
ATR - average true range in pips, current timeframe
Stop - ATR x multiplier, in pips
Risk - your dollar risk, entered manually
Lots - position size, rounded down to 0.01
HOW IT WORKS
1. ATR is calculated on whatever timeframe the chart is on. Nothing is
hard-coded - switch from 5m to 1h and the numbers follow.
2. Stop distance = ATR x multiplier. This is a DISTANCE, not a price.
The script draws no lines and places no orders.
3. Risk per lot = stop distance x units per lot x quote-currency rate.
The quote currency is converted to USD automatically using
request.currency_rate(), so the dollar figure is correct on USDJPY,
GBPJPY, EURAUD, NZDCAD and any other cross - not just USD-quoted pairs.
4. Lots = risk / risk per lot, always rounded DOWN to 0.01.
EXAMPLE - EURUSD, ATR 4.5 pips, multiplier 1.5, risk $200
Stop = 4.5 x 1.5 = 6.75 pips (0.000675)
Risk/lot = 0.000675 x 100,000 x 1 = $67.50
Lots = 200 / 67.50 = 2.962 -> 2.96
2.96 x $67.50 = $199.80, at or below the $200 limit.
Displayed values are rounded to one decimal for readability, but the
sizing math uses the raw unrounded stop. A stop shown as "6.8" is
divided as 6.75.
SETTINGS
ATR Length default 14
ATR Multiplier default 1.5
Risk $ default 500
Units per Lot default 100000 (standard lot)
For metals, set Units per Lot to 100 for XAUUSD or 5000 for XAGUSD.
Leave it at 100000 for all currency pairs.
NOTES
- Pip size is derived as mintick x 10, which handles JPY pairs correctly.
- Sizing is risk-based only. It does not check available margin - a valid
lot size can still exceed what your leverage allows.
- Spread is not included in the stop. On very low timeframes the stop can
be only a few pips, where spread is a significant share of the risk.
- The last bar updates live, so figures move until the bar closes.
Not financial advice. Position sizing is one input among many.
A minimal position-sizing dashboard for forex. It reads the ATR of the
current chart timeframe, converts it into a stop distance, and shows how
many lots you can trade while keeping the theoretical risk at or below a
fixed dollar amount.
Four lines, nothing else:
ATR - average true range in pips, current timeframe
Stop - ATR x multiplier, in pips
Risk - your dollar risk, entered manually
Lots - position size, rounded down to 0.01
HOW IT WORKS
1. ATR is calculated on whatever timeframe the chart is on. Nothing is
hard-coded - switch from 5m to 1h and the numbers follow.
2. Stop distance = ATR x multiplier. This is a DISTANCE, not a price.
The script draws no lines and places no orders.
3. Risk per lot = stop distance x units per lot x quote-currency rate.
The quote currency is converted to USD automatically using
request.currency_rate(), so the dollar figure is correct on USDJPY,
GBPJPY, EURAUD, NZDCAD and any other cross - not just USD-quoted pairs.
4. Lots = risk / risk per lot, always rounded DOWN to 0.01.
EXAMPLE - EURUSD, ATR 4.5 pips, multiplier 1.5, risk $200
Stop = 4.5 x 1.5 = 6.75 pips (0.000675)
Risk/lot = 0.000675 x 100,000 x 1 = $67.50
Lots = 200 / 67.50 = 2.962 -> 2.96
2.96 x $67.50 = $199.80, at or below the $200 limit.
Displayed values are rounded to one decimal for readability, but the
sizing math uses the raw unrounded stop. A stop shown as "6.8" is
divided as 6.75.
SETTINGS
ATR Length default 14
ATR Multiplier default 1.5
Risk $ default 500
Units per Lot default 100000 (standard lot)
For metals, set Units per Lot to 100 for XAUUSD or 5000 for XAGUSD.
Leave it at 100000 for all currency pairs.
NOTES
- Pip size is derived as mintick x 10, which handles JPY pairs correctly.
- Sizing is risk-based only. It does not check available margin - a valid
lot size can still exceed what your leverage allows.
- Spread is not included in the stop. On very low timeframes the stop can
be only a few pips, where spread is a significant share of the risk.
- The last bar updates live, so figures move until the bar closes.
Not financial advice. Position sizing is one input among many.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。