Gekko Forum
[SHARE] Simple RSI BULL/BEAR strategy - Printable Version

+- Gekko Forum (https://forum.gekko.wizb.it)
+-- Forum: Gekko (https://forum.gekko.wizb.it/forum-13.html)
+--- Forum: Strategy Development (https://forum.gekko.wizb.it/forum-12.html)
+--- Thread: [SHARE] Simple RSI BULL/BEAR strategy (/thread-100.html)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38


[SHARE] Simple RSI BULL/BEAR strategy - tommiehansen - 01-31-2018

The general idea is quite simple: RSI between A and B works best in trend C but workes less great in trend D. So... use that knowledge to do A when B and C when D.

Works best with shorter duration candles in the ranges of 5-30 minutes but this of course depends on the pair. Please do your own backtests and please do not expect the default settings to always work.

This strategy has two variations, one simply called "RSI BULL/BEAR" and a modification called "RSI BULL/BEAR ADX". The latter is an improvement and most often yields better results since it adds logic to modify the RSI params when more rapid changes are detected using ADX (https://tulipindicators.org/adx). A simple way to test the strategy is to begin with the original (since it's faster because less params) and then use the ADX-version to improve upon the results.


---

Backtest samples


XRP-USDT, dec 2017 - jan 31 2018
https://i.imgur.com/4bcYnNm.png

XRP-USDT, 2016-10-15 - 2018-01-21
https://i.imgur.com/ZoUfeaT.png

ETH-USDT: 2016-01-01 - 2017-10-05
https://i.imgur.com/Yz0t4VN.png

NEO-USDT: 2017-12-01 - 2018-02-03
https://i.imgur.com/rqHjgyM.png

Note: These are only samples, one can of course yield better results with other parameters.
In some cases one can even create backtests results that has quite insane returns and makes
the above backtests look bad.


---

Instructions for use

1. Clone the repo:
git clone https://github.com/tommiehansen/gekko_tools.git
...or just download it from https://github.com/tommiehansen/gekko_tools

2. Copy JS-files e.g. RSI_BULL_BEAR.js to /gekko/strategies
3. Copy TOML-files e.g. RSI_BULL_BEAR.toml to /gekko/config/strategies
-
4. Versions after the 18th of march of the strategies also requires custom indicators, get here:
https://github.com/Gab0/gekko-extra-indicators
5. ...and add to gekko/strategies/indicators.


Running it live
Make sure Gekko downloads the necessary data needed. Else the strategy will be stuck in 'BEAR'-mode and won't trade.
Your Warmup period should reflect what you have set as SMA_long since the strategy will need that length of data in order to properly see if there's a BULL or BEAR trend.
Also make sure Gekko (check your console) tells you that it is downloading the necessary data before it starts running, you should get a message about this.

---

Q&A


Q: Adding a stoploss would be great
A: No, this has been tested several times and always gives less performance for quite obvious reasons.
-
Q: It did a bad trade
A: Yes, none of this strategies manages to always make good trades.
-
Q: When running live it does nothing
A: See 'Runing it live'
-
Q: It doesn't work
A: This is unrelated to the strategies, try another forum thread
-
Q: Using X instead of Y would be better
A: Maybe? Modify the strategy and share the results!

---

Download / latest versions

To get the latest versions goto (and modifications):
https://github.com/tommiehansen/gekko_tools/tree/master/strategies

...or just clone on your drive somewhere:
git clone https://github.com/tommiehansen/gekko_tools.git


RE: Share: Simple RSI BULL/BEAR strategy - susitronix - 01-31-2018

wow this looks GOOD.
Thanks alot for sharing. Will try it. nice!!!

Works a treat!
Only tested with BTC/Usdt 15min 2month/Binance.
Not the right setting but the Buy/Sell signal looks superPromising THANKS!
impressive structure.


RE: Share: Simple RSI BULL/BEAR strategy - tommiehansen - 02-01-2018

(01-31-2018, 09:30 PM)susitronix Wrote: wow this looks GOOD.
Thanks alot for sharing. Will try it. nice!!!

Works a treat!
Only tested with BTC/Usdt 15min 2month/Binance.
Not the right setting but the Buy/Sell signal looks superPromising THANKS!
impressive structure.

For BTC or higher valued coins you'd want different timings and settings as you say. BTC, eventhough crypto, is a bit more stable then say XRP and 'smaller' coins.

But here's a 10-month backtest using BTC:
https://i.imgur.com/HWkurC1.png

When backtesting against BTC you'd also have to remember that you'd be backtesting against all other bots and strategies that people use as well. :-)


RE: Share: Simple RSI BULL/BEAR strategy - susitronix - 02-01-2018

That Code of yours is astonishing!
Its so direct and nice structurized.

With a few Backtesting on:
Usdt/Neo
Usdt/Btc

Result very satisfying allready.
Works best with 11 minutes Candles.
Looks like the Daytrader i was looking for.

Only downside:
if at the Bull Trend the last Trade was a Buy,
then, when entering the Bear Trend, it would keep the Bag maybe because of the "BullTrend.WaitState"?

You obviously must be one of the smart guys but kind enough to share with us... Thanks

Looks good

But thats the most impressive Part that it allready begin to work a treat by only change to 11 minutes Candles.
Imagine what a proper Optimatisation could do!

This clearly proves for me that the code of yours works.

The Importer is not finished Download otherwise i will try Stoploss like so:



Code:
   // BEAR TREND
   if( maFast < maSlow )
   {
        // in case before Trendreversal the last trade, is a buy?
        if( this.advice == 'long');
        {    
        // get rid of the BAG
            this.advice ('short');
        }    
       log.debug('BEAR Trend');
       rsi = ind.BEAR_RSI.result.result;
       if( rsi > this.settings.BEAR_RSI_high ) goShort = true;
       if( rsi < this.settings.BEAR_RSI_low )  goLong = true;



RE: Share: Simple RSI BULL/BEAR strategy - tommiehansen - 02-01-2018

Yes, it will 'keep the bag' as you say and that's one of the things one would want to fix since a reversal in the trend would be a quite clear sign that it would be time to accept a loss.

I tested it now though and that simple thing does not really do much except hurt the strategy. What ends up happening is that the strategy sells and then buys again since the MA comes close to the RSI-buy at the BEAR trend. One can clearly see this since some time periods becomes only 1 candle long. That isn't always awful but the short tests i did it hurt more then it gave profits.

Here's the code that i used:

Code:
    // BEAR TREND
    if( maFast < maSlow )
    {
        // check if it's a trend reversal
        if( this.trend.adviced && this.trend.direction == 'up' )
        {
            this.advice('short'); // drop dead weight
        }
        
        log.debug('BEAR Trend');
        rsi = ind.BEAR_RSI.result.result;
        if( rsi > this.settings.BEAR_RSI_high ) goShort = true;
        if( rsi < this.settings.BEAR_RSI_low )  goLong = true;
    }
Could do with more refinments and having a reversal ofc will make it possible to adjust all other values as well. Would need to be backtested on a larger amount of data as well.

This first thing was just a sort of baseline idea. :-)

Note: I would also wait until the bugs regarding the TULIP indicators gets properly fix since they might give some bad data at the moment, see:
https://github.com/askmike/gekko/issues/1827

This strategy will still work since the idea is sound in itself but the specific parameters would probably need to be modified.


RE: Share: Simple RSI BULL/BEAR strategy - susitronix - 02-01-2018

TESTED:
Binance USDT/ETH
1month
14 minutes Candles
with your Strat makes 67%
my addition does not work make only 59%

Maybe i would need to compare the lastBuyPrice from the portofolioManager,
to set a dynamic Stoploss


RE: Share: Simple RSI BULL/BEAR strategy - tommiehansen - 02-01-2018

What you're looking for is basically a trailing stoploss. I have no idea how to implement that in Gekko but if i were to code it in pure js i would just set this trail (which would consist of the current price) everytime a long position is taken and then check it on every candle etc. The logic is quite basic.

Doesn't need to be that fancy, just needs this:
1. A new option in the TOML-file so that it can be configured
2. It need to be percentage based (since anything else would be awful); so need to calc percentage between current price and old price (trail)
3. If executed the rest of the stuff should obviously stop until next candle (at least)

Edit: Tried that other trail with USD-BTC-data at 1 year and 8 months @ 11 min but my Gekko is just crashing with that amount of data.
Edit 2: You really need to test with more data when you test. 1 month is hardly enough. :-)


RE: Share: Simple RSI BULL/BEAR strategy - susitronix - 02-01-2018

Thanks for the Hint.
I am just new to write code sorry. So i begun with notepad++ but fund that i must use Java JDK.
..and learn a bit more
Guess the jdk will help me implement the
/plugins/trader/portofolioManager //var price

First ill test your strat properly, and give it a try.
Looking for the Tulip-issue.


RE: Share: Simple RSI BULL/BEAR strategy - susitronix - 02-01-2018

I like your idea of TrendDirection. just a busy day

Found Stoploss article by Werkkrew:

Emit Trade to Strategy #1810
https://github.com/askmike/gekko/pull/1810


RE: Share: Simple RSI BULL/BEAR strategy - tommiehansen - 02-02-2018

That is in some sort of beta it would seem. Do note that the original strategy has a sort of stop-loss though since in trend reversel the RSI High gets a lower value meaning a sell will be triggered at a lower level.