TradingView
Solutions1978
10 מרץ 2021 22:29

RSI Mean Reversion Bot Strategy 

Bancor / United States DollarCoinbase

תיאור

I started developing this strategy as a way to plug in and test values before defining them in the bots on 3Commas, Coinrule, and Quadency. None of those bots performed the same way my script did and I kept working on it until the strategy finally yielded the same simulated results when paired with the Tradingview bot on Quadency. I looked at all the different RSI strategies already published and saw what each was missing and changed it in mine to make it better:

1. Backtest an actual timeframe by date and time
2. Define the RSI price source
3. Fully manipulate the RSI length
4. Define a stop loss that works
5. Pick Long or Short, or both, based on market conditions. Or compare side by side to decide which you want.

הערות שחרור

Since I saw quite a few likes to my previous script I decided to try and make it better since it was taking me so much time tinkering and guessing the right upper and lower values. After I figured out that I could move the strategy to its own pane, I decided to snazz it up.

1. This provides you with the visualizations of the Fast vs Slow EMA as background colors showing bear and bull conditions
2. It shows a Stochastic RSI overlay to give you a visual check of whether or not you are setting the oversold and overbought values in the wrong region
3. I used the EMA and OHLC to create a smooth candle for the price with the RSI overlaid on it so it is easier to see
4. I added risk management to it with target profit and stop loss

I tested the strategy today on MANA with $450 and it has yielded $109 in actual profit which is close enough to what the strategy shows for the time period I let it run in Short Only mode. When I tried adding trailing to the stop loss and take profit functions I received the re-drawing warning so I abandoned that. This is a solid strategy that pairs the three leading strategies to help you with setting it up.

Word of caution to anyone new to using strategies on bots, the RSI strategy is not a set it and forget it strategy. It requires tinkering on a daily basis with the crypto market. The date range can be set into the future to avoid any shedding of tears, I typically have it run through 5 am and then check on it when I wake up and adjust accordingly. It has not failed me yet in the previous iterations and this one just makes the adjustments take 5 minutes as opposed to 20 minutes.

הערות שחרור

Published wrong version, this one has the smooth candle for price that is rescaled to work.

הערות שחרור

Forgot to update the showcase when I published the previous fix. I need sleep.

הערות שחרור

1. Fixed Risk Management bug that was not calculating exit prices correctly
2. Fixed the color of the RSI plot so it shows clearly
3. Added option to hide the Stochastic RSI background
4. Fixed the cross logic to maximize profits in entry and exit

הערות שחרור

I've updated this script with some of the updates I made to my other scripts, but still kept this one focused on a simple RSI strategy. The inputs only depend on the RSI inputs and back test dates. The other inputs for K, D, and EMA are only for visualization of the zone overlays to help visualize bear and bull markets.

The back test settings shown in this publication are for EOS on the week of 23 May through 30 May.

Chart Resolution = 30 minutes

Start Time = 24 May 2021 00:00
End Time = 31 December 2021 00:00

Trade Types = Long/Short
Stop Loss % = 2.27
Target Profit % = 12.18

RSI Length = 11
Source = Close
Overbought = 77
Oversold = 31

All other settings are default.
תגובות
aryashiv
Great script! Thank you for all your hard work.. but i checked alert but alert not configured. requested pls
bluewater4000
Great script! Thank you for all your hard work. I noticed that the pyramiding feature does not work. For example if I set it to an order size of 10% equity and increase the pyramid number to 10 then I would expect to see multiple buy/sell signals show up consecutively in certain cases but this does not happen. It is always as if the setting is 100% equity for the order size with a pyramid of 1, no matter what the actual setting are. Am I missing something?
egranville
Hi Solutions1978!
We're born the same year!! :D

I liked your research on the RSI level that brought you to this conclusion. I happened to read it in an article and since then always practice bearish and bullish settings for a lot of indicators. Stoch RSI seems to vary a lot less and has a very sharp entrance but needs something extra to help you choose the right one. I try to add price action (patterns) and some trend line. EMA 200.

Any tips on where to start (I'm a PHP, Node programmer) with neural networks to do researches like you did? And where did you get your data from? Binance? I believe a good script needs some code that constantly tests the recent price action to adapt settings. Also, settings always influence each other. I would like to see a TV feature that runs a quantum computer like process on our inputs to determine the best combinations
Canmexly
You have put a lot of energy into your script. Thank you!
Solutions1978
@Canmexly, thank you.
bluiska
Great script, thanks for sharing! You mentioned: "Word of caution to anyone new to using strategies on bots, the RSI strategy is not a set it and forget it strategy. It requires tinkering on a daily basis with the crypto market". What do you mean by this? What is a sign that you look for that needs adjusting and what do you adjust?
Solutions1978
@bluiska, in crypto markets the RSI is not simply 70 for overbought and 30 for oversold is something I found out after foolishly losing a bit of money with RSI bots on 3commas and Quadency. I pulled out of those and started tinkering with my own strategy and studying the markets closely. I then built an AI based program on Amazon Web Service using their neural network algorithms and my eyes were opened. This is what I found out:

1. RSI channels fluctuate during the day depending on what part of the world is awake and trading. For example, I live in the Central time zone in the US and found that between the hours of 10 pm and 6 am the RSI channel typically moves to somewhere between 40 and 50 for oversold and 60 to 68 for overbought.

2. RSI channels change dramatically Fridays through Sunday night. This is what I started calling the Noob Rush, or it might actually be seasoned traders but I like the Noob term better. Every Friday, without fail, around 2 pm everything starts dropping a bit. Not a whole lot, but enough to make a few bucks if you time it right. So I started watching things beginning at noon and have some triggers based on percent decrease for Fridays that I set up. If things decrease between 2.7 and 3.2% consistently for the past 5 bars, then the Friday Noob rush has begun and I sell my holdings. I then wait until the crypto starts to increase before getting back in. At that time the RSI channel may just be between 42 and 54. So I set those as my triggers and usually fair pretty well (about $10 - $40 in returns because things move slower on weekends).

3. Every time some rich, pompous, arrogant brat on Twitter says something on Twitter (you know who I am talking about), the market quivers and drops. I jump in and tinker with my RSI settings when that happens because a bearish market is in the cards for the next few days or weeks.

4. Speaking of bear and bull, this is why I added the market trend to the indicator. In a bear market you want to use Short Only, and in a bull market you want to use Long Only in this strategy. In a market that is fluctuating and has no identity with a lot of volatility, you can use Long/Short but make sure the strategy points to two different portfolios. Don't Long/Short simultaneously on the same portfolio using the same bucket of coins.

Hope this helps. If you have any other questions please feel free to PM me. Sorry it took me so long to respond I am still new to TradingView and getting used to the notifications here.
stanfordisimi123
@Solutions1978, I would like to ask you, which algorithm of AI & machine learning you used?
Solutions1978
@stanfordisimi123, AWS Neural Networks is what I am using with base code I developed using Python 3. I am playing around with their latest offering, Sage Maker, and thus far am less than impressed with their canned solution.
Solutions1978
@bluiska, here is something you can add to the script and it will help you determine what the RSI values should be. It is not 100%, but it will get you to within +/- 2 of the right RSI value that you can check with the back testing in real time:

AvgHigh(src,cnt,val) =>
total = 0.0
count = 0
for i = 0 to cnt
if src > val
count := count + 1
total := total + src
round(total / count)

RSI_high = AvgHigh(RSI, 9, 60)

AvgLow(src,cnt,val) =>
total = 0.0
count = 0
for i = 5 to cnt by 5
li = lowestbars(src, i)
if src < val
count := count + 1
total := total + src
round(total / count)

RSI_low = AvgLow(RSI, 100, 45)

f_print("Recommended RSI Settings:" + "\nOversold = " + tostring(RSI_high) + "\nOverbought = " + tostring(RSI_low))
עוד