ProBacktest/probacktest · proorder

PPROFIT

PPROFIT sets a take profit a fixed number of points from the average position price in ProBacktest and ProOrder, written as SET TARGET PPROFIT x in a strategy.

Syntax

probuilder
SET TARGET PPROFIT x

Parameters

NameTypeDefaultDescription
xinteger or numeric expressionrequiredDistance in points between the average position price and the take-profit level.

How it works

When the instruction executes, the strategy registers a take-profit level x points on the winning side of the average position price, above the entry for a long and below it for a short. When price reaches the level, the position closes and the gain is realized.

The distance is anchored to POSITIONPRICE, the average entry price of the whole position. If the strategy adds contracts to an open position, the average shifts and the target level shifts with it, which changes where the exit sits relative to each individual fill.

A SET TARGET command remains active until replaced, so it does not need to be repeated every bar. All target variants share one internal slot: calling SET TARGET PPROFIT after SET TARGET %PROFIT, SET TARGET $PROFIT, or SET TARGET BREAKEVEN overwrites the earlier setting, and only the most recent call counts.

Examples

Example 1, MACD entry with a 50-point target (ProOrder)

probuilder
myMACD = MACD[12,26,9](close)
long = myMACD CROSSES OVER 0

IF NOT LongOnMarket AND long THEN
  BUY 1 CONTRACTS AT MARKET
ENDIF

// Take profit 50 points above the average position price
SET TARGET PPROFIT 50

A long opens when the MACD crosses above zero, and the trade closes automatically once price is 50 points above the average entry. This is the reference example from the source documentation with rewritten comments.

Example 2, Point-based target on a short position (ProBacktest)

probuilder
short = close CROSSES UNDER average[100](close)

IF NOT shortonmarket AND short THEN
  SELLSHORT 1 CONTRACTS AT MARKET
ENDIF

// Take profit 40 points below the average short entry price
SET TARGET PPROFIT 40

For a short position the same instruction places the target on the profitable side below the entry, closing the trade after a 40-point decline.

Example 3, ATR-scaled bracket of target and stop (ProOrder)

probuilder
// Derive both exit distances from volatility, in whole points
atr = AverageTrueRange[14](close)
targetPoints = max(10, round((3 * atr) / pointsize))
stopPoints = max(5, round((1.5 * atr) / pointsize))

IF NOT onmarket AND close > highest[20](high[1]) THEN
  BUY 1 CONTRACTS AT MARKET
ENDIF

SET TARGET PPROFIT targetPoints
SET STOP PLOSS stopPoints

The target sits three ATRs away and the stop one and a half, a fixed two-to-one geometry that adapts its absolute size to current volatility.

Common errors and gotchas

  • Anchored to the average, not the last fill. After pyramiding or averaging, the target is measured from the updated POSITIONPRICE. Individual entries can therefore exit closer to or further from their own fill price than x points.
  • One target slot. PPROFIT, %PROFIT, $PROFIT, and SET TARGET BREAKEVEN overwrite each other. Only the most recent SET TARGET call is active, so mixing variants bar by bar produces unstable exits.
  • Points are not cash or percent. x is a point count. A percentage objective belongs in SET TARGET %PROFIT, a cash objective in SET TARGET $PROFIT. Feeding a cash figure to PPROFIT misplaces the level by the instrument's point value.
  • Touch equals fill only in backtests. ProBacktest assumes the target fills the moment price touches the level. Live, a limit at the extreme of a move may not execute, so tested results overstate fill quality on thin markets.
  • %PROFIT, take profit as a percentage of the position price.
  • $PROFIT, take profit as a cash amount.
  • PLOSS, stop loss in points, the mirror instruction.
  • %LOSS, stop loss as a percentage.
  • BREAKEVEN, moves the stop or target to the entry price.
  • TARGET, overview of the target instruction family.
  • POSITIONPRICE, the average entry price the distance is measured from.
  • POINTSIZE, the size of one point in price units.