Strategy statistics

The following system variables can be evaluated after the end of a simulation in the objective or the evaluate function. There is another set of trade statistics that can also be evaluated during the simulation. These variables allow designing custom performance metrics and printing them to the performance report.
 

DrawDownMax

Maximum drawdown, the largest difference between a balance peak and the lowest subsequent equity valley during the simulation period, in account currency units.

MAE

Maximum adverse excursion, the largest difference between an equity peak and the lowest subsequent equity valley during the simulation period, in account currency units.

MarginMax

Maximum margin sum of open trades during the simulation period, in account currency units.

RiskMax

Maximum possible loss sum of all open trades during the simulation period, in account currency units. The possible loss is calculated by the stop loss distance of a trade, or estimated at 10% of the price if no stop loss was used.

SpreadCost

Total loss by bid-ask spreads during the simulation period, in account currency units.

SlippageCost

Total win or loss by simulated slippage during the simulation period, in account currency units.

RollCost

Total win or loss by rollover interest during the simulation period, in account currency units.

CommissionCost

Total loss by commissions during the simulation period, in account currency units.

ReturnMean

Mean of all bar returns. The bar return is the equity difference to the previous bar, divided by Capital. If Capital is not set, the sum of normalized drawdown and maximum margin is used.

ReturnStdDev

Standard deviation of all bar returns. Can be used together with ReturnMean for calculating the annualized Sharpe Ratio and other metrics.

Ulcer

Ulcer Index in percent; average drawdown divided by peak equity.

R2

R2 coefficient; the similarity of the equity curve with a straight line ending up at the same profit.
   

DrawDownBars

Total number of bars spent in drawdown. For the percentage spent in drawdown, divide by the duration of the test, (Bar-StartBar).

DrawDownBarsMax

Maximum length of a drawdown in bars.

LossStreakMax

Maximum number of losses in a row.

NumOpenMax

Maximum number of simultaneously open trades.

InMarketBars

Total number of bars with open trades.

InMarketSum

Sum of the durations of all trades, in bars. Can be bigger than the duration of the test when several positions are simultaneously open.

Type:

int for numbers that count something, otherwise var. Read/only, set at the end of the simulation period.
 

Results

Array containing the current wins and losses of all open and closed trades at every bar, in account currency units. (var)Results[Bar] is the end result.

Type:

float* pointer, or 0 when no results were calculated.
 

ResultsDaily

Array containing the balance or equity (dependent on the BALANCE flag) at the end of every day, in account currency units. ResultsDaily[Day] is the end result. This array is automatically saved to a .csv file for further evaluation.

Type:

var* pointer, or 0 when no daily results were calculated.

 

Remarks:

Example:

// print the annualized Sharpe Ratio to the performance report 
function evaluate()
{ 
  if(NumWinTotal == 0) return;
  var MySharpe = ReturnMean/ReturnStdDev;
// roughly adjust to annual in-market bars
  MySharpe *= sqrt(InMarketBars * 252/Day);
  printf(TO_REPORT,"\nMy Sharpe: %.2f",MySharpe);
}

See also:

Trade statistics, for(trades), NumBars, performance report

 

► latest version online