RealTest User Guide
RealTest User Guide

 

 

Navigation: RealTest Script Language > Syntax Element Details >

InitialRisk (definition)

 

 

 

 

Category

Strategy Elements

Description

Defines the initial risk ("1R") of each trade, per share or contract, in price points

Input

Any formula specifying a price distance

Notes

Typical formulas are 2 * ATR(14), FillPrice - stop_price or 3 * StdDev(C, 20). The sign is ignored, so FillPrice - stop_price works for both long and short positions; the saved value is always positive.

It is evaluated in the same context as Quantity: on the setup bar, with FillPrice equal to the entry order price (for a market entry, the setup bar's close -- the no-gap assumption orders are sized on) unless QtyPrice is FillPrice. So 1R is the risk planned when the order was sized.

When the strategy specifies Side (Long or Short), InitialRisk is evaluated just before Quantity, so a risk-based Quantity can use it directly: Quantity: S.Alloc * 0.01 / (InitialRisk * PointValue) with QtyType: Shares risks 1% of the strategy's allocation per trade. InitialRisk cannot use Shares, which is not known yet at that point. Without a Side, Quantity is evaluated first, because the sign of its result decides the side, so Quantity cannot use InitialRisk (a parse error); InitialRisk is then evaluated once the entry order is priced, still with FillPrice and Side available.

RealTest applies the quantity, point value and exchange rate: T.RiskAmt is the trade's total amount at risk, and T.RMult its net profit in units of that risk (its "R multiple"). T.Risk returns the value itself.

While the position is open, the InitialRisk property returns the value, so stops and targets can be written in R:

ExitStop: FillPrice - InitialRisk
ExitLimit: FillPrice + 2 * InitialRisk

Trade Analysis Plots can show trades in R (the R Multiple trade value), and Trade Statistics Functions such as TradeStatAvg(T.RMult) (expectancy in R) skip trades that have no InitialRisk.

Unlike EntryTradeValue, which saves any value for any purpose, InitialRisk has a fixed meaning, which is what lets RealTest compute R multiples. EntryTradeValue and T.ValueIn remain free for other uses.

Example

From the futures_trend_follow_csi.rts example, where the position size is based on the same distance (both of its strategies specify Side, so Quantity can use InitialRisk):

Data:
    StopPts: Min(BreakHigh - BreakLow, NStopPts) // points from the breakout close to the initial stop
Template: common
    InitialRisk: StopPts
    Quantity: PctRisk / 100 * S.Alloc / (InitialRisk * PointValue)

 

 

 

 

Copyright © 2020-2026 Systematic Solutions, LLC