PROTECTED SOURCE SCRIPT
Position Size Calculator forex

//version=5
indicator("AUTO Risk & Position Size Calculator – FOREX (EURUSD)", overlay=true)
// === INPUTS ===
accountBalance = input.float(100000, "Account Balance")
riskPercent = input.float(1.0, "Risk % per Trade", step=0.1)
// === ENTRY & STOP (MANUAL) ===
entryPrice = input.float(0.0, "Entry Price")
stopPrice = input.float(0.0, "Stop Loss Price")
// === SYMBOL DATA (AUTO FROM TRADINGVIEW) ===
tickSize = syminfo.mintick
tickValue = syminfo.pointvalue * syminfo.mintick
// === CALCULATIONS ===
riskAmount = accountBalance * (riskPercent / 100)
stopDistance = math.abs(entryPrice - stopPrice)
// antal ticks mellem entry og stop
ticks = stopDistance / tickSize
// risk pr. 1 lot
riskPerLot = ticks * tickValue
// lots der skal trades
lotsToTrade = riskPerLot > 0 ? riskAmount / riskPerLot : na
// === DISPLAY ===
var table t = table.new(position.top_right, 2, 9, border_width=1)
table.cell(t, 0, 0, "Symbol")
table.cell(t, 1, 0, syminfo.ticker)
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 Lot ($)")
table.cell(t, 1, 7, str.tostring(riskPerLot))
table.cell(t, 0, 8, "LOTS TO TRADE")
table.cell(t, 1, 8, str.tostring(lotsToTrade, "#.##"))
indicator("AUTO Risk & Position Size Calculator – FOREX (EURUSD)", overlay=true)
// === INPUTS ===
accountBalance = input.float(100000, "Account Balance")
riskPercent = input.float(1.0, "Risk % per Trade", step=0.1)
// === ENTRY & STOP (MANUAL) ===
entryPrice = input.float(0.0, "Entry Price")
stopPrice = input.float(0.0, "Stop Loss Price")
// === SYMBOL DATA (AUTO FROM TRADINGVIEW) ===
tickSize = syminfo.mintick
tickValue = syminfo.pointvalue * syminfo.mintick
// === CALCULATIONS ===
riskAmount = accountBalance * (riskPercent / 100)
stopDistance = math.abs(entryPrice - stopPrice)
// antal ticks mellem entry og stop
ticks = stopDistance / tickSize
// risk pr. 1 lot
riskPerLot = ticks * tickValue
// lots der skal trades
lotsToTrade = riskPerLot > 0 ? riskAmount / riskPerLot : na
// === DISPLAY ===
var table t = table.new(position.top_right, 2, 9, border_width=1)
table.cell(t, 0, 0, "Symbol")
table.cell(t, 1, 0, syminfo.ticker)
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 Lot ($)")
table.cell(t, 1, 7, str.tostring(riskPerLot))
table.cell(t, 0, 8, "LOTS TO TRADE")
table.cell(t, 1, 8, str.tostring(lotsToTrade, "#.##"))
보호된 스크립트입니다
이 스크립트는 비공개 소스로 게시됩니다. 하지만 이를 자유롭게 제한 없이 사용할 수 있습니다 – 자세한 내용은 여기에서 확인하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
보호된 스크립트입니다
이 스크립트는 비공개 소스로 게시됩니다. 하지만 이를 자유롭게 제한 없이 사용할 수 있습니다 – 자세한 내용은 여기에서 확인하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.