OPEN-SOURCE SCRIPT

SuperTrend Optimizer

업데이트됨
Hello!

This indicator attempts to optimize Supertrend parameters. To achieve this, 102 parameter combinations are tested concurrently - the top three performers are listed in descending order.

Parameters,

Factor: Changes to this parameter shifts the tested factor range. For instance, increasing the factor measure from 3.00 to 3.01 (+0.01) will remove 3.00 from the tested range - this setting controls the lower threshold of the range. The upper threshold, in all instances, is the lower Factor threshold + 3.3 (i.e. 3.0(lower) - 6.3(upper), 4.0(lower) - 7.3(upper), 2.5(lower) - 5.8(upper))

ATR period: Changes to this parameter shifts the tested ATR period range. For instance, increasing the ATR measure from 10 to 11 (+1) will remove 10 from the tested range - this setting controls the lower threshold of the range. The upper threshold, in all instances, is the lower threshold + 2 (i.e. 10(lower) - 12(upper), 11(lower) - 13(upper), 9(lower), - 11(upper))

The Factor parameter is modifiable to any positive decimal number; the ATR parameter is modifiable to any positive integer. Changing either parameter shifts the tested parameter combination range. Both parameters can be changed in the settings, to which you control the lower threshold of the range. If, for instance, you were to change the Factor measurement from 3.0 to 4.1 (+1.1) the 4.0 Factor measurement, and all Factor measures less than 4.0, will be excluded from the performance test.

Consequently, a Supertrend test will be performed with a Factor of 4.1 and an ATR period of 10 (default). This test repeats at 0.1 Factor intervals and 1.0 ATR intervals.

Therefore, assume you modify the Factor lower threshold to 3.1 and the ATR lower threshold to 10. The indicator will test three Supertrend systems with a Factor of 3.1 and an ATR period of 10.. then 11.. 12, then three systems with a Factor of 3.2 and an ATR period of 10.. then 11.. 12... until (lower Factor threshold + 3.3) and (lower ATR threshold + 2) are tested... which in this example is... a Factor of 6.4 and an ATR period of 12.

The tested Factor range and ATR range are displayed in a bottom right table alongside the top performing parameter combinations.

Of course, you can change the the lower thresholds, which means you can test numerous Supertrend parameter combinations! However, no greater than 102 parameter combinations will be tested simultaneously; the best performing Supertrend parameters are plotted on the chart automatically.

I will be working on this indicator more tomorrow! Let me know if you have questions or anything you would like included!

(I of course added something fun in the script. Be sure to try it with bar replay!)
릴리즈 노트
Forgot to mention,

The indicator tests LONG positions ONLY! Traditional Supertrend sell signals are considered LONG EXIT signals - which are calculated for profit/loss.

Performance calculations are predicated on CUMULATIVE gains, not average gain/loss!

Also, it's good to be prudent with an indicator like this! Automated optimization can lead to over optimization!
릴리즈 노트
Added indicator instructions! For those of you who found this script in chart search!
릴리즈 노트
스냅샷

Added the option to display all performance test data.
릴리즈 노트
Removed unused identifiers
릴리즈 노트
Added the option to override plot SuperTrend; removed unused identifiers.
릴리즈 노트
Fixed a misplaced word
릴리즈 노트
Hello!

I was recently questioned why I did not mention the potentially disastrous consequences of optimization scripts.

So, I am posting a quick update to outline the advantages and disadvantages of indicator/strategy optimization!

An optimization script is best implemented to discover what won't work, not what will work. The best performing "optimized" parameters are not a guaranteed profitable investment system. While we may see an exceptionally positive performance for a set of parameters, it's impossible to know how much of that performance is the beneficiary of market noise in the absence of additional testing. Most market moves are noise - irreplicable sequences that offer no predictive utility - and most "good" backtests overwhelmingly benefit from these irreplicable sequences. An investor unfamiliar with this concept may be lead to believe they have found a valid correlation between an indicator sequence and subsequent price movement, despite the correlation being illusory.

Consequently, it should be assumed that the best performing parameters strongly benefitted from market noise and will not work in a live market - until further rigorous statistical tests are performed on an investment system built around the best performing parameters. This includes out-of-sample, in-sample, and forward testing in addition to testing negatively correlated, positively correlated and zero-correlation assets; testing additional assets should be treated as prerequisite to live implementation.

Of course, all trading strategies, even one's that methodically exploit a valid correlation/replicable sequence, will benefit from market noise - it's impossible to avoid. However, a "legit" trading strategy has a chance to work on future price data, while an overoptimized strategy will fail miserably on new price data!

This script tests 102 parameter combinations concurrently and returns the performances in descending order. An overoptimized strategy is virtually guaranteed to have a better backtest performance than a valid strategy. The overoptimized strategy will fail in a live market while the valid strategy has a chance of working. So, should you notice the best performing SuperTrend parameters, be sure to build a comprehensive trading system around the parameters and perform additional tests. This is the only way to know if the optimized parameters will truly work in a live market!

Unfortunately, they often will not!


릴리즈 노트
A user requested that I include an option to hide table descriptions.

So, you can now hide table/testing descriptions!
릴리즈 노트
Added light mode option
릴리즈 노트
Attempt to fix new memory error
릴리즈 노트
Efficiency Upgrade
릴리즈 노트
Values are not appended to arrays on last bar
ATRAverage True Range (ATR)statisticssupertrendsupertrend_reversalsupertrendstrategyTrend Analysis

오픈 소스 스크립트

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

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


•Access to Next-Gen Optimization Tools: kiosefftrading.com

•Discord Server: discord.gg/3cKVU28Z9Z
또한 다음에서도:

면책사항