Self Optimizing RSI and Self Adaptive TP/SL Strategy. (non-repainting)
This script continuously backtests 20 different combinations of RSI Buy conditions across 5 different Take Profit/Stop Loss combinations. In total, it tests 100 variants on every bar close and records the Net Profit gained for each combination. The strategy then selects and uses the best-performing combination of settings currently available for you to trade.
--------------------------------------------------------------------------------------------------------- The Relative Strength Index (RSI), developed by J. Welles Wilder, is a momentum oscillator that measures the speed and change of price movements. The RSI oscillates between zero and 100. Traditionally the RSI is considered overbought when above 70 and oversold when below 30. Signals can be generated by looking for divergences and failure swings. RSI can also be used to identify the general trend.
To improve our results we are calculating Multiple Length RSI - Average RSI based on the multiple periods. You can use just 1 Length or Multiple.
Set Inputs to Min=14, Max=14 if you want to use just 1 period. = RSI(14)
3 RSI Lengths example (12,13 and 14):
Min=12, Max=14
(12+13+14) / 3 = avg. RSI
----------------------------------------------------------------------------------------------------------- Backtester - Optimizer Explained: The backtester runs numerous backtests in the background to optimize trading strategies. Here’s how it works:
Default Inputs (RSI Crossover Buys) : 18,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,45,55,69 _______________________________________________________ Backtest RSI Crossover 18: TP1%, SL4% => Save net profit TP2%, SL4% => Save net profit TP3%, SL4% => Save net profit TP2%, SL5% => Save net profit TP4.5%, SL10% => Save net profit ,... ,... Backtest RSI Crossover 69: TP1%, SL4% => Save net profit TP2%, SL4% => Save net profit TP3%, SL4% => Save net profit TP2%, SL5% => Save net profit TP4.5%, SL10% => Save net profit Self Optimizing Buy Condition and Self Optimizing Take Profit - Stop Los This process involves testing various combinations of RSI crossover values with different Take Profit (TP) and Stop Loss (SL) percentages. The net profit for each combination is saved, allowing the optimizer to select the best-performing settings for trading.
It recalculates on every bar close. If one combination starts performing better than others—achieving a higher net profit gain (essentially like running 100 backtests with different settings in the background)—the strategy switches to that combination of TP/SL and Buy condition. It continues trading with the new settings until another parameter starts performing better and the strategy switches to that setting. ________________________________________________________________________
If you wish to use it as INDICATOR - turn on 'Recalculate - On every tick' in Properties tab to have this script updating constantly and use it as a normal Indicator tool for manual trading.
Other functions:
Set the %fee for optimizing engine. If you set this % higher, you also punish small average trades and make the strategy prefer larger avg. trades, giving you better chances to make your strategy profitable.
Trade with trend and optimize the strategy only when the market is uptrending with EMA/HMA
Use Moving Average of avg.RSI and smooth the values for indicator even more. (Yes strategy is self optimizing RSI or avg.RSI or RSI-MA, you can select all sorts of this indicator for optimizing)
All trading alerts are working and functional, if you want to automate the strategy
This script is simple to use for any trader as it saves a lot of time for searching good parameters on your own. It's self-optimizing and adjusting to the markets on the go.
เอกสารเผยแพร่
Added: 'Backtest Date Range', 'Profit Calendar' and 'Pre-Optimization'. 'Pre-Optimization Trade Count' refers to the number of trades that occur before the self-optimization process begins. It's recommended to leave the first 2..10 trades unoptimized to allow the strategy to learn.
เอกสารเผยแพร่
Changed the 'Pre-Optimization Trade Count' to % of your total trades, it's easier. -It’s recommended to leave the first 5% to 30% of trades in the backtest unoptimized. Also improved some tooltips, every function is explained if you mousover (!)
เอกสารเผยแพร่
Quick little edit that i forgot. Changed Multi-Length RSI to default settings of Min=10, Max=20. It's recommended to use parameters Min=7, Max=14 or Min=10, Max=20 most of the time.