TradingView
KioseffTrading
2022年3月1日晚上8點04分

Find Best Performing MA For Price Crossover 

Microsoft CorporationNASDAQ

描述

Hello!

This script calculates the average percentage gain/loss following a price crossover of a moving of any length, up until prices cross back under the MA.
The script calculates the average number of candles that the source (i.e. close, open, low, ohlc4) remains above the moving average until crossing back under, in addition to the number of crosses. Performance is listed from best to worst; descending order. Also listed is the HIGHEST cumulative gains of ALL tested moving averages.

The moving average length can be changed to any number, so long as there are enough data points, on ANY timeframe and the script will recalculate.

發布通知

Added additional plotting options.

The option "Best performing MA" can be selected. Tradingview will plot the bet performing MA when selected; however, there will be gaps in the data series.
To compensate, I included three color display options: "Full", "Light" and "Off".

"Full" will plot all MA types with original colors; the best performing moving average will incorporate a gradient color.
"Light" will plot all MA types. The best performing MA will have a gradient color and the worse performing MAs will be light black.
"Off" only plots the best performing MA. Worse performing MAs are excluded. However, there might be plot gaps with this selection.

發布通知

Added further indicator instructions!

發布通知

Hello!

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 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 Moving Average 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!


發布通知

Memory calculation compliant
評論
RedKTrader
Nice work.. ! Thanks for sharing.
KioseffTrading
@RedKTrader, Thank you very much RedKTrader! Very appreciated it!
Honestcowboy
Congrats, very powerful concept in indicator building. I think this one can be used by a ton of traders to be honest.
KioseffTrading
@Honestcowboy, Thank you for the reply Honest Cowboy!

I think it is very helpful as well!
HeyMrRobot
Yes, this is something that I needed to see on historical for shaping up strategy's moving averages filter to be keep up positions side with trend.

Thanks Kio!
KioseffTrading
@HeyMrRobot, Thank you for the positive feedback Mr.Robot!
TRND-TRADING
nice!
KioseffTrading
@Doc_Holliday_75, Thank you for the positive feedback Doc!
suranga1987
so these are sort of "smart indicators" ,who optimized themselves ...i believe this a huge step and open to a vast realm of opportunities...!!
KioseffTrading
@suranga1987, Good to see ya suranga!

Thank you for the support!
更多