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精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?

免責聲明