Skip to content

How to make a pip-based input in TradingView's Pine Script?

How to make a pip-based input in TradingView’s Pine Script?

Section titled “How to make a pip-based input in TradingView’s Pine Script?”

TL;DR
Capture the pip distance with input.int, multiply it by syminfo.mintick (or pipSize() helper), and use the result as a raw price offset anywhere in your script.

DifficultyBeginner
Time to implement10-15 min
CategoryInputs
//@version=5
indicator("Pip input demo", overlay=true)
pips = input.int(5, "Band distance (pips)", minval=0)
pipSize = syminfo.mintick
pipRange = pips * pipSize
emaValue = ta.ema(close, 40)
upper = emaValue + pipRange
lower = emaValue - pipRange
plot(emaValue, "EMA", color=color.orange)
plot(upper, "Upper", color=color.new(color.orange, 0))
plot(lower, "Lower", color=color.new(color.orange, 0))
Tip. `syminfo.mintick` equals one pip for FX pairs, including fractional pips. If you need 10-pip increments by default, multiply the input by 10 before converting.

Pip-based distances feel natural to FX traders, but TradingView scripts operate in absolute price units. Converting pips inside Pine keeps your logic chart-agnostic—no more hard-coded 0.0010 offsets for EURUSD or 0.10 for USDJPY. Users set the pip value once and the script adapts per symbol.

  • Create integer inputs that represent pip distances.
  • Convert pip counts to on-chart price values via syminfo.mintick or custom helpers.
  • Apply the result to bands, stops/targets, and label placement.
  • Present inputs with tooltips and groups so traders understand the unit.
CallPurpose
input.int(defval, title, minval, step)Captures the pip count.
syminfo.mintickReturns the instrument’s minimum price movement (pip size).
strategy.position_avg_priceBase price to apply pip offsets for stops/targets.
plot(series)Visualise pip-derived bands or markers.
strategy.exit(..., stop=price)Submit orders using the converted pip value.
  1. Provide the pip input
    Ask for pips in integers (or floats if you need decimals) and explain the unit in the tooltip.

    pipCount = input.int(10, "Stop distance (pips)", minval=0, tooltip="Input measured in pips relative to current instrument")
  2. Translate pips to price
    Multiply by syminfo.mintick or a helper that handles special cases.

    pipToPrice(int pips) => pips * syminfo.mintick
    stopOffset = pipToPrice(pipCount)
  3. Use the converted value
    Apply the price offset in plots, labels, or order placement.

    upperBand = emaValue + stopOffset
    lowerBand = emaValue - stopOffset
    strategy.exit("Long SL", from_entry="Long", stop=strategy.position_avg_price - stopOffset)
//@version=5
strategy("Pip-aware breakout", overlay=true, initial_capital=25_000)
pipInput = input.int(12, "Stop distance (pips)", minval=1)
targetInput = input.int(24, "Target distance (pips)", minval=1)
len = input.int(20, "Breakout length", minval=2)
pipSize = syminfo.mintick
stopOffset = pipInput * pipSize
targetOffset = targetInput * pipSize
highestHigh = ta.highest(high, len)
lowestLow = ta.lowest(low, len)
longSignal = ta.crossover(high, highestHigh)
shortSignal = ta.crossunder(low, lowestLow)
if longSignal
strategy.entry("Long", strategy.long)
strategy.exit("Long SL", from_entry="Long", stop=strategy.position_avg_price - stopOffset, limit=strategy.position_avg_price + targetOffset)
if shortSignal
strategy.entry("Short", strategy.short)
strategy.exit("Short SL", from_entry="Short", stop=strategy.position_avg_price + stopOffset, limit=strategy.position_avg_price - targetOffset)
plot(highestHigh, "Breakout high", color=color.new(color.green, 40))
plot(lowestLow, "Breakout low", color=color.new(color.red, 40))
labelColor = input.color(color.new(color.blue, 70), "Label colour")
if barstate.isconfirmed and (longSignal or shortSignal)
dir = longSignal ? "Long" : "Short"
text = dir + " (+" + str.tostring(targetInput) + " / -" + str.tostring(pipInput) + " pips)"
label.new(bar_index, close, text, textcolor=color.white, bgcolor=labelColor)
Why this works.
  • The script converts pip distances once, ensuring stops/targets align with the chart’s tick size.
  • Users adjust pip-based risk without touching price math.
  • Labels reinforce the actual pip distances applied so settings stay transparent.
  • Some brokers quote symbols in fractional pips. syminfo.mintick already reflects that—no extra scaling needed.
  • For metals or indices, rename the input (e.g., “Point distance”) or compute pip size manually if the symbol does not follow FX conventions.
  • Guard against zero pip distance (minval=1) to avoid stop prices equal to the entry.
  • Offer separate inputs for stop and target so traders can configure asymmetric reward/risk ratios.

The converted price looks tiny on cryptocurrencies

Section titled “The converted price looks tiny on cryptocurrencies”

Crypto tick sizes can be much smaller than FX pips. Consider renaming the input to “tick distance” or exposing a multiplier for non-FX charts.

How do I show the price equivalent to the user?

Section titled “How do I show the price equivalent to the user?”

Add a label or plotchar: label.new(bar_index, close, str.tostring(pipCount) + " pips → " + str.tostring(stopOffset, format.price)).

Switch to input.float and multiply by pipSize the same way. Provide a step=0.1 if you want 0.1-pip granularity.

  • Use integer (or float) inputs to collect pip distances and multiply by syminfo.mintick for price units.
  • The resulting price offset adapts automatically per instrument, keeping scripts portable across symbols.
  • Apply the converted value to indicators, stops, and labels for consistent pip-based behaviour.
  • Document the unit in tooltips so users know exactly what they are adjusting.

Adapted from tradingcode.net, optimised for Algo Trade Analytics users.