Account Parameters

Balance

The current amount in the broker account. In live trading, this parameter is updated from the broker API if available; otherwise it is calculated from Capital + Wintotal - LossTotal.

Equity

The current value of the account including all open trades. In live trading, this parameter is updated from the broker API if available; otherwise it is calculated from Balance + WinValTotal - LossValTotal.

TradeVal

The current value of all open trades by the strategy. This is the profit or loss if all trades would be closed immediately. The value of all open trades of the account is Equity - Balance.

RiskTotal

The estimated maximum risk of all open trades by the current script. The risk is estimated as trade costs plus loss at either the initial stop loss distance, or at an 1% adverse price move when no stop is used. Due to trailing and exit mechanisms, the real risk is normally smaller than the estimated risk, but can also be higher in cases of large price moves or large exit slippage.

MarginTotal

The current allocated margin of all open trades of the strategy, calculated through MarginCost under assumption of a constant margin requirement of open trades. This can be different in live trading when brokers adapt the margin requirement to the market situation or asset price. A margin call is simulated in test and training mode when Capital > 0 and Equity - MarginTotal reaches zero.

MarginVal

The current allocated margin of the account. The account is threatened by a margin call when Equity - MarginVal approaches zero. In live trading, this parameter is updated from the broker API if available; in test and training it follows MarginTotal.

Range:

Account currency

Type:

var, read/only

Remarks:

Example:

// stop trading when there's not enough money in the acount
if(IsTrading && Equity - MarginVal < 1000)) 
Lots = 0;
else
Lots = 1;

See also:

enterLong/Short, Win / Loss, Capital

 

► latest version online