Asset parameters 2
Size of 1 price point (pip) of the current asset in units of the counter currency, f.i. 0.0001 for EUR/USD. Can be used to set a price in pips, f.i. Stop = 10*PIP. For converting a price difference to pips, divide it by PIP.
Value of 1 pip profit or loss per lot in units of the account currency; determined by the lot size (LotAmount) and the exchange rate of account currency and counter currency. This value should normally remain constant during the simulation for not adding artifacts to the result. If desired for special purposes, it can be calculated by script to fluctuate with the exchange rate (see example below). When the asset price rises or falls by x, the equivalent profit or loss in account currency is x * Lots * PIPCost/PIP. The value of the counter currency in account curreny units is normally CCValue = PIPCost / (PIP * LotAmount). This is only different In special cases when a CFD corresponds to only a fraction of the underlying asset.
Required initial margin for buying 1 lot of the current asset in units of the account currency; depends on leverage and lot size.
The number of lots at a given margin is Margin / MarginCost. Is updated in real time when the broker uses the Leverage method for calculating margin cost. For special margin requirements, f.i. for covered options or vertical spread, set this variable in the script before entering a trade.
Asset value divided by margin cost. Determined by the account's buying power, i.e. the asset amount that can be purchased with account currency. MarginCost and Leverage can be converted into each other: MarginCost = LotAmount * Asset price * CCValue / Leverage = Asset price / Leverage * PIPCost / PIP.
The number of contracts per lot with the current asset. Determines the minimum order size and depends on the lot size of the account. For currencies, the lot size of a micro lot account is normally 1000 contracts; of a mini lot account 10000 contracts; and of a a standard lot account 100000 contracts. Some brokers offer also lot sizes that are a fraction of a contract, f.i. 0.1 contracts per lot for certain CFDs.
The initial asset price taken from the asset list. Can be used - when desired - to adapt MarginCost to the changes of the asset price in the backtest (current MarginCost = Initial MarginCost * Asset Price / InitialPrice). Most brokers do not adapt their MarginCost continously to the price, but in separate steps of a multiple of the account currency unit.
var, read/only (edit the Asset List for permanently changing asset parameters).
- When Zorro is connected to a broker, it loads the current asset parameters from the broker's server. When not connected, or when the boker API does not provide the parameters, they are loaded from the asset list (normally History\AssetsFix.csv). The asset list can be edited with a spreadsheet program or a text editor for simulating different brokers, accounts, and assets in backtests; or it can be automatically updated to the parameters of the current broker account. For details see Data Import.
// set stop / profit target at a fixed pip distance
Stop = 10*PIP;
TakeProfit = 40*PIP;
// let profits fluctuate with the account currency exchange rate
function convertProfits(string Rate)
char OldAsset; strcpy(OldAsset,Asset); // store original asset
var Price = price();
if(Price > 0.)
PIPCost = PIP*LotAmount/Price;
// call this function from run(), f.i.
convertProfits("EUR/USD"); // when account currency = EUR and counter currency = USD.
Stop, Spread, Lots, Commission, Broker Data
► latest version online