TradingView 1R Lot Size Pine Script v6 Indicator
On a $100,000.00 account, risking 1% ($1,000.00) with a stop of 20 pips, CHFJPY sizes to 7.91 lots. One pip on 1.00 lot is $6.3167. The loss at that rounded size is $999.3052, with no spread and no commission.
Pine Script v6 source
Open TradingView Pine Editor, paste, and click Add to chart. Renders Entry, Stop Loss, Take Profit, and lot size right away using 1x ATR or your custom stop, and auto-detects gold (XAUUSD), silver, oil, indices, crypto, JPY, and major FX pairs.
//@version=6
indicator("Danel Research - 1R Prop Lot Size & Daily Check", overlay=true, max_lines_count=20, max_labels_count=20)
// Inputs matching Danel Research sizing rules (strict floor down to lot step)
accountBalance = input.float(100000.0, "Account Balance ($)", minval=100.0, step=1000.0)
riskPct = input.float(1.0, "Risk per Trade (%)", minval=0.05, maxval=25.0, step=0.25)
dailyLimitPct = input.float(5.0, "Prop Daily Loss Limit (%)", minval=0.0, maxval=25.0, step=0.5)
todayRealized = input.float(0.0, "Today's Realized P&L ($)", step=100.0)
direction = input.string("Long", "Direction", options=["Long", "Short"])
stopMode = input.string("Pips / Points", "Stop Mode", options=["Pips / Points", "Custom Price"])
stopPipsIn = input.float(0.0, "Stop Distance (Pips / Points, 0 = 1x ATR)", minval=0.0, step=5.0)
customStopIn = input.float(0.0, "Custom Stop Loss Price (when Stop Mode = Custom Price)", minval=0.0)
entryPriceIn = input.float(0.0, "Entry Price (0 = live close)", minval=0.0)
targetR = input.float(2.0, "Target R Multiple", minval=0.5, step=0.5)
autoDetect = input.bool(true, "Auto-detect Contract & Pip Size")
contractSizeIn = input.float(100000.0, "Manual Contract Size per 1.00 Lot", minval=0.001)
pipSizeIn = input.float(0.0001, "Manual Pip / Point Size", minval=0.000001)
quoteToUsdIn = input.float(1.0, "Quote Currency to USD Rate (1 if quote is USD)", minval=0.000001)
minLot = input.float(0.01, "Minimum Lot Size", minval=0.001)
lotStep = input.float(0.01, "Lot Step", minval=0.001)
panelPosIn = input.string("Top Right", "Panel Position", options=["Top Right", "Bottom Right", "Top Left", "Bottom Left"])
showLines = input.bool(true, "Show Entry / SL / TP Lines")
showSourceRow = input.bool(false, "Show Source Row in Panel")
atr14 = ta.atr(14)
sym = str.upper(syminfo.ticker)
isGold = str.contains(sym, "XAU") or str.contains(sym, "GOLD")
isSilver = str.contains(sym, "XAG") or str.contains(sym, "SILVER")
isOil = str.contains(sym, "OIL") or str.contains(sym, "WTI") or str.contains(sym, "XTI") or str.contains(sym, "BRENT")
isCrypto = str.contains(sym, "BTC") or str.contains(sym, "ETH") or str.contains(sym, "SOL") or str.contains(sym, "LTC")
isIndex = str.contains(sym, "US30") or str.contains(sym, "DJ30") or str.contains(sym, "DJI") or str.contains(sym, "NAS100") or str.contains(sym, "US100") or str.contains(sym, "USTEC") or str.contains(sym, "NDX") or str.contains(sym, "SPX") or str.contains(sym, "US500") or str.contains(sym, "US2000") or str.contains(sym, "GER40") or str.contains(sym, "DAX") or str.contains(sym, "UK100") or str.contains(sym, "FRA40") or str.contains(sym, "JP225") or str.contains(sym, "AUS200")
isJpy = str.endswith(sym, "JPY")
isUsdBase = str.startswith(sym, "USD")
isUsdQuote = syminfo.currency == "USD" or syminfo.currency == "USDT" or syminfo.currency == "USDC"
autoContract = isGold ? 100.0 : isSilver ? 5000.0 : isOil ? 1000.0 : (isCrypto or isIndex) ? 1.0 : 100000.0
autoPip = isGold ? 0.1 : (isSilver or isOil or isJpy) ? 0.01 : (isCrypto or isIndex) ? 1.0 : 0.0001
autoRate = isUsdQuote ? 1.0 : (isUsdBase and close > 0.0) ? (1.0 / close) : quoteToUsdIn
contractSize = autoDetect ? autoContract : contractSizeIn
pipSize = autoDetect ? autoPip : pipSizeIn
quoteToUsdRate = autoDetect ? autoRate : quoteToUsdIn
entryPrice = entryPriceIn > 0.0 ? entryPriceIn : close
isAtrDefault = stopMode == "Pips / Points" and stopPipsIn <= 0.0
isLongDir = direction == "Long"
offChartEntry = entryPriceIn > 0.0 and close > 0.0 and (entryPriceIn > close * 1.35 or entryPriceIn < close * 0.65)
offChartStop = stopMode == "Custom Price" and customStopIn > 0.0 and close > 0.0 and (customStopIn > close * 1.35 or customStopIn < close * 0.65)
stalePrice = offChartEntry or offChartStop
rawDistPrice = stopPipsIn > 0.0 ? stopPipsIn * pipSize : math.max(pipSize, nz(atr14, pipSize * 10.0))
badPipsStop = stopMode == "Pips / Points" and isLongDir and rawDistPrice >= entryPrice
badRate = autoDetect and not isUsdQuote and not isUsdBase and quoteToUsdIn == 1.0
badStop = badPipsStop or (stopMode == "Custom Price" and (customStopIn <= 0.0 or (isLongDir ? customStopIn >= entryPrice : customStopIn <= entryPrice)))
errMsg = stalePrice ? "PRICE OFF CHART" : badRate ? "SET FX RATE" : badStop ? "CHECK STOP PRICE" : ""
stopPrice = stopMode == "Custom Price" ? customStopIn : (isLongDir ? entryPrice - rawDistPrice : entryPrice + rawDistPrice)
stopDistPrice = errMsg == "" ? math.abs(entryPrice - stopPrice) : 0.0
stopInUnits = pipSize > 0.0 ? stopDistPrice / pipSize : 0.0
// Exact pip/point dollar value per 1.00 lot = contractSize * pipSize * quoteToUsdRate
valuePerUnit1Lot = contractSize * pipSize * quoteToUsdRate
lossPer1Lot = errMsg != "" ? 0.0 : stopInUnits * valuePerUnit1Lot
minLotUse = autoDetect and isIndex ? math.max(minLot, 0.1) : minLot
lotStepUse = autoDetect and isIndex ? math.max(lotStep, 0.1) : lotStep
riskBudget = accountBalance * (riskPct / 100.0)
rawLots = lossPer1Lot > 0.0 ? riskBudget / lossPer1Lot : 0.0
// Floor strictly down to the instrument lot step (never round up)
flooredSteps = lotStepUse > 0.0 ? math.floor((rawLots + 1e-12) / lotStepUse) : 0.0
sizedLots = flooredSteps * lotStepUse
belowMin = sizedLots < minLotUse
displayLots = belowMin ? 0.0 : sizedLots
actualLoss = belowMin ? minLotUse * lossPer1Lot : displayLots * lossPer1Lot
dailyCap = accountBalance * (dailyLimitPct / 100.0)
dailyRoom = dailyLimitPct > 0.0 ? math.max(0.0, dailyCap + todayRealized) : 0.0
lossesFit = (errMsg == "" and not belowMin and actualLoss > 0.0 and dailyLimitPct > 0.0) ? math.max(0, math.floor((math.round(dailyRoom * 100.0) - 1) / math.max(1, math.round(actualLoss * 100.0)))) : 0
isOverDaily = errMsg == "" and dailyLimitPct > 0.0 and (math.round(actualLoss * 100.0) > math.round(dailyRoom * 100.0))
hitsDailyFloor = errMsg == "" and dailyLimitPct > 0.0 and not isOverDaily and lossesFit == 0
rawTp = isLongDir ? entryPrice + stopDistPrice * targetR : entryPrice - stopDistPrice * targetR
tpPrice = errMsg == "" and stopDistPrice > 0.0 and rawTp > 0.0 ? rawTp : na
var line entryLine = na
var line slLine = na
var line tpLine = na
var label entryLbl = na
var label slLbl = na
var label tpLbl = na
panelPos = panelPosIn == "Bottom Right" ? position.bottom_right : panelPosIn == "Top Left" ? position.top_left : panelPosIn == "Bottom Left" ? position.bottom_left : position.top_right
var table panel = table.new(panelPos, 2, showSourceRow ? 7 : 6, bgcolor=color.new(#08090d, 10), border_color=color.new(#ffffff, 75), border_width=1)
if barstate.islast
line.delete(entryLine)
line.delete(slLine)
line.delete(tpLine)
label.delete(entryLbl)
label.delete(slLbl)
label.delete(tpLbl)
leftBar = math.max(0, bar_index - 25)
rightBar = bar_index + 8
if showLines and errMsg == ""
entryLine := line.new(leftBar, entryPrice, rightBar, entryPrice, color=color.white, width=2, style=line.style_solid)
entryLbl := label.new(rightBar, entryPrice, "Entry " + str.tostring(entryPrice, format.mintick), style=label.style_label_left, color=color.new(#08090d, 15), textcolor=color.white, size=size.small)
slLine := line.new(leftBar, stopPrice, rightBar, stopPrice, color=#fb7185, width=2, style=line.style_dashed)
slLbl := label.new(rightBar, stopPrice, "SL (-$" + str.tostring(actualLoss, "0.00") + ")", style=label.style_label_left, color=color.new(#fb7185, 15), textcolor=color.white, size=size.small)
if not na(tpPrice)
tpLine := line.new(leftBar, tpPrice, rightBar, tpPrice, color=#34d399, width=1, style=line.style_dashed)
tpLbl := label.new(rightBar, tpPrice, "TP " + str.tostring(targetR, "#.##") + "R", style=label.style_label_left, color=color.new(#34d399, 15), textcolor=color.black, size=size.small)
dailyText = errMsg != "" or dailyLimitPct <= 0.0 ? "n/a" : isOverDaily ? "OVER DAILY LIMIT" : hitsDailyFloor ? "HITS DAILY LIMIT" : str.tostring(lossesFit) + " losses fit"
dailyColor = isOverDaily ? color.new(#fb7185, 0) : (errMsg != "" or hitsDailyFloor) ? color.new(#fbbf24, 0) : dailyLimitPct <= 0.0 ? color.new(#a1a1aa, 0) : color.new(#34d399, 0)
table.cell(panel, 0, 0, "Danel 1R Lot Size", text_color=color.new(#a1a1aa, 0), text_size=size.small)
table.cell(panel, 1, 0, errMsg != "" ? errMsg : belowMin ? "BELOW MIN" : str.tostring(displayLots, "0.00") + " lots", text_color=(errMsg != "" or belowMin) ? color.new(#fbbf24, 0) : color.white, text_size=size.normal)
table.cell(panel, 0, 1, "Stop distance", text_color=color.new(#a1a1aa, 0), text_size=size.small)
table.cell(panel, 1, 1, errMsg != "" ? "n/a" : str.tostring(stopInUnits, "#.#") + (isAtrDefault ? " pips (ATR)" : " pips/pts"), text_color=color.white, text_size=size.small)
table.cell(panel, 0, 2, belowMin ? "Min lot loss" : "Loss at stop", text_color=color.new(#a1a1aa, 0), text_size=size.small)
table.cell(panel, 1, 2, errMsg != "" ? "n/a" : "$" + str.tostring(actualLoss, "0.00"), text_color=belowMin ? color.new(#fbbf24, 0) : color.white, text_size=size.small)
table.cell(panel, 0, 3, "Risk cap (" + str.tostring(riskPct, "#.##") + "%)", text_color=color.new(#a1a1aa, 0), text_size=size.small)
table.cell(panel, 1, 3, "$" + str.tostring(riskBudget, "0.00"), text_color=color.white, text_size=size.small)
table.cell(panel, 0, 4, "Daily room check", text_color=color.new(#a1a1aa, 0), text_size=size.small)
table.cell(panel, 1, 4, dailyText, text_color=dailyColor, text_size=size.small)
specColor = (autoDetect and isIndex) ? color.new(#fbbf24, 0) : color.new(#a1a1aa, 0)
table.cell(panel, 0, 5, (autoDetect and isIndex) ? "Spec (check platform)" : "Spec", text_color=specColor, text_size=size.small)
table.cell(panel, 1, 5, sym + " (" + str.tostring(contractSize, "#") + " / " + str.tostring(pipSize) + ")", text_color=specColor, text_size=size.tiny)
if showSourceRow
table.cell(panel, 0, 6, "Source", text_color=color.new(#71717a, 0), text_size=size.tiny)
table.cell(panel, 1, 6, "danelresearch.com", text_color=color.new(#a1a1aa, 0), text_size=size.tiny)
| Scenario | Risk cap | Pine / site floored lot | Exact stop loss |
|---|---|---|---|
| EURUSD ($100k, 1%, 20 pips) | $1,000.00 | 5.00 | $1,000.00 |
| EURUSD ($10k, 1%, 28 pips) | $100.00 | 0.35 | $98.00 |
| XAUUSD ($10k, 1%, 100 pips) | $100.00 | 0.10 | $100.00 |
| US30 ($100k, 0.5%, 40 pts) | $500.00 | 12.50 | $500.00 |
Setup instructions and questions
Manually transcribing entry and stop distances from a candlestick chart into a separate browser tab costs execution speed on fast intraday sessions. This open Pine Script v6 indicator runs directly on any TradingView chart: after you click a stop price level on screen, it computes exact floored lot size, plots Entry, Stop Loss, and target multiple lines, and verifies how many identical stops fit inside a daily loss limit. Every formula mirrors our web engine's strict floor rounding, as shown in the parity table and the CHFJPY baseline notes ($100,000.00, 1%, 20 pips: 7.91 lots).
CHFJPY contract: 100,000 units per 1.00 lot. 1 pip = 0.01. A 0.01 lot is $0.0632 per pip, a 0.10 lot is $0.6317, and 1.00 lot is $6.3167. Values in USD use USD/JPY 158.31 on 2026-10-15. Minimum lot 0.01, step 0.01. The lot rounds down, so the loss at the stop stays at or under the risk when spread and commission are left at zero.
The risk table for CHFJPY uses stops of 18, 36, 72 pips. On $100,000.00 at 1% those three stops size 8.79 lots, $999.4315 at the stop; 4.39 lots, $998.2945 at the stop; 2.19 lots, $996.0205 at the stop.
| Spec | CHFJPY |
|---|---|
| Contract size | 100,000 units per 1.00 lot. |
| Pip definition | 1 pip = 0.01 |
| Value of 0.01 lot per pip | $0.0632 |
| Value of 0.10 lot per pip | $0.6317 |
| Value of 1.00 lot per pip | $6.3167 |
| Minimum lot | 0.01 |
| Lot step | 0.01 |
| USD rate used for this table | USD/JPY 158.31 on 2026-10-15 |
| CHFJPY | Account | Risk | 18 pips | 36 pips | 72 pips |
|---|---|---|---|---|---|
| CHFJPY | $5,000.00 | 0.5% ($25.00) | 0.21 lots, $23.8772 at the stop | 0.10 lots, $22.7402 at the stop | 0.05 lots, $22.7402 at the stop |
| CHFJPY | $5,000.00 | 1% ($50.00) | 0.43 lots, $48.8914 at the stop | 0.21 lots, $47.7544 at the stop | 0.10 lots, $45.4804 at the stop |
| CHFJPY | $5,000.00 | 2% ($100.00) | 0.87 lots, $98.9198 at the stop | 0.43 lots, $97.7828 at the stop | 0.21 lots, $95.5088 at the stop |
| CHFJPY | $10,000.00 | 0.5% ($50.00) | 0.43 lots, $48.8914 at the stop | 0.21 lots, $47.7544 at the stop | 0.10 lots, $45.4804 at the stop |
| CHFJPY | $10,000.00 | 1% ($100.00) | 0.87 lots, $98.9198 at the stop | 0.43 lots, $97.7828 at the stop | 0.21 lots, $95.5088 at the stop |
| CHFJPY | $10,000.00 | 2% ($200.00) | 1.75 lots, $198.9767 at the stop | 0.87 lots, $197.8397 at the stop | 0.43 lots, $195.5657 at the stop |
| CHFJPY | $25,000.00 | 0.5% ($125.00) | 1.09 lots, $123.9341 at the stop | 0.54 lots, $122.797 at the stop | 0.27 lots, $122.797 at the stop |
| CHFJPY | $25,000.00 | 1% ($250.00) | 2.19 lots, $249.0051 at the stop | 1.09 lots, $247.8681 at the stop | 0.54 lots, $245.5941 at the stop |
| CHFJPY | $25,000.00 | 2% ($500.00) | 4.39 lots, $499.1472 at the stop | 2.19 lots, $498.0102 at the stop | 1.09 lots, $495.7362 at the stop |
| CHFJPY | $50,000.00 | 0.5% ($250.00) | 2.19 lots, $249.0051 at the stop | 1.09 lots, $247.8681 at the stop | 0.54 lots, $245.5941 at the stop |
| CHFJPY | $50,000.00 | 1% ($500.00) | 4.39 lots, $499.1472 at the stop | 2.19 lots, $498.0102 at the stop | 1.09 lots, $495.7362 at the stop |
| CHFJPY | $50,000.00 | 2% ($1,000.00) | 8.79 lots, $999.4315 at the stop | 4.39 lots, $998.2945 at the stop | 2.19 lots, $996.0205 at the stop |
| CHFJPY | $100,000.00 | 0.5% ($500.00) | 4.39 lots, $499.1472 at the stop | 2.19 lots, $498.0102 at the stop | 1.09 lots, $495.7362 at the stop |
| CHFJPY | $100,000.00 | 1% ($1,000.00) | 8.79 lots, $999.4315 at the stop | 4.39 lots, $998.2945 at the stop | 2.19 lots, $996.0205 at the stop |
| CHFJPY | $100,000.00 | 2% ($2,000.00) | 17.59 lots, $2,000.00 at the stop | 8.79 lots, $1,998.863 at the stop | 4.39 lots, $1,996.589 at the stop |
Questions
Does the TradingView Pine v6 indicator match danelresearch.com lot sizes?
Yes. Both calculate value per unit and apply strict math.floor down to the lot step without rounding up. Appendix verifies CHFJPY across 18, 36, 72 pips (7.91 lots at 20).
How do I set my stop level on the chart after adding the script?
After clicking Add to chart in TradingView, click once on the chart where your Stop Loss belongs; Entry uses either live close or your optional manual entry input.
Does it work for XAUUSD, US30, and MNQ in TradingView?
Yes. Match Contract Size and Pip / Point Size in Settings on $100,000.00 (1% risk checks) to match your feed specifications.