# Asset parameters 2

## PIP

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.

## PIPCost

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 strategy performance figures; but 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 counter currency exchange rate - its value in account curreny units - is PIPCost / (PIP * LotAmount).

## MarginCost

Required margin for puchasing and holding 1 lot of the current asset in units of the account currency.Either directly taken from the asset list, or calculated from the leverage by MarginCost = Asset price * PIPCost / PIP / Leverage. The number of lots at a given margin is Margin / MarginCost. For options and futures, MarginCost is calculated per underlying unit. The variable is updated in real time when the asset list contains a negatve MarginCost parameter that represents Leverage. For special margin requirements, f.i. for covered options or option combos, set this variable in the script to the maximum of initial, maintenance, and end-of-day margin per underlying unit before entering the trade.

## Leverage

Asset value divided by margin cost. Determines 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:  Leverage = Asset price * LotAmount * CCValue / MarginCost or Leverage = Asset price * PIPCost / PIP / MarginCost, where CCValue is the value of the counter currency in account currency units. For brokers that support the SET_LEVERAGE command, Leverage and MarginCost must be set on the fly before entering a trade.

## LotAmount

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 CFDs or diginal coins. Some brokers allow arbitrary lot amounts when they support the SET_AMOUNT command.

## LotLimit

Maximum number of Lots with the current asset (default: 1000000000/LotAmount). Can be set to a smaller number for safety reasons. If the number of lots exceeds this limit, for instance due to a script bug, the order is not executed and an error message is issued.

## InitialPrice

The initial asset price taken from the asset list. Can be set to the first historical price and used to adapt parameters (such as MarginCost) to asset price changes in the backtest (f.i. MarginCost = InitialMarginCost * priceClose() / InitialPrice).

The last ask price of the current asset in live trading mode or by calling priceQuote. The last bid price is AskPrice - Spread.

### Type:

var, read/only if not mentioned otherwise (edit the Asset List for permanently changing asset parameters).

## AssetBar

Bar number of the last received price quote of the current asset, from 1 (first bar) up to Bar (current bar). Can be used to determine if there was a quote in the current bar.

### Remarks:

• Asset specific parameters are only valid after selecting the asset.
• When Zorro is connected to a broker, it loads the current asset parameters from the broker's server if available. Otherwise they are taken from the current 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.

### Examples:

```// 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  if(!asset(Rate)) return;  var Price = price();  asset(OldAsset);  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.
```