OPEN-SOURCE SCRIPT
Position Size Calculator - Risk Manager, Risk/Reward & L[LunqFX]

Risk Manager is an on-chart position size and risk/reward calculator for TradingView that turns proper risk management into one click. Set your account size and risk per trade %, and it instantly gives you the exact position size (units / lots / contracts / shares), your risk and reward in dollars, the risk/reward ratio, and the breakeven win rate you need to be profitable — all visualized as clean risk and reward zones right on the chart. It works out of the box with an auto ATR setup (Entry / Stop Loss / Take Profit placed for you), or type your own levels. Built in Pine Script v6, it works on forex, crypto, stocks, indices, futures, gold (XAUUSD) and Bitcoin (BTCUSD), on any timeframe — because it sizes risk, not signals. Keywords: position size, position sizing, risk management, risk reward, risk/reward ratio, lot size calculator, money management, stop loss, take profit, R multiple, risk per trade, breakeven win rate, Kelly criterion, day trading, swing trading, scalping.
◆ WHY THIS MATTERS
Most traders blow accounts not because of bad entries, but because of bad position sizing and inconsistent risk. Professionals risk a fixed small % per trade (commonly 0.5–2%) and know their risk/reward before they click buy. This tool enforces that discipline on every trade — no spreadsheets, no external calculators.
◆ WHAT IT DOES
Exact position size from your account balance and risk %, in units, lots, contracts, shares or coins.
Risk and reward in account currency and as a % of account.
Risk/reward ratio with a clean visual meter.
Breakeven win rate — the minimum win rate needed to be profitable at your current R:R (a metric most calculators skip).
Visual risk zone (red) and reward zone (green) drawn between Entry, Stop and Target.
Optional fractional Kelly suggested risk %.
A modern, colour-coded dashboard.

◆ HOW IT WORKS
Auto mode (default): Entry is set at price, Stop at a chosen ATR distance, and Target at your chosen R multiple — a valid setup appears instantly on any instrument.
Manual mode: turn Auto off and enter your own exact Entry / Stop / Target prices in the settings.
Position size = (account balance × risk %) ÷ (distance from entry to stop). This guarantees that if the stop is hit, you lose exactly your chosen risk %.
Reward = position size × distance to target; R:R = reward ÷ risk.
Breakeven win rate = 100 ÷ (1 + R:R) — e.g., at 2R you only need to win >33% of trades to break even.
Lots/contracts = units ÷ your contract size (100000 for a forex standard lot, 1 for stocks/crypto, your multiplier for futures).
◆ HOW TO USE IT
Set Account balance and Risk per trade % once (e.g., 1%).
Pick Auto direction (Long/Short) or switch to manual and place your real Entry/Stop/Target.
Read the Position size — that is exactly how much to trade so your loss at stop = your set risk.
Check the R:R meter and Breakeven — only take trades whose math fits your strategy’s win rate.
Use the red/green zones to see risk and reward visually before entering.
Adjust Contract size to match your instrument (forex lots, futures multiplier, etc.).
◆ SETTINGS
Trade Setup (auto ATR or manual prices, direction, ATR stop, target R), Account & Risk (balance, risk %, contract size, size label), Kelly (optional), Visuals (box length, neon candles), Panel (text size, position, colours).
◆ ALERTS
Price hit Entry · Price hit Stop · Price hit Target.
◆ ORIGINALITY
This is original work. The auto-ATR setup engine, the account-aware sizing, the visual risk/reward zones, the colour-coded dashboard with the R:R meter and the breakeven-win-rate readout are all my own implementation. No third-party code is used.
◆ LIMITATIONS
This is a planning and sizing tool, not a signal generator — it does not tell you when to buy or sell.
Position size assumes your account currency matches the quote currency; for cross-currency pairs or unusual contracts, set Contract size to match your broker’s lot/units.
The auto ATR setup is a starting template — always adjust Stop and Target to real structure.
Results depend on the inputs you provide (balance, risk %, contract size); double-check them for your broker.
◆ NON-REPAINTING
This is a calculator: it draws from your inputs and the current price and never alters historical bars.
Risk Manager is an educational tool, not financial advice. Trading involves risk of loss. Always do your own research and manage risk responsibly. © LunqFX.
◆ WHY THIS MATTERS
Most traders blow accounts not because of bad entries, but because of bad position sizing and inconsistent risk. Professionals risk a fixed small % per trade (commonly 0.5–2%) and know their risk/reward before they click buy. This tool enforces that discipline on every trade — no spreadsheets, no external calculators.
◆ WHAT IT DOES
Exact position size from your account balance and risk %, in units, lots, contracts, shares or coins.
Risk and reward in account currency and as a % of account.
Risk/reward ratio with a clean visual meter.
Breakeven win rate — the minimum win rate needed to be profitable at your current R:R (a metric most calculators skip).
Visual risk zone (red) and reward zone (green) drawn between Entry, Stop and Target.
Optional fractional Kelly suggested risk %.
A modern, colour-coded dashboard.
◆ HOW IT WORKS
Auto mode (default): Entry is set at price, Stop at a chosen ATR distance, and Target at your chosen R multiple — a valid setup appears instantly on any instrument.
Manual mode: turn Auto off and enter your own exact Entry / Stop / Target prices in the settings.
Position size = (account balance × risk %) ÷ (distance from entry to stop). This guarantees that if the stop is hit, you lose exactly your chosen risk %.
Reward = position size × distance to target; R:R = reward ÷ risk.
Breakeven win rate = 100 ÷ (1 + R:R) — e.g., at 2R you only need to win >33% of trades to break even.
Lots/contracts = units ÷ your contract size (100000 for a forex standard lot, 1 for stocks/crypto, your multiplier for futures).
◆ HOW TO USE IT
Set Account balance and Risk per trade % once (e.g., 1%).
Pick Auto direction (Long/Short) or switch to manual and place your real Entry/Stop/Target.
Read the Position size — that is exactly how much to trade so your loss at stop = your set risk.
Check the R:R meter and Breakeven — only take trades whose math fits your strategy’s win rate.
Use the red/green zones to see risk and reward visually before entering.
Adjust Contract size to match your instrument (forex lots, futures multiplier, etc.).
◆ SETTINGS
Trade Setup (auto ATR or manual prices, direction, ATR stop, target R), Account & Risk (balance, risk %, contract size, size label), Kelly (optional), Visuals (box length, neon candles), Panel (text size, position, colours).
◆ ALERTS
Price hit Entry · Price hit Stop · Price hit Target.
◆ ORIGINALITY
This is original work. The auto-ATR setup engine, the account-aware sizing, the visual risk/reward zones, the colour-coded dashboard with the R:R meter and the breakeven-win-rate readout are all my own implementation. No third-party code is used.
◆ LIMITATIONS
This is a planning and sizing tool, not a signal generator — it does not tell you when to buy or sell.
Position size assumes your account currency matches the quote currency; for cross-currency pairs or unusual contracts, set Contract size to match your broker’s lot/units.
The auto ATR setup is a starting template — always adjust Stop and Target to real structure.
Results depend on the inputs you provide (balance, risk %, contract size); double-check them for your broker.
◆ NON-REPAINTING
This is a calculator: it draws from your inputs and the current price and never alters historical bars.
Risk Manager is an educational tool, not financial advice. Trading involves risk of loss. Always do your own research and manage risk responsibly. © LunqFX.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Trade setups with clear entry, stop, target and risk logic. Built for traders who want structure, not guessing.
t.me/lunqfx
lunqfx.com
t.me/lunqfx
lunqfx.com
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
Trade setups with clear entry, stop, target and risk logic. Built for traders who want structure, not guessing.
t.me/lunqfx
lunqfx.com
t.me/lunqfx
lunqfx.com
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.