OPEN-SOURCE SCRIPT

BACKTEST SCRIPT 0.999 ALPHA

TRADINGVIEW BACKTEST SCRIPT by Lionshare (c) 2015
THS IS A REAL ALTERNATIVE FOR LONG AWAITED TV NATIVE BACKTEST ENGINE.
READY FOR USE JUST RIGHT NOW.

For user provided trading strategy, executes the trades on pricedata history and continues to make it over live datafeed.
Calculates and (plots on premise) the next performance statistics:
  • profit - i.e. gross profit/loss.
  • profit_max - maximum value of gross profit/loss.
  • profit_per_trade - each trade's profit/loss.
  • profit_per_stop_trade - profit/loss per "stop order" trade.
  • profit_stop - gross profit/loss caused by stop orders.
  • profit_stop_p - percentage of "stop orders" profit/loss in gross profit/loss.
  • security_if_bought_back - size of security portfolio if bought back.
  • trades_count_conseq_profit - consecutive gain from profitable series.
  • trades_count_conseq_profit_max - maxmimum gain from consecutive profitable series achieved.
  • trades_count_conseq_loss - same as for profit, but for loss.
  • trades_count_conseq_loss_max - same as for profit, but for loss.
  • trades_count_conseq_won - number of trades, that were won consecutively.
  • trades_count_conseq_won_max - maximum number of trades, won consecutively.
  • trades_count_conseq_lost - same as for won trades, but for lost.
  • trades_count_conseq_lost_max - same as for won trades, but for lost.
  • drawdown - difference between local equity highs and lows.
  • profit_factor - profit-t-loss ratio.
  • profit_factor_r - profit(without biggest winning trade)-to-loss ratio.
  • recovery_factor - equity-to-drawdown ratio.
  • expected_value - median gain value of all wins and loss.
  • zscore - shows how much your seriality of consecutive wins/loss diverges from the one of normal distributed process. valued in sigmas. zscore of +3 or -3 sigmas means nonrandom realitonship of wins series-to-loss series.
  • confidence_limit - the limit of confidence in zscore result. values under 0.95 are considered inconclusive.
  • sharpe - sharpe ratio - shows the level of strategy stability. basically it is how the profit/loss is deviated around the expected value.
  • sortino - the same as sharpe, but is calculated over the negative gains.
  • k - Kelly criterion value, means the percentage of your portfolio, you can trade the scripted strategy for optimal risk management.
  • k_margin - Kelly criterion recalculated to be meant as optimal margin value.


DISCLAIMER :

The SCRIPT is in ALPHA stage. So there could be some hidden bugs.
Though the basic functionality seems to work fine.
Initial documentation is not detailed. There could be english grammar mistakes also.

NOW Working hard on optimizing the script. Seems, some heavier strategies (especially those using the multiple SECURITY functions) call TV processing power limitation errors.

Docs are here:
docs.google.com/document/d/1lwZzondmpwH9FO0YlrnojIJZeo0SZLqb8IwvwMdmZJE/edit
algotradingbackteststatistics

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항