ProBacktest/probacktest · proorder

PIPVALUE

PIPVALUE returns the monetary value of one pip for the current instrument in ProBacktest and ProOrder. A synonym of POINTVALUE, used in position sizing.

Syntax

probuilder
PIPVALUE

How it works

PIPVALUE is a read-only market constant. It takes no arguments and returns the amount of money, in the instrument's currency, that one pip of price movement represents for a single contract, lot, or share of the instrument the strategy is attached to. In ProBuilder terminology PIPVALUE and POINTVALUE refer to the same value, so the two keywords are interchangeable.

The value is set by the instrument's contract specification, not by the code. A pip on a forex pair, an index CFD, and a commodity future can each be worth a very different cash amount, so any strategy that hardcodes a pip value breaks as soon as it runs on another market. Reading PIPVALUE at runtime keeps sizing and profit calculations portable.

PIPVALUE is usually combined with PIPSIZE or POINTSIZE. PIPSIZE expresses how large one pip is in price units, while PIPVALUE expresses what that move is worth in cash. Dividing a price distance by PIPSIZE yields a pip count, and multiplying the pip count by PIPVALUE converts it into money.

Examples

Example 1, Inspect the pip value of an instrument (ProBacktest)

probuilder
// Read the cash value of one pip and plot it during a backtest
myPipValue = PipValue
GRAPH myPipValue AS "Value of one pip for this instrument"

Runs a backtest whose only purpose is to display the instrument's pip value in the graph panel, a quick way to verify the contract specification before writing sizing logic.

Example 2, Risk-based position sizing (ProOrder)

probuilder
// Risk a fixed cash amount per trade
riskCash = 200
stopPips = 30

// Cash at risk for one contract over the stop distance
riskPerContract = stopPips * pipvalue
positionSize = max(1, floor(riskCash / riskPerContract))

IF NOT onmarket AND close CROSSES OVER average[50](close) THEN
  BUY positionSize CONTRACTS AT MARKET
ENDIF

// Pip and point coincide on this instrument
SET STOP PLOSS stopPips

The number of contracts is derived from the cash risk budget divided by the cash risk of one contract, so the same code risks roughly the same amount on any instrument.

Example 3, Floating profit in account currency (ProBacktest)

probuilder
// Unrealized profit of the open position, converted to cash
IF onmarket THEN
  floatingProfit = ((close - positionprice) / pipsize) * pipvalue * countofposition
ELSE
  floatingProfit = 0
ENDIF
GRAPH floatingProfit AS "Floating profit"

The price distance from the average entry is turned into a pip count with PIPSIZE, then into cash with PIPVALUE, and finally scaled by the position size. COUNTOFPOSITION is negative for shorts, which gives the sign automatically.

Common errors and gotchas

  • Confusing PIPVALUE with PIPSIZE. PIPSIZE is a distance in price units, PIPVALUE is a cash amount. Mixing them up produces sizing errors of several orders of magnitude. Distance divided by PIPSIZE gives pips, pips multiplied by PIPVALUE gives cash.
  • Hardcoding the value. A pip value copied from one instrument's specification is wrong on the next instrument. Read PIPVALUE at runtime instead of embedding a number.
  • Forgetting the position size. PIPVALUE is quoted per single contract or lot. Cash exposure of the whole position requires multiplying by COUNTOFPOSITION or the intended order size.
  • Using it outside a strategy. The keyword only compiles in ProBacktest and ProOrder code. In an indicator or screener the compiler rejects it, so pip-based indicator logic must use fixed inputs instead.
  • POINTVALUE, synonym of PIPVALUE, the cash value of one point.
  • PIPSIZE, the size of one pip in price units.
  • POINTSIZE, the size of one point in price units.
  • TICKSIZE, the smallest tradable price increment.
  • COUNTOFPOSITION, the signed size of the open position.
  • POSITIONPRICE, the average entry price of the open position.
  • STRATEGYPROFIT, realized profit of the strategy in cash.
  • GRAPH, plots a value in the backtest graph panel.