I welcome you to my first published script on TradingView: “Multi-timeframe Moving Averages + RSI”.
The script is based on a simple formula: Buy signals are generated when a fast moving average is above a slower moving average (uptrend) and the K line is crossing above the oversold level (entry).
Sell signals are generated when a fast moving average is below a slower moving average (downtrend) and the K line is crossing below the overbought level (entry).
This indicator works best in strong trends!
**Please note the above example has repainting turned on which may produce unrealistic results when viewing historical data. See below for more information regarding this and how you can turn it off.**
The user has the following inputs:
- Option to change the settings, including the oversold and overbought levels.
- Option to enter any value for both the Fast Moving Average and the Slow Moving Average.
- Option to change between or for each moving average.
- Multiple time frames to choose from, as well as the ability to selectively turn off individual time frames (both plots and alerts).
(Default time frames are 1 hour, 4 hour, and Daily. You can have a 4th time frame by changing your current time frame to something lower than the other 3 time frames)
- Turn on/off repainting: If repainting is turned on you will get an alert and buy/sell signal on chart immediately when condition is met, however the signal may disappear from chart if the condition reverses during the same candle.
If repainting is turned off, the indicator will wait for the candle to close before issuing the alert and painting the signal on chart.
For higher time frames, the indicator will wait for the candle in the higher time frame to close before issuing a signal if repaint is turned off. Default is set to Repaint on, so please be aware of this if you do not want repainting.
How to use alerts:
- Before you do anything, make sure your current time frame is the lowest time frame you’d like alerts on, as you will still receive alerts for the higher time frames you selected in settings.
- Once you have all the settings changed to how you like, save your chart first. Then right click on any of the indicator’s buy/sell signals on the chart and click “Add Alert on MAs + RSI”.
- Make sure “Any alert() function call” is selected under the Condition.
- You can delete or change the text in “Alert name” if you want as the alert message is already built into the indicator, and it will tell you in the alert message which asset and time frame to buy or sell.
Other things to note:
- The indicator will not display the buy/sell signals of lower time frames when you are on a higher time frame. This was done purposely to reduce clutter on the chart when you switch to higher time frames.
- While the alert message will tell you which time frame a signal was generated, the plots on the chart will instead show “Buy/Sell TF1, or TF2, or TF3”.
If the signal is from the current time frame that the alert was created on, then it will simply show “Buy” or “Sell”.
Hope you guys enjoy using this one, please drop a like if you found it useful. If anyone wants to modify my script in any way, please just credit me for the original work when you publish the script. Good luck!
- Addressed issue with repaint function truly showing a repainting signal from higher time frames. Previously if there was a signal coming from higher time frame, it was waiting until the end of that higher time frame candle to display/alert the signal on lower time frame. With repaint turned on, we want the signal to happen as soon as the stoch RSI crosses up the oversold or crosses down the overbought on the higher time frame even if it ends up disappearing during that higher time frame candle.
- Added the option for a 3rd moving average to calculate which can provide even more accurate signals, and help reduce signals during noisy periods. Note that this 3rd moving average (Slow MA) must be higher than 2nd moving average (Medium MA), and 2nd moving average must be higher than 1st moving average (Fast MA).
- Additionally, you can now display all of these moving averages on the chart to make it easier to see how your changes affect the signals.
- Added the option to add trend filters to the signals. This includes using the Supertrend, ADX, and/or Rising/Falling Moving Average threshold. I have also added the ability to see The rising/falling MA as well as the Supertrend to display on the chart to see how your changes affect the indicators.
- As a result of adding the different filtering indicators which also affect higher time frame signals, I ran out of security requests that pine script allows me to use. Therefore I had to remove one of the higher time frames for signals, so users have current time frame plus 2 higher time frames they can pick from.
As previously noted, this indicator works best when the asset is in a strong trend, it can give a lot of false signals during ranging periods. Use this indicator in combination with my S/R zones indicator to help you filter out some of the signals: . You can also implement the other filters I discussed above, and tweaking the Stoch RSI settings can help tremendously in smoothing it out so you have fewer false signals. Most importantly is to use the moving averages to your advantage, wait until they are all fanning out and angled up/down before taking the signals.
I hope this update helps everyone, if you have any other suggestions please comment below!
Dalam semangat TradingView, penulis dari skrip ini telah mempublikasikannya ke sumber-terbuka, maka trader dapat mengerti dan memverifikasinya. Semangat untuk penulis! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.