Asset parameters 1 - transaction costs
Difference between the ask and bid price of the current asset (default taken from AssetsFix.csv when offline, current real spread when connected to a broker). The trade profit is reduced by this amount. Spread is ignored in binary trading mode (BINARY flag).
Simulated extra slippage in seconds (default = 5), used in [Test] mode only. In Fill modes above 0, slippage is simulated by filling or closing orders not at the current price, but at a price expected after the given number of seconds. The
price is extrapolated from the current trend and volatility by the direction and length of the
current candle. For instance, with 1-minute bars and Slippage at 15, the order is filled at a price
expected within the first quarter of the next bar. The larger the Slippage variable, the larger is the price range and thus the deviation of the fill or close price from the current price. For hitting entry, stop, or takeprofit limits, slippage is simulated by taking a price from the current tick range, regardless of the Slippage variable.
Extra slippage has normally a negative effect on systems that go with the trend and can noticeably reduce the profit especially on short time frames. But slippage can also be in favor of the trader, especially with counter-trend or mean-reversion systems. It is recommended to test systems with and without slippage for determining its effect on the result. Slippage at 0 disables extra slippage, but entry, stop, or takeprofit limits still cause slippage unless Fill is set to NAIVE. Setting Slippage to a negative amount simulates asymmetric slippage that is always in adverse direction. Some trading platforms allow the broker to automatically apply asymmetric slippage for reducing the win chance of their clients.
Slippage has no effect on training.
Broker's fee for opening and closing a trade, taken from the
asset list, in account currency units per 10000 contracts for currencies,
or per contract for all other assets, or as a percent value when negative. The trade profit is reduced by this amount
when the position is closed.
Commission is automatically reduced by 50% for expired options (since fees are usually not charged for expiration), and
is initialized to zero in binary trading mode (since binary brokers get their commission via payout, see below). When set in the script, it must be set individually for every traded asset.
Commission is equivalent to an additional spread with a size in pips of Commission*LotAmount/10000/PIPCost for currencies, and Commission*LotAmount/PIPCost for all other assets.
If a negative percent value is given (f.i. -0.25 for 0.25%),
the commission of a trade is Percent/100 * PIPCost/PIP * Price * Lots *
Daily rollover interest (also called 'swap') per 10000 contracts for currencies, or per contract for all other assets. Taken from the assets list when offline, otherwise the broker's current rollover value is used
when provided by the API. The rollover is daily interest paid to or received from the broker for
borrowing or lending margin. For instance, when you hold a EUR/USD long position, you receive interest from the broker for
lending the EUR and pay interest for borrowing the USD - the difference is the rollover. Negative rollover contributes to the losses, positive rollover to the profits. As to be expected, negative rollover values are more frequent and greater than positive rollover values. For CFDs, rollover is usually trend compensating - for instance, upwards trending index CFDs get a negative RollLong for eliminating long-term trend profit. Rollover can
affect the performance of long-term strategies and cause an asymmetry between long and short trades when positions are hold for several weeks.
Payout in percent of the invested Margin for binary trading (set(BINARY)). Winning trades win the invested amount plus the WinPayout, losing trades lose the invested amount minus the LossPayout. The payout variables must be set individually for every traded asset. Spread and Commission should be set to 0 for normal binary trades.
- The accumulated trading costs by spread, slippage, commission and rollover are displayed on the Performance Report.
- When Zorro is connected to a broker, it loads the current asset
parameters from the broker's server. When not connected,
or when the asset parameters are not available online, they are loaded from the Asset List.
This file can be selected or edited with a text editor for simulating
different brokers, accounts, and assets in backtests.
- In portfolio strategies, transaction costs are specific to the currently selected asset. The asset must be selected
with asset() before modifying any asset specificc parameters.
- The roundturn cost of a currency pair trade - without rollover and slippage - is
Lots*(Commission*LotAmount/10000 + Spread*PIPCost/PIP). For all other assets it's
Lots*(Commission*LotAmount + Spread*PIPCost/PIP).
- Trade costs can be set to constant values per asset for test purposes. F.i. for a simulation with no slippage and trade costs at all, run the following command once per traded assets (f.i. inside the
asset loop): Spread = Commission = RollLong = RollShort = Slippage = 0.
Fill mode can also be set at 0 for closing all trades exactly at the stop or profit limit.
- Some brokers or exchanges apply complex commission calculations that are
neither a flat fee nor a percentage. If required, calculate commission in
the script and set the Commission variable to the result
before entering and exiting a trade. For instance, when the total commission
is a fixed 1$ when buying less than 50 shares, and 2 cents per share
otherwise, calculate it with
if(Lots < 50) Commission = 1.0/Lots; else Commission = 0.02;.
- In [Test] and [Train] mode, rollover is added to the trading cost for any trade that was longer open than 12 hours at any new day, including Saturday and Sunday. This is only an approximation to the real rollover cost, as brokers have many different algorithms to calculate rollover. If you need to simulate rollover very precisely, use a
data set of historical rollover costs, and add them to the trading costs by script using the broker's algorithm.
- Since spread and rollover are taken from an 'account snapshot' when the asset list was generated, they can be very different to the current, as well as to historical spread and rollover. This can falsify backtests f.i. when trades are open a long time and accumulate a large rollover. For being on the safe side, set
RollShort and RollLong to their minimum (RollLong = RollShort = min(RollLong,RollShort);) and
Spread to a high percentile of a one-day sample.
Spread = 3*PIP; // ignore broker spread, set constant spread for performance calculation
enterLong/Short, price, Stop, Lots, Margin, PIP, asset parameters
► latest version online