Trade parameters 3 - investment control

The trade size - the number of contracts or currency units purchased - can be determined in four different ways. For directly ordering a certain number of contracts, use Amount or Lots. For investing a certain sum of money, use Margin. For risking a certain sum of money by determining the worst case loss, use Risk.

Lots

Trade size given by the number of lots (default = 1; max = LotLimit). 1 lot is defined as the smallest possible order size of the selected broker and account. Thus, a lot can mean different amounts dependent on the broker, and the trade size can never be less than 1 lot (see remarks). In binary trading mode (BINARY flag) or if Margin is used for calculating the trade size, Lots determines the minimum number of lots to be opened per trade (normally 1). If Lots is 0, no trades are opened.

Amount

Alternative trade size in multiples of 100,000 units for currencies, and in multiples of 1 contract for anything else (default = 0 = trade size given by Lots). This number is independent of the broker's minimum order size and similar to a 'MT4 lot' for currencies (see remarks). Fractional amounts are possible. If a nonzero Amount amounts to less than one lot, 1 lot is opened.

Margin

Alternative trade size by invested margin, in units of the account currency (default = 0.00000001 for always opening at least 1 lot). With no leverage, Margin is simply the money invested to purchase the asset. On a leveraged account, Margin is a fixed part of the real trade size - for instance 1% at 1:100 leverage - that the broker keeps as a deposit for opening a trade. As long as the trade is open, the margin amount is locked on the account and can not be used for further trades (of course the loss of a trade can be higher than the margin). If Margin is 0 or negative, no trades are opened. Otherwise the trade size is calculated from the given margin.
  The Lots variable still determines the minimum number of lots to be opened per trade. If the trade size by Margin is lower than Lots and the MARGINLIMIT flag is set, trades are skipped. If the ACCUMULATE flag is set, the size of skipped trades is accumulated until it reaches the Lots amount. Keep Margin at its default value for controlling the number of lots only with the Lots variable.

Risk

Alternative trade size given by the trade risk in units of the account currency (default = 0 = no risk limit). The risk is the theoretical maximum that a trade can lose; it is determined from trade size, stop loss distance, commission, and spread. Since risk is undefined when a trade has no stop loss, the Risk parameter must always be given in combination with Stop. If the risk of a trade at the given Margin is higher than the Risk variable, the trade margin is accordingly reduced.
  When the RISKLIMIT flags is set, trades are skipped when even with a trade size of 1 lot the trade risk is still higher than twice the given Risk value. When Margin is not set, the trade size is only limited by Risk; this can lead to extreme trade sizes and subsequent margin calls when the Stop distance is tight. Due to slippage and minimum lot amount, the displayed risk in the trade log can deviate from the set up Risk value especially with tight Stop distances. A stopped out trade can lose less or more than Risk.

Capital

Initial invested capital in units of the account currency (default = 0 = no initial capital). This has no direct effect on trading, but on calculating the strategy performance in the simulation. Set this to the initial capital when the strategy reinvests profits; Zorro then calculates CAGR instead of AR/ROI and determines performance parameters from the initial invested capital instead of the required capital. If drawdown plus required margin exceeds Capital on leveraged accounts, Zorro will declare a Margin Call and abort the simulation. Make sure to set Capital well above the required capital on leveraged accounts, and to limit reinvestment so that negative equity is avoided. Setting Capital to a negative amount prevents margin call detection and allows to continue the backtest even with negative free capital. 

Type:

var
 

MaxLong

MaxShort

Maximum number of open long and short trades with the same asset and algo. If this limit is reached in [Test] or [Trade] mode, enter calls do not open more trades, but they still close reverse positions and update the stop limits, profit targets, and life times of open trades to the values that the new trade would have. 

Type:

int
 

Remarks:

Examples:

// set margin from slider
Margin = slider(1,500,0,2000,"Margin","Average margin in $");

See also:

enterLong/Short, Stop, Spread, PIP, PIPCost, MarginCost, Win/LossPayout, TradeMode

 

► latest version online