Stop % on ATR and stock beta

Category: Indicators By: Climber's trading Created: May 11, 2026, 8:35 AM
May 11, 2026, 8:35 AM
Indicators
0 Comments

– This indicator plots a theoretical ATR-based long stop and short stop.

– It also calculates position size based on account size, risk %, beta, ATR stop distance, and max portfolio allocation.

– The position size is displayed as text on the last bar only.

– Blue line = long stop, orange line = short stop.

// =====================================================
// ATR LONG/SHORT STOP + SIZE SU ULTIMA BARRA
// =====================================================

// ---------------------
// PARAMETRI UTENTE
// ---------------------

// Capitale totale del portafoglio
account = 100000

// Rischio base per trade in % del capitale
riskBasePct = 1

// Beta del titolo
// Se non disponibile, lascia 1
beta = 1

// Peso massimo del titolo nel portafoglio in %
maxPosPct = 3

// Moltiplicatore ATR per la distanza dello stop
kATR = 2

// Periodo ATR
atrPeriod = 14

// ---------------------
// CALCOLI
// ---------------------

atr = AverageTrueRange[atrPeriod](close)
stopDist = kATR * atr

longStop = close - stopDist
shortStop = close + stopDist

riskBetaPct = riskBasePct / beta

IF riskBetaPct < 0.5 THEN
riskBetaPctAdj = 0.5
ELSIF riskBetaPct > 1.5 THEN
riskBetaPctAdj = 1.5
ELSE
riskBetaPctAdj = riskBetaPct
ENDIF

riskCash = account * (riskBetaPctAdj / 100)

IF stopDist > 0 THEN
sizeTheo = riskCash / stopDist
sizeCap = (account * (maxPosPct / 100)) / close
sizeFinal = MIN(sizeTheo, sizeCap)
ELSE
sizeFinal = 0
ENDIF

// ---------------------
// TESTO SOLO ULTIMA BARRA
// ---------------------

IF IsLastBarUpdate THEN
DRAWTEXT("Size = #sizeFinal#", BarIndex, low - atr, SansSerif, Bold, 12) COLOURED(255,255,0,255)
ENDIF

// ---------------------
// OUTPUT
// ---------------------

RETURN longStop COLOURED(0,0,255) AS "Stop Long", shortStop COLOURED(255,165,0) AS "Stop Short"

Download
Filename: AND-Stop-rischio-e-beta.itf
Downloads: 37
Climber's trading Junior
A group of traders studying financial markets and exchanging information. Languages: Italian and English Methodologies: Discretionary and systematic Tools: Stocks, futures, options Discord channel: https://discord.gg/2KwmPeuf8e
Author’s Profile

Comments

Logo Logo
Loading...