# Trade parameters 3 - investment control

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

## Lots

Trade size given by the number of lots per trade (default = 1; max = 99999). This is the unit used for sending orders to the broker. One lot is the smallest possible order unit of the active account (see remarks). In binary trading mode (BINARY flag) or if Margin or Risk are 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. If Lots is -1, trades are executed in phantom mode (see below); they are only simulated, but not sent to the broker.

## Margin

Trade size given by invested margin per trade, in units of the account currency (default = 0.0001 for always opening at least 1 lot). In binary trading mode (BINARY flag) or with no leverage, Margin is simply the money invested per trade. 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 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

Trade size given by the trade risk in units of the account currency (default = 0 = no risk limit). The risk is the maximum amount 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, this 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 size is accordingly reduced. Due to slippage and minimum lot amount, a trade can still lose more than Risk. When the RISKLIMIT flags is set, trades are skipped when even with the minimum amount (1 lot) the trade risk is still higher than twice the given Risk value.

## Capital

Initial invested capital in units of the account currency (default = 0 = no initial capital). This has no effect on trading, but on the 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 and determines performance parameters from the invested capital instead of the required capital. If drawdown plus margin exceeds Capital, Zorro will declare a Margin Call and abort the simulation. Thus make sure to set Capital well above the required capital without reinvestment, and to limit reinvestment so that negative equity is avoided.

var

### Remarks:

• Lot can have different meanings in the trade context. Normally one lot is the smallest order unit; the trade size is always a multiple of 1 lot and can never be less than 1 lot. The lot amount - the number of contracts equivalent to one lot - depends on the broker, the account, and the asset type. Forex brokers often offer mini lot and micro lot accounts. One mini lot is equivalent to 10,000 contracts and about ~50 EUR margin; and one micro lot is 1000 contracts and ~5 EUR margin. On stock broker accounts accounts the lot amounts and margins are usually higher and the leverage is smaller. For indexes, commodities, and CFDs, some brokers offer lot sizes that are a fraction of one contract (f.i.1 lot = 0.1 contracts). Some brokers require a minimum order size of more than one lot, f.i.10 lots. The broker normally displays his trade parameters on his website or in his trading platform, so the lot amount per asset is always available.
• In some platforms, lot has a special meaning. 1 "Lot" in the MT4™ platform is equivalent to 100 micro lots. MT4 lots can be converted to broker lots with the script command Lots = MT4Lots * 100000/LotAmount.
• The margin per lot can be determined with the MarginCost variable. The number of contracts per lot can be determined with the LotAmount variable. The risk of a trade - the maximum possible loss at a given Stop distance - is Lots * (Stop/PIP) * PIPCost. The number of lots equivalent to a given margin is (Margin/MarginCost).
• Margin, Risk and Lots must be set before calling enterLong / enterShort.
• Margin, Risk or Lots could be set up in real time with a slider (see script example). This would allow to quickly adapt the trade risk to the market situation, or to disable trades temporarily when you hear of a market crash. The number of lots, the current price, and the real risk is displayed in Zorro's message window when an order is placed (see Trading).
• [Train] mode always uses 1 lot for training parameters or rules, regardless of the setting of Margin, Risk and Lots. When Margin or Lots are zero, no trade is opened.
• Because orders can only be placed in a multiples of one lot, the actual margin can be bigger or smaller than the given Margin value. When the MARGINLIMIT flag is set, trades are not executed when the required margin is more than twice the Margin value; increasing Margin will then increase both the trade size and the number of trades, while increasing Lots only increases the trade size.
• Phantom trades are simulated trades that are not sent to the broker. The win or loss of a phantom trade is calculated from the price curve and contributes to the Short/Long statistics, but not to the Total statistics. This way the performances of phantom and real trades can be evaluated separately. Phantom trades are normally used for "Equity Curve Trading" (see below) - they test the market and determine if a certain strategy is currently profitable or not. As long as the equity curve is below a certain level, real trades are replaced by phantom trades. Phantom trades are also used for "Virtual Hedging" (see Hedge) - combining long and short positions in a way that market exposure is minimized and only net positions are sent to the broker.
• The Capital variable is used for determining the effectivity of the reinvestment algorithm. It calculates performance parameters based on the given capital, not on the equity curve, and thus ignores the setting of the Monte Carlo Confidence level.
• In [Train] mode, trades always open 1 lot, and phantom trades are converted to normal trades. This behavior can be modified with the Optimize variable.

### Equity curve trading

Equity curve trading is a method of avoiding losses by detecting and skipping unfavourable market periods or the expiration of strategies. The system monitors the equity curve separately for any asset and algorithm of the strategy. When unusual losses are recognized, real trading with that component is automatically suspended and all future trades are simulated in phantom mode (see above). The results of the phantom trades are still recorded in the equity curve as if they were real trades. But no money is invested until the equity curve shows that the market became profitable again.

Many methods can be used for determining if the market it profitable or not. In the example below, the equity curve is permanently compared with its own long-term average by lowpass filtering. It the equity is below average and still falling, trading switches to phantom mode; it goes back to normal as soon as the equity curve is rising again. Other methods may be based on the balance instead of the equity curve, or on the ratio of winning to losing trades.

Equity curve trading is not a 'holy grail'. It does not improve the performance when there is no clear distinction between profitable and unprofitable market periods. But it can often reduce the risk of a system. An example of a system that suddenly became unprofitable is the 'Luxor' strategy in the script examples; here equity curve trading would have drastically improved the overall result. According to our experience, equity curve trading is recommended especially for systems that use many algorithms for distributing risk (such as Zorro's Z1, Z2, and Z12). It does not make much difference in backtests, but it can make a large difference in live trading.

### Examples:

```// set margin from slider
Margin = slider(1,500,0,2000,"Margin","Average margin in \$");if(Margin > 0) Lots = 1; else Lots = 0; // don't trade when slider is set to 0```
```// equity curve trading: switch to phantom mode when the equity
// curve goes down and is below its own lowpass filtered value
function checkEquity()
{
if(Train) { Lots = 1; return; } // no phantom trades in training mode
vars EquityCurve = series(ProfitClosed+ProfitOpen);
vars EquityLP = series(LowPass(EquityCurve,10));
if(EquityLP[0] < LowPass(EquityLP,100) && falling(EquityLP))
Lots = -1; // drawdown -> phantom trading
else
Lots = 1; // profitable -> normal trading
}```

### See also:

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