KioseffTrading

Self-Optimizing RSI Strategy [Kioseff Trading]

KioseffTrading Wizard 已更新   
Hello!

Introducing the Self-Optimizing RSI Strategy.

The indicator tests up to 800 RSI strategies simultaneously, looping through arrays, and auto plots the best performing parameter set.


The image above shows the result of 800 RSI strategies concurrently.

The table oriented bottom right shows the performance and risk metrics of the best performing RSI system tested across the bar set. Additionally, the conditions for entry and exit are displayed; for the image - a long entry system predicated on RSI crossunders and exit system predicated on a 1% TP and 2% SL are shown.


The indicator calculates numerous risk and performance metrics.

Calculated metrics include:

  • RSI Parameters
  • RSI Cross Entry Level
  • Total Trades
  • Win Rate
  • Avg. Gain for Winning Trades
  • Max Pain
  • PnL (Cumulative Performance)
  • Profit Factor
  • Avg. Loss for Losing Trades
  • Ratio Avg. Win / Avg. Loss
  • Avg. Bars in Trade
  • Max Drawdown
  • Current Drawdown
  • Open Position PnL

"Dynamic" indicates the performance of self-optimizing RSI system was tested.


The image above shows the performance of the greatest-performing RSI system - a fixed set of parameters - when adhering to a 1% TP and 2% fixed SL.

Trailing Stops and Profit-Taking Limit orders can be set/simulated.


The image above shows a dynamic entry level - plotted as a purple, non-transparent line.

The entry level "self-optimizes" to mimic the best performing RSI system at current time.


The image above exemplifies the functionality for all horizontal lines plotted on the chart.

The average RSI level achieved subsequent a profitable trade is shown.

The average RSI level achieved subsequent a losing trade is shown.

The entry level for RSI crossunders/crossovers is shown.


The image above show the Self-Optimizing RSI indicator recording entries & exits; gains & losses, for each executed trade.

You can "verify" trades manually.

Blue boxes reflect an entered position.

Green boxes reflect a closed, profitable trade.

Red boxes reflect a close, losing trade.

The percentage gain for a profitable trade is appended to green boxes; the percentage loss for a losing trade is appended to red boxes.

The Self-Optimizing RSI indicator plots off the chart; however, percentage gains/losses are measured against price, not RSI.

Boxes correlate to the interval a trade was entered/exited on.

The indicator hosts various methods to filter the outcome for testing.

For instance, you can:

  • Use trailing stops or fixed stop losses
  • Test RSI crossunders and crossovers
  • Configure the RSI settings that are tested (i.e. RSI 2 - 9, RSI 14 - 20, RSI 50 - 57)
  • Test short-based RSI Systems and long-based RSI systems
  • Simulate limit orders (Exit intrabar at fixed stop losses or trailing stop losses; exit intrabar at profit targets)
  • Require all tested RSIs to trend above or below their respective average (i.e. all RSIs must trend above/below their 50-interval EMA values. SMAs can also be used)
  • Use external indicators and require a user-defined value be exceeded, measured below, or that price exceed or measure below an indicator. The Self-Optimizing RSI indicator incorporates a few built-in technical indicators - ADX, %k, MFI, CMFI, and RSI. Consequently, you can require these indicators to measure above/below a specified level prior to entry. Additionally, you can supplement an extrinsic indicator (anything custom coded with plot values) to the entry logic for the Self-Optimizing RSI indicator. I'll show an example shortly.
  • Adjust the time window that's tested.
  • Adjust PT and SL percentages.
  • Override plot an RSI system to procure thorough statistics.
  • Require a symbol to measure above/Below or equal to a particular price level to “validate” a Long/Short entry signal. You can retrieve any data hosted by TradingView and require it measure above/below a user-defined level prior to entry. For instance, you can select "$VIX", and require the ticker to measure less than $30 prior to long/short entry. If "$VIX" measures greater than $30 prior to a long/short signal the position will not open. Alternatively, you can require a symbol to measure above a user-defined price prior to entry. If the retrieved ticker doesn't measure above the user-defined level prior to entry a trade will not open.

Use trailing stops or fixed stop losses


The image above shows results for 800 short-based RSI systems - using a trailing stop loss.

Test RSI crossunders and crossovers


The image shows results for 800 long-based RSI systems. Positions are entered subsequent to RSI crossovers.

You can select which RSI strategies are tested - you aren't not limited to testing RSI 2 - RSI 9 (:

Simulate limit orders (Exit intrabar at fixed stop losses or trailing stop losses; exit intrabar at profit targets)


The image above shows performance test results when exiting during the interval subsequent to the profit target being exceeded.


The image above shows performance test results when exiting during the interval subsequent to the stop loss being exceeded.

Require all tested RSIs to trend above or below their respective average (i.e. all RSIs must trend above/below their 50-interval EMA values. SMAs can also be used)


The image above shows an RSI EMA in addition to prerequisite condition. For each RSI strategy tested, the RSI used for the strategy must measure above an EMA of its values prior to entry. You can require RSI to measure below an EMA of its values prior to entry, use an SMA, and change the length of the MA used.

Use external indicators and require a user-defined value be exceeded, measured below, or that price exceed or measure below an indicator. The Self-Optimizing RSI indicator incorporates a few built-in technical indicators - ADX, %k, MFI, CMFI, and RSI. Consequently, you can require these indicators to measure above/below a specified level prior to entry. Additionally, you can supplement an extrinsic indicator (anything custom coded with plot values) to the entry logic for the Self-Optimizing RSI indicator. I'll show an example shortly.


The image above shows me requiring the ADX indicator to measure above "20" prior to long entry. Any of the built-indicators can be used with similar conditions; you can implement a custom-coded indicator for trade logic.


Additionally, you can supplement an extrinsic indicator (anything custom coded with plot values) to the entry logic for the Self-Optimizing RSI indicator.


The image above shows me retrieving the value for Volume Profile Point of Control - a TradingView coded indicator.

Consequently, I can require price to measure above/below the session's Poc prior to RSI long/short entry.

You can use this feature with any custom coded indicator providing historical plot values - something you or a favored author have coded.


]Adjust PT and SL percentages


The image above shows adjusted TP & SL percentages - optimize and reward/risk ratio you'd like (:


Override plot an RSI system to procure thorough statistics.


The image above shows manually plotted RSI parameters and a corresponding stat sheet.

Require a symbol to measure above/Below or equal to a particular price level to “validate” a Long/Short entry signal. You can retrieve any data hosted by TradingView and require it measure above/below a user-defined level prior to entry. For instance, you can select "$VIX", and require the ticker to measure less than $30 prior to long/short entry. If "$VIX" measures greater than $30 prior to a long/short signal the position will not open. Alternatively, you can require a symbol to measure above a user-defined price prior to entry. If the retrieved ticker doesn't measure above the user-defined level prior to entry a trade will not open.


The image above shows me requiring the ticker "$VIX" to measure below $30 prior to long/short entry. If %VIS measures greater than $30 when a long/short signal triggers a position will not be opened. Further refine your trading system with this feature - exploit correlations.

Adjust the time window that's tested.


The image above shows configurable start and end dates for the optimization period.

You won't be able to test 800 RSI strategies concomitantly on a 20,000 bar data set.

Consequently, for large data sets (intrasession data) you will have to narrow the optimization window to test a larger number of combinations.

You can test 80 (loads on all data sets), 144 (loads on all data sets), 264 (loads on ~15,000 bar data sets), 312 (loads on ~11,500 bar data sets) and 800 (loads on ~4950 bar data sets)combinations simultaneously. You can test 800 RSI strategies simultaneously on intrasession data; however, you'll likely have to narrow the tested time window.

I recently published a bar count script titled "Bar Count for Backtesting", you can access the script here:
The above script is useful for quickly calculating the number of bars in a time window, or the date for a bar that is "x" number of bars back. Therefore, implementing these scripts cooperatively should improve date selection efficiency (not arbitrarily selecting test start & end dates that fail to load).

I included a tool tip describing the near-maximum bars in a data set that the higher numbers of simultaneous RSI strategies can be tested on.


More to come; enjoy!

(P.S. The script uses private libraries and, consequently, is unable to be published open source)

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!

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 RSI 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!

This publication does not constitute investment advice.

發布通知:
Updated chart
發布通知:
Compliance Update

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

•Discord Server: discord.gg/3cKVU28Z9Z
受保護腳本
該腳本是閉源發佈的,您可以自由使用。您可以把它加入到常用以在圖表上使用它。您無法查看或修改其原始碼。
免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?