Direct answer
Position size based on risk percentage is just a disciplined way of saying: decide how much you can lose first, then work backward to quantity from the distance between entry and stop.
That logic is simple, but it changes how traders think. The trade stops being a prediction-first decision and becomes a risk-first decision. That is usually a very healthy shift.
Where people usually get this wrong
The most common error is sizing from confidence instead of from invalidation.
- choosing a quantity first and then forcing the stop to fit it
- using a stop level that is not actually tied to the setup failure point
- ignoring slippage or contract rounding on the execution side
- pretending risk percentage alone makes a weak strategy safe
Copyable example
This is the kind of base pattern I prefer to start from before adding more filters, styling, or automation layers.
//@version=6
indicator("Risk based size", overlay = false)
capital = input.float(100000, "Capital")
riskPercent = input.float(1.0, "Risk %", step = 0.1)
entryPrice = input.float(100, "Entry")
stopPrice = input.float(95, "Stop")
riskAmount = capital * (riskPercent / 100.0)
perUnitRisk = math.abs(entryPrice - stopPrice)
qty = perUnitRisk > 0 ? riskAmount / perUnitRisk : na
plot(qty, "Position size", color.new(color.green, 0), 2)
How I would handle it in a real build
I always ask where the trade is wrong first. Once that stop location is honest, the risk-based size calculation becomes straightforward and much more useful than arbitrary lot or share counts.
If your current script or workflow already exists and the behavior is drifting, send the setup or code on WhatsApp. I can usually tell quickly whether it needs a rewrite, a migration pass, or a smaller audit.
WhatsApp for a 3-minute quoteWhat to read next
If this topic is part of a bigger TradingView or Pine Script workflow for you, these are the most useful follow-up guides on the site.
- Target Stop Loss Indicator
- Multiple Take Profit Targets
- TradingView indicator with target and stop loss
Send the chart idea, broker, market, and goal on WhatsApp. I can usually tell you quickly whether it needs a custom indicator, a strategy audit, an alert fix, or a broker-ready automation layer.
Related services
Frequently asked questions
Should I optimize this for backtests first or live behavior first?
Live behavior comes first. A cleaner live model usually gives you a more believable backtest, while the reverse is not always true.
Is Pine Script v6 the safer default for new examples now?
Yes. Traders still search with older wording, but new examples are usually easier to maintain and explain in v6.
When is the next step a service page instead of another tutorial?
Once you know the logic you want and the remaining problem is implementation, audit, or broker-ready structure, the service path is usually the better next move.
Primary sources and references
I take on Pine Script indicators, TradingView automation layers, strategy audits, and broker-aware execution workflows when the goal is clear and the live behavior actually matters.