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:
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
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
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。