thebiggerhand

Multiple Timeframe RSI Bot for 3commas (works w/o 3commas too)

thebiggerhand Mis à jour   
Overview

A few days ago I wrote a new RSI-based strategy. The idea was that you could set up buy and sell RSI thresholds and when RSI crossed that threshold it would make a buy or a sell depending on which one it hit. It worked very well on multiple coins that I tested. I then started to think that maybe there was a better way to execute this concept using multiple timeframe RSIs and this bot represents that idea. It is better and more versatile than the previous bot in every single way. In fact at this point I think this is my most elegant bot to date. It's not as flashy as my other scipts but it is an extremely reliable performer and comes with lower risk than some of my other more outlandish automated trading ideas.

Concept

This script monitors the RSI of all timeframes you have picked in settings and displays chosen values on your chart. It defaults to 5m, 15m and 30m enabled with the rest of the timeframe options disabled and it will only show the RSI chart of timeframes you are currently using. You can specify one or more (in any combination) from the following list:

1m
5m
15m
30m
1h
4h
1d
1w

On each bar it checks each timeframe's RSI value to see if it is is lower (for a buy) or higher (for a sell) than the respective threshold you have picked in settings for that timeframe. On any given bar if enough of your used RSI values are above or below their respective thresholds to be equal to or greater than your set Number of Thresholds for Buy value a buy or sell is executed. In other words, when the number of total (different timeframed) RSI buy thresholds currently met is equal to or greater than the Number of Thresholds for a Buy value you set in settings, a buy is placed. Similarly, when the total number of differently timeframed RSI sell thresholds currently hit is equal to or greater than the total sell threshold you have in settings, a sell is placed.

I have had the best results using 5m, 15 and 30m together with the total threshold value for both buys and sells set to three which is what I left as the default. However, there are limitless ways to use this and I'm sure that over the coming months I will come up with some more creative ways to use it. Please experiment a bit and if you feel like sharing you can comment on this page as to what you find works best.

Like all my scripts this includes a date backtester. I have the start date set to Nov 1, 2021 because I feel you should never backtest a new strategy on older data if you don't specifically have a reason to do it. You likely won't get reliable results, hence the date selector.

Settings

Number of Thresholds for Buy
This is a global setting. You can use any positive whole number here that is one or greater. If it is set to one, one or more of the RSI thresholds you have selected for each chart timeframe will need to be lower than the RSI threshold value you have set for that particular timeframe's settings and once that happens the bot will buy. For example, if I have this value set to (1) and I am using a 5m, 15m and 30m chart, a buy will be placed on the first bar that any of these RSIs drop to below the respective value you have set for them in settings. If I have it set to two in the same scenario, I will need at least two RSI values to be below their respective thresholds. Since each RSI value is set separately you have a ton of creative options here. I refer to the number of currently met RSI buy thresholds per bar as 'buy count' going forward in this document. The buy count resets to zero each bar which means they will all need to be met on the same bar. You will need to make sure this setting is equal to or less than the number of differently timeframed RSIs you are using or it won't ever buy. For example, if you are using only a 5m and 15m RSI but I have the Number of Thresholds for Buy set to three it will never make a buy because you will have at max two thresholds met.

Number of Thresholds for Sell
This is the same concept above except for sells obviously. I chose to make these independent for maximum flexibility but you can obviously use the same value for both if you'd like. I refer to the number of currently met RSI sell thresholds as 'sell count' for the rest of this document. You will need to make sure this number is equal to or less than the number of differently timeframed RSIs you are using or you will potentially get a buy but never a sell. Use the backtester to figure this out or message me if you get stuck.

Display Multi RSI Table?
This will show you all of the available RSI settings that are currently in play. Note that only timeframes which are equal to or higher than your current TradingView chart timeframe will be accurate. This is due to the fact that these values are looked up once per bar, so if you are set to a 1h chart you won't get 5m values every 5m, instead getting the 5m RSI once per hour. For best results set your chart to the lowest timeframe that you have enabled from the options below this.

Use XX RSI?
This turns a particular timeframe's RSI off and on. If you turn it off it will disappear from the chart and its thresholds won't be applied to the strategy.

XX RSI Length
You can set the RSI length for each timeframe you want to use separately. The default value is 14.

XX RSI Buy / Sell Threshold
These are all also set separately for each timeframe. Any time XX timeframe's RSI is below the Buy Threshold for that timeframe it will increase the buy count by +1 for that bar. Since the count resets to zero each bar, you will need to have at least your Number of Thresholds for Buy worth of RSI values below their respective thresholds on any given bar for a buy to happen. The opposite is true for sells.


Usage

For each timeframe you pick you will also need to set a buy and a sell threshold. I have the defaults set to 30 and 70 which is pretty standard but you should experiment and see what works best for you. Each individual timeframe has its own buy and sell threshold which makes this script about as customizable as you want it to be.

Set your chart to the lowest timeframe that you are using, ie if you are using 1h, 4h and 1d use a 1h chart. If you are using 5m, 15m and 30m use a 5m chart. You need to do this because it will only refresh each RSI on the interval your chart is set to, so if you have 5m, 15m and 30m but use a 1h chart the strategy will basically lose most of its effectiveness because there should be twelve different 5m RSI values in each hour but you will only recalculate once every hour since your chart is set to one hour, and will therefore only get one 5m value, one 15m value and one 30m value per 1h bar. If you don't understand this just trust me and set it to the lowest timeframe you are currently using.

I didn't put a stop loss in this version but I will in the next update.

I think that's about it! If you have questions please ask. I give access to this script away for free for testing but in order to use it with 3commas you will need the entire script. Message me if you want it and we can figure something out.
Notes de version:
I updated this bot to include a stop loss which actually increases its historical profitability quite a bit. I didn't expect it to be such a huge improvement but here it is.
Notes de version:
Another small update - I added an optional target take profit setting so that if you want to take profit at a certain percentage and not wait for RSI signals to process you can do it now.

I also added a label that appears whenever your RSI buy or sell conditions are met. The buy labels are white and the sell labels are red. Note that these will occur every time your buy or sell conditions are met, not just when an actual buy or sell happens. If you have a potential sell point but have no deal going it will still show the label. I chose to create it this way because you can already display trades on the chart via TradingView's built in function so it made more sense to me to give more (and more varied) info. Too much info never hurt this trader!
Script protégé
Ce script est publié en code source fermé et vous pouvez l'utiliser librement. Vous pouvez le préférer pour l'utiliser sur un graphique. Vous ne pouvez pas visualiser ou modifier son code source.
Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.

Vous voulez utiliser ce script sur un graphique ?