ProBacktest/probacktest · proorder

%PROFIT

The %PROFIT instruction sets a take profit target as a percentage above the average position price with SET TARGET %PROFIT in ProBacktest and ProOrder.

Syntax

probuilder
SET TARGET %PROFIT x

Parameters

NameTypeDefaultDescription
xnumericnonePercentage distance from the average position price at which the take profit triggers. Decimals are allowed, so 0.75 means 0.75 percent.

How it works

%PROFIT combines with SET TARGET only. The instruction defines a profit target as a relative distance from the average position price: a long position closes once price has gained x percent, a short position closes once price has fallen x percent. Because the level is relative, the code works unchanged across instruments trading at very different price levels.

The setting is persistent. After the line executes, every current and future position carries the same percent target until another SET TARGET call replaces it, and SET TARGET %PROFIT 0 cancels it. The usual pattern is a single unconditional call near the end of the strategy code.

The target is recalculated per position from its average price, so when several orders are cumulated the exit level reflects the blended entry. On IG and PRT-CFD accounts the platform attaches the target to each individual order instead.

The stop-side counterpart is SET STOP %LOSS. A target placed below the entry, used to escape a losing trade, is the inverted form documented under Set Target Loss, and a stop placed in the profit zone is documented under Set Stop Profit.

Examples

Example 1, MACD entry with a 2 percent target (ProBacktest)

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 2 percent above the average position price
SET TARGET %PROFIT 2

The strategy buys on a MACD cross above zero and exits automatically once the position shows a 2 percent gain on price.

Example 2, Percent target on a short position (ProOrder)

probuilder
fast = Average[10](close)
slow = Average[40](close)
IF NOT ShortOnMarket AND fast crosses under slow THEN
    SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// For a short the target sits 1.2 percent BELOW the position price
SET TARGET %PROFIT 1.2

The same instruction serves short positions. The platform places the exit on the profitable side automatically, so the code needs no sign handling.

Example 3, Asymmetric percent bracket (ProOrder)

probuilder
DEFPARAM CumulateOrders = false

bandLow = BollingerDown[20](close)
IF NOT OnMarket AND close crosses under bandLow THEN
    BUY 1 CONTRACT AT MARKET
ENDIF

// Tight stop, wider target, a 1:3 relationship in percent terms
SET STOP %LOSS 0.5
SET TARGET %PROFIT 1.5

Pairing SET TARGET %PROFIT with SET STOP %LOSS produces a complete percent-based bracket whose absolute size scales with the instrument price.

Common errors and gotchas

  • Percent of price, not of account. A %PROFIT value of 2 exits after a 2 percent move in price. With leverage the effect on equity is a multiple of that. Position sizing has to be handled separately.
  • Wrong SET pairing. %PROFIT is documented with SET TARGET. The stop-side percent instruction is SET STOP %LOSS. Swapping them produces an exit on the wrong side of the entry or a compile error on older platform versions.
  • Last SET TARGET wins. %PROFIT, $PROFIT, PPROFIT and SET TARGET BREAKEVEN share one internal target slot. The most recent call replaces any earlier value, so conditional re-arming inside per-bar logic can silently reprice the exit.
  • Small percentages on slow instruments. A very tight value such as 0.1 may resolve to less than one tick on low-priced instruments, in which case the order is rejected or filled immediately. Check the tick size before using sub-percent targets.
  • $PROFIT, take profit as a fixed money amount.
  • PPROFIT, take profit as a distance in points.
  • %LOSS, stop loss as a percentage of the position price.
  • %TRAILING, trailing stop as a percentage of the position price.
  • BREAKEVEN, moves the stop or target to the entry price.
  • TARGET, pending target orders and the SET TARGET family.
  • Set Stop Profit, stop placed in the profit zone, the inverted form.
  • TRADEPRICE, entry price of a given trade.
  • POSITIONPRICE, average price of the open position.
  • LONGONMARKET, true while a long position is open.