PropValue

Pine Script v6

Prop Risk HUD

ATR-based stop distance in ticks and the contract count that keeps one loss inside your chosen share of the remaining drawdown.

Install

  1. Open TradingView, then Pine Editor at the bottom of the chart.
  2. Paste the script, press Save, then Add to chart.
  3. Open the indicator settings and enter your remaining drawdown and the share you will risk per trade.

Check sizes by hand with the position sizer.

What it does

A table in the top right shows the stop in ticks, dollars per contract, the contract count within your budget, the dollars at risk, and how many full losses the remaining drawdown absorbs.

Optional bands mark the stop distance above and below price. Pair it with the position sizer tool to check the numbers by hand.

Script

//@version=6
indicator("Prop Risk HUD", overlay = true)

// Inputs
riskCap   = input.float(250, "Max $ risk per trade", minval = 1)
ddLeft    = input.float(2000, "Drawdown remaining ($)", minval = 0)
ddShare   = input.float(15, "Max % of remaining drawdown per trade", minval = 1, maxval = 100)
atrLen    = input.int(14, "ATR length", minval = 1)
atrMult   = input.float(1.5, "Stop = ATR x", minval = 0.1, step = 0.1)
showBands = input.bool(true, "Plot stop reference bands")

// Maths
tickValue = syminfo.mintick * syminfo.pointvalue
stopPts   = ta.atr(atrLen) * atrMult
stopTicks = math.ceil(stopPts / syminfo.mintick)
budget    = math.min(riskCap, ddLeft * ddShare / 100)
perCon    = stopTicks * tickValue
contracts = perCon > 0 ? math.floor(budget / perCon) : 0
riskUsed  = contracts * perCon
lossesToFloor = riskUsed > 0 ? math.floor(ddLeft / riskUsed) : na

// Bands
plot(showBands ? close + stopPts : na, "Short stop ref", color.new(color.red, 40), style = plot.style_stepline)
plot(showBands ? close - stopPts : na, "Long stop ref", color.new(color.green, 40), style = plot.style_stepline)

// HUD
var table hud = table.new(position.top_right, 2, 5, bgcolor = color.new(color.black, 15), border_width = 1)
if barstate.islast
    txt = color.white
    table.cell(hud, 0, 0, "Stop", text_color = txt)
    table.cell(hud, 1, 0, str.tostring(stopTicks) + " ticks", text_color = txt)
    table.cell(hud, 0, 1, "$ / contract", text_color = txt)
    table.cell(hud, 1, 1, "$" + str.tostring(perCon, "#,###.##"), text_color = txt)
    table.cell(hud, 0, 2, "Contracts", text_color = txt)
    table.cell(hud, 1, 2, str.tostring(contracts), text_color = contracts == 0 ? color.orange : color.lime)
    table.cell(hud, 0, 3, "Risk used", text_color = txt)
    table.cell(hud, 1, 3, "$" + str.tostring(riskUsed, "#,###"), text_color = txt)
    table.cell(hud, 0, 4, "Losses to floor", text_color = txt)
    table.cell(hud, 1, 4, na(lossesToFloor) ? "-" : str.tostring(lossesToFloor), text_color = txt)