UNIVERSAL Position Size Calculator ALL Brokers mobil brokers//@version=5
indicator("UNIVERSAL Risk & Position Size Calculator (ALL Brokers)", overlay=true)
// =====================
// USER INPUTS
// =====================
accountBalance = input.float(100000, "Account Balance")
riskPercent = input.float(1.0, "Risk % per Trade", step=0.1)
// =====================
// EXECUTION TYPE (ONE LINE – PINE SAFE)
// =====================
executionType = input.string("MT4 / MT5 / cTrader", "Execution Type", options= )
// =====================
// LOT / CONTRACT DEFINITION (MANUAL)
// =====================
lotDefinition = input.float(100000, "Units per Lot / Contract")
// =====================
// ENTRY & STOP
// =====================
entryPrice = input.float(0.0, "Entry Price")
stopPrice = input.float(0.0, "Stop Loss Price")
// =====================
// SYMBOL DATA (AUTO)
// =====================
tickSize = syminfo.mintick
tickValue = syminfo.pointvalue * syminfo.mintick
// =====================
// CORE CALCULATIONS
// =====================
riskAmount = accountBalance * (riskPercent / 100)
stopDistance = math.abs(entryPrice - stopPrice)
ticks = stopDistance / tickSize
riskPerUnit = ticks * tickValue
unitsAllowed = riskPerUnit > 0 ? riskAmount / riskPerUnit : na
rawPosition = unitsAllowed / lotDefinition
// Futures = whole contracts only
finalPosition = executionType == "Futures" ? math.floor(rawPosition) : rawPosition
// =====================
// DISPLAY PANEL
// =====================
var table t = table.new(position.top_right, 2, 13, border_width=1)
table.cell(t, 0, 0, "Execution Type")
table.cell(t, 1, 0, executionType)
table.cell(t, 0, 1, "Account Balance")
table.cell(t, 1, 1, str.tostring(accountBalance))
table.cell(t, 0, 2, "Risk %")
table.cell(t, 1, 2, str.tostring(riskPercent) + "%")
table.cell(t, 0, 3, "Risk Amount ($)")
table.cell(t, 1, 3, str.tostring(riskAmount))
table.cell(t, 0, 4, "Entry Price")
table.cell(t, 1, 4, str.tostring(entryPrice))
table.cell(t, 0, 5, "Stop Loss Price")
table.cell(t, 1, 5, str.tostring(stopPrice))
table.cell(t, 0, 6, "Stop Distance")
table.cell(t, 1, 6, str.tostring(stopDistance))
table.cell(t, 0, 7, "Risk per 1 Unit ($)")
table.cell(t, 1, 7, str.tostring(riskPerUnit))
table.cell(t, 0, 8, "Units Allowed")
table.cell(t, 1, 8, str.tostring(unitsAllowed, "#.##"))
table.cell(t, 0, 9, "Units per Lot / Contract")
table.cell(t, 1, 9, str.tostring(lotDefinition))
table.cell(t, 0, 10, "POSITION SIZE TO ENTER")
table.cell(t, 1, 10, str.tostring(finalPosition, "#.##"))
table.cell(t, 0, 11, "Broker Tip")
table.cell(t, 1, 11, "Copy this value into broker")
table.cell(t, 0, 12, "Symbol")
table.cell(t, 1, 12, syminfo.ticker)
Pine Script® indicator






















