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が提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。