ProBacktest/probacktest · proorder

$PROFIT

The $PROFIT instruction sets a take profit target as a fixed money amount in the instrument currency with SET TARGET $PROFIT in ProBacktest and ProOrder.

Syntax

probuilder
SET TARGET $PROFIT x

Parameters

NameTypeDefaultDescription
xnumericnoneProfit at which the position closes, expressed in the currency of the traded instrument.

How it works

$PROFIT combines with SET TARGET only. The instruction states the exit as a monetary outcome: once the unrealized profit on the position reaches x currency units, the platform closes it. The money amount is converted into a price level using the position size and the instrument's point value, so a larger position reaches the same money target with a smaller price move.

The setting is persistent. After it executes, it applies to the current position and to every future position until another SET TARGET call replaces it. SET TARGET $PROFIT 0 cancels the target. Strategies usually place the call once, unconditionally, near the end of the code.

On IG and PRT-CFD accounts the target is attached to each individual order, so with cumulated orders each order exits at its own computed level.

The stop-side counterpart is SET STOP $LOSS. A stop deliberately placed in the profit zone is the inverted form documented under Set Stop Profit.

Examples

Example 1, MACD entry with a 100 currency-unit 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 the profit once the position has gained 100
SET TARGET $PROFIT 100

The strategy buys on a MACD cross above zero and exits automatically once the open profit reaches 100 currency units.

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

probuilder
resistance = Highest[20](high)
IF NOT ShortOnMarket AND close crosses under Average[50](close) THEN
    SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Same instruction for shorts, the platform places the exit below entry
SET TARGET $PROFIT 80

For a short position the exit level is computed below the entry price so the trade closes after an 80 currency-unit gain.

Example 3, Money bracket sized from a fixed risk budget (ProOrder)

probuilder
DEFPARAM CumulateOrders = false

// Trade plan in money: risk 50 to make 150
riskAmount   = 50
rewardAmount = 3 * riskAmount

IF NOT OnMarket AND RSI[14](close) crosses over 50 THEN
    BUY 1 CONTRACT AT MARKET
ENDIF

SET STOP $LOSS riskAmount
SET TARGET $PROFIT rewardAmount

Both sides of the bracket accept variables, so the risk-reward relationship can be written once and reused. Here the trade risks 50 to make 150.

Common errors and gotchas

  • Wrong SET pairing. $PROFIT is documented with SET TARGET. The money-based stop is SET STOP $LOSS. Attaching $PROFIT to SET STOP belongs to the inverted forms and places the exit on the other side of the entry.
  • Position size changes the price distance. The same x on twice the contracts means half the price move to reach the target. After editing sizing logic, verify that the implied exit is not inside the spread.
  • Instrument currency, not account currency. The amount is measured in the currency the instrument trades in. Cross-currency accounts realize a slightly different amount depending on the exchange rate at exit.
  • Shared target slot. $PROFIT, %PROFIT, PPROFIT and SET TARGET BREAKEVEN write to the same internal target; the most recent SET TARGET call wins. Re-arming with different values per bar reprices the exit silently.
  • %PROFIT, take profit as a percentage of the position price.
  • PPROFIT, take profit as a distance in points.
  • $LOSS, stop loss as a fixed money amount.
  • $TRAILING, trailing stop as a fixed money amount.
  • 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.
  • POINTVALUE, currency value of one point, used in money-to-price conversion.
  • LONGONMARKET, true while a long position is open.