Position Size & Stop Loss | QuantEdgeB

QuantEdgeB indicator for calculating risk-based position sizing, leverage, and dynamic stop-loss levelsโall in one on-chart dashboard.
๐ What It Does
1. Position Sizing
o Takes your Portfolio Value and Risk Percentage to compute how much dollar risk youโre willing to take.
o Given an Entry Price and Stop-Loss Price, it derives the per-trade risk and thus the optimal Position Size (number of contracts/shares).
o Based on your available Margin, it calculates the implied Leverage.
2. Stop-Loss Levels
o Offers two modes:
๏ง High-Low SL โ plots the highest high and lowest low over user-defined lookback windows.
๏ง Market-Structure SL โ dynamically tracks the current up/down โwickโ extremes using an HMA-driven regime filter and places your stop just inside the recent high/low wicks.
o Always overlays both a โHighest Bandโ and โLowest Bandโ as steplines, plus a simple moving average for trend context.
3. Dashboard Table
o Presents all core inputs and outputs in a neat on-chart table:
๏ง Portfolio Value, Margin, Risk %, Entry, Stop Loss
๏ง Computed Position Size and Leverage
๏ง Final Long SL and Short SL levels (depending on your chosen SL type)
o Fully customizable: choose table position, text size, color theme, and transparency.
โ๏ธ Inputs & Settings
Portfolio Value ($) -> Total account equity.
Margin on Exchange ($) -> Available margin for this trade.
Risk Percentage (%) -> Percent of portfolio to risk per trade.
Entry Price -> Your intended entry level.
Stop Loss Price -> Your intended stop level.
Decimal Places -> Rounding precision for โPosition Size.โ
Below the hood, โPosition Sizeโ is simply the number of units you should buy (or sell) so that, if your stop-loss is hit, you lose exactly your pre-defined risk amount. Hereโs how to translate it into a real tradeโand a quick example using the scriptโs default settings:
๐ข What โPosition Sizeโ Means - Deep Dive
โข Units: the raw number of shares, contracts, or cryptocurrency coins.
โข Risk per unit = |Entry Price โ Stop-Loss Price|
โข Total Risk = Portfolio Value ร (Risk %)
โข Position Size = Total Risk รท Risk per unit
If you trade instruments that are fractional (e.g. BTC) youโll buy that many coins; if itโs a futures contract, you buy that many contracts; if itโs stock, that many shares.
๐งฎ Hypothetical Example
1. Inputs
o Portfolio Value = $100 000
o Risk % = 1%
o Entry Price = 105 000
o Stop-Loss Price = 104 000
o Margin Available = $10 000
2. Compute Your Risk Budget
3. Total Risk = 100 000 ร (1 / 100) = $1 000
4. Compute Risk Per Unit
5. Risk per Unit = |105 000 โ 104 000| = $1 000 per unit
6. Compute Position Size
7. Position Size = 1 000 รท 1 000 = 1 unit
o If youโre trading 1 BTC contract, you buy 1 contract.
o If it were stock, youโd buy 1 share.
o If it were spot BTC, youโd buy 1 BTC.
8. Compute Implied Leverage
9. Notional Exposure = Position Size ร Entry Price = 1 ร 105 000 = $105 000
10. Leverage = 105 000 รท 10 000 โ 10.5ร
11. Place the Trade
o Buy 1 unit at 105 000.
o Place your stop-loss at 104 000.
o If price drifts down to 104 000, you lose exactly $1 000 (1% of your $100 000 account).
๐ Putting It All Together on the Chart
When the indicatorโs table shows:
1. Portfolio Value = 100'000
2. Margin = 10'000
3. Risk% = 1%
4. Entry = 105'000
5. Stop Loss = 104'000
6. Size = 1
7. Leverage = 10.5x
โฆthat tells you in plain terms:
โWith $100 000 behind me and a 1% risk threshold, buying 1 unit hereโwith my stop at 104 000โmeans I stand to lose $1 000 if Iโm wrong. Iโm using $10 000 of margin, so Iโm at roughly 10.5ร leverage.โ
No more guesswork around lot sizes or margin callsโthis table gives you the exact numbers you need to place that order.
๐จ Visual Output
1. Stepline Plots
o Highest Band (short-side stop) in your down-color.
o Lowest Band (long-side stop) in your up-color.
o EMA Trend Line for context.
2. Dashboard Table
o Header with the indicator name.
o First section: all your Position Size inputs & results.
o Separator line + SL-Type label.
o Final section: Long SL and Short SL values under the chosen mode.
o Color and transparency reflect your selected theme.
๐งโ๐ผ Why Itโs Useful
โข Risk-First Sizing: Never guess your position againโrisk is dollar-accurately defined.
โข Flexible Stop-Loss: Choose the simple bar-high/low bands or an adaptive โwick-insiderโ based on market structure.
โข On-Chart Clarity: Everything you need to size, stop-loss, and monitor your trade sits in one unified panel.
โข Customizable: Color themes, font sizes, SL methods, and moreโtailor it to your workflow.
Use this indicator to keep your risk parameters crystal-clear, automate your position sizing, and visualize both static and dynamic stop-loss levelsโall without leaving your TradingView chart.
Skrip jemputan sahaja
Hanya pengguna yang diluluskan oleh penulis boleh mengakses skrip ini. Anda perlu memohon dan mendapatkan kebenaran untuk menggunakannya. Ini selalunya diberikan selepas pembayaran. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi terus QuantEdgeB.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.
whop.com/quantedgeb/ ๐
๐น Unlock our free toolbox:
tradinglibrary.carrd.co/ ๐ ๏ธ
Disclaimer: All resources and indicators provided are for educational purposes only
Penafian
Skrip jemputan sahaja
Hanya pengguna yang diluluskan oleh penulis boleh mengakses skrip ini. Anda perlu memohon dan mendapatkan kebenaran untuk menggunakannya. Ini selalunya diberikan selepas pembayaran. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi terus QuantEdgeB.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.
whop.com/quantedgeb/ ๐
๐น Unlock our free toolbox:
tradinglibrary.carrd.co/ ๐ ๏ธ
Disclaimer: All resources and indicators provided are for educational purposes only