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


RE: [SHARE] Simple RSI BULL/BEAR strategy - jvs - 03-19-2018

(03-19-2018, 05:53 AM)tommiehansen Wrote:
(03-18-2018, 11:30 PM)jvs Wrote: Gentleman - over the weekend I left a box running testing different settings on the strategy.

I set it to change 4 settings:

Candle size: From 300 seconds (5 minutes) to 3600 seconds (1 hour), in steps of 1 minute.
SMA Fast Period: From 20 periods to 95 periods, in steps of 5.
SMA Slow Period: From 100 periods to 2000 periods, in steps of 20.
ADX Period: From 2 periods to 20 periods, in steps of 1.

So, 1.4 odd million tests later - testing on a dataset of ETH/USDT from 1/1/2016 to 1/3/2018, the setting that came out tops was....(drum roll)

Candle size: 480 seconds (8 minutes)
SMA Fast Period: 95
SMA Slow Period: 200
ADX Period: 3

The default settings of candle size 15 minutes, SMA Fast of 50 periods and slow of 1000 periods, results in a return of around 242,621%

Good for you, do note that the default is the default though and will not be optimized for anything basically. Smile

I'll also ramp up testing since i've just finished making something usable of the PHP-stuff i've been writing that makes it simpler to do brute-force tests with more dynamic parameters. Something that is needed to really test something and where the run time can be over 20 hours (and over 5000 runs per go) and so on, here's a screen of the current 'run screen':
https://i.imgur.com/j5I3eWH.png

There just isn't any feasible way of testing things 'for real' with the current Gekko UI.

How do you think you will go about looping through the different ranges?

I just used a whole bunch of nested for loops... I can't help but think there is a better way...

Code:
foreach (range(300, 3600, 60) as $candle){
    foreach(range(20,95,5) as $smaFastPeriod){
        foreach(range(100,2000,20) as $smaSlowPeriod){
            foreach(range(2,20,1) as $adxPeriod){



RE: [SHARE] Simple RSI BULL/BEAR strategy - tommiehansen - 03-20-2018

(03-19-2018, 09:49 PM)jvs Wrote:
(03-19-2018, 05:53 AM)tommiehansen Wrote:
(03-18-2018, 11:30 PM)jvs Wrote: Gentleman - over the weekend I left a box running testing different settings on the strategy.

I set it to change 4 settings:

Candle size: From 300 seconds (5 minutes) to 3600 seconds (1 hour), in steps of 1 minute.
SMA Fast Period: From 20 periods to 95 periods, in steps of 5.
SMA Slow Period: From 100 periods to 2000 periods, in steps of 20.
ADX Period: From 2 periods to 20 periods, in steps of 1.

So, 1.4 odd million tests later - testing on a dataset of ETH/USDT from 1/1/2016 to 1/3/2018, the setting that came out tops was....(drum roll)

Candle size: 480 seconds (8 minutes)
SMA Fast Period: 95
SMA Slow Period: 200
ADX Period: 3

The default settings of candle size 15 minutes, SMA Fast of 50 periods and slow of 1000 periods, results in a return of around 242,621%

Good for you, do note that the default is the default though and will not be optimized for anything basically. Smile

I'll also ramp up testing since i've just finished making something usable of the PHP-stuff i've been writing that makes it simpler to do brute-force tests with more dynamic parameters. Something that is needed to really test something and where the run time can be over 20 hours (and over 5000 runs per go) and so on, here's a screen of the current 'run screen':
https://i.imgur.com/j5I3eWH.png

There just isn't any feasible way of testing things 'for real' with the current Gekko UI.

How do you think you will go about looping through the different ranges?

I just used a whole bunch of nested for loops... I can't help but think there is a better way...

Code:
foreach (range(300, 3600, 60) as $candle){
    foreach(range(20,95,5) as $smaFastPeriod){
        foreach(range(100,2000,20) as $smaSlowPeriod){
            foreach(range(2,20,1) as $adxPeriod){

You just take min/max/stepping, create a range out of it and choose a random value out of it.
Why would you bloody hardcode the params ... ?

Say this is my format:
SMA_short = 10:100,10
RSI = 5:15,5

MIN/MAX/STEPPING

Just create a range out of it and select one random via shuffle() or any other random func (which is best depends on PHP-version... i suggest using 7.1+):

PHP Code:
// loop all lines
$lines preg_split("/((\r?\n)|(\r\n?))/"$params);
$new '';
$hasError false;

foreach(
$lines as $line)
 
 {
 
 if (contains(':'$line))
 
   {

 
   // all lines must has equals sign so use to explode

 
   $lineArr explode('='$line);
 
   $vals rmspace($lineArr[1]);
 
   $vals str_replace(','':'$vals); // make all separators : for simplicy
 
   $vals explode(':'$vals); // create array

 
   // get min/max

 
   $min $vals[0];
 
   $max $vals[1];

 
   // error check

 
   if (!empty($vals[2]))
 
     {

 
     // not empty, get stepping

 
     $step $vals[2];
 
     }
 
     else
      
{
 
     $hasError[] = 'No stepping set. Format is min:max,stepping';
 
     continue;
 
     }

 
   // generate entire range

 
   $range range(0$max$step);

 
   // ..then remove all under $min

 
   foreach($range as $key => $val)
 
     {
 
     if ($range[$key] < $min) unset($range[$key]);
 
     }

 
   // ...and add back $min

 
   $range[0] = $min;

 
   // all above is due to the fact that range() is inclusive and thus we need this logic
 
   // TODO: make a function out of this
 
   // shuffle and get first from shuffled

 
   shuffle($range);
 
   $range $range[0];

 
   // put back at line

 
   $new.= $lineArr[0] . '= ' $range "\n";
 
   }

 
 // else just add to new lines

 
   else
    
{
 
   $new.= $line "\n";
 
   }
 
 

This is just a sample that would take input from e.g. a textarea etc.
rmspace() will not exist since it's a custom function (it just cleans any spaces, tabs etc that might exist) etc but you get the point (or if not -- this is beyond your coding ability, sorry).


RE: [SHARE] Simple RSI BULL/BEAR strategy - mfilipow - 03-20-2018

Hi guys,
sorry if this is a simple issue, but I have problems installing the ADX version of the script.
I installed the extra indicators to the following order: gekko\strategies\indicators, but when I try to run a backtest, I get the following error:

2018-03-20 20:39:54 (ERROR):    Failed to load indicator ADX
2018-03-20 20:39:54 (ERROR):    Failed to load indicator ATR
2018-03-20 20:39:54 (ERROR):    Failed to load indicator BBANDS
2018-03-20 20:39:54 (ERROR):    Failed to load indicator DX
2018-03-20 20:39:54 (ERROR):    Failed to load indicator TRANGE

am I missing something? I run gekko under Win 10 with WSL (Debian).
Talib and Tulip did install well, so no problem there. Just those 5 indicators Tommie modified on March 18th.

BTW: is there an option to get the older Version of the ADX script (the latest befor March 18th), - before this change was made? I was not able to find it on github anymore.

Thank you in advance.
Michael


RE: [SHARE] Simple RSI BULL/BEAR strategy - imsami - 03-20-2018

(03-18-2018, 11:30 PM)jvs Wrote: Gentleman - over the weekend I left a box running testing different settings on the strategy.

I set it to change 4 settings:

Candle size: From 300 seconds (5 minutes) to 3600 seconds (1 hour), in steps of 1 minute.
SMA Fast Period: From 20 periods to 95 periods, in steps of 5.
SMA Slow Period: From 100 periods to 2000 periods, in steps of 20.
ADX Period: From 2 periods to 20 periods, in steps of 1.

So, 1.4 odd million tests later - testing on a dataset of ETH/USDT from 1/1/2016 to 1/3/2018, the setting that came out tops was....(drum roll)

Candle size: 480 seconds (8 minutes)
SMA Fast Period: 95
SMA Slow Period: 200
ADX Period: 3

The default settings of candle size 15 minutes, SMA Fast of 50 periods and slow of 1000 periods, results in a return of around 242,621%

The above settings, result in a return of 72,145,604%.

Yes, 72 million percent.

If you put in $1000 on Jan 1 2016, you would now be holding over $721 million dollars.

GIANT GODDAMN CAVEAT!!!
The strategy outlined above is a trade everything strategy. That means towards the end, it was theoretically placing buy and sell orders of hundreds of millions of dollars PER ORDER. Of course in reality, this would result in massive slippage, and probably crash the market every time you traded.  So the reality is you would be playing with much, much, MUCH smaller traders - so your total return will be much, much, MUCH smaller. However, it wouldn't be unreasonable to think that you could easily be in the 7 figure bracket. (Hodling during this period, you would have around $800k).


Now, no trading strategy is any good if it can't trade well during bear markets, like what we are seeing at the moment. So I tested the settings on the following bear markets (All USDT base, all with a starting figure of $1000 USD):

BTC 1 Jun 2014 - 10 Nov 2014
Hodl: $561
Strategy Original Settings: $878
Strategy New Settings: $835
Delta: $273

ETH 13 June 2017 - 17 July 2017
Hodl: $388
Strategy Original Settings: $1004
Strategy New Settings: $1158
Delta: $770

Also the following from the 8th Jan to today - the current big bear market we're all coming to hate:

ETH:
Hodl: $495
Strategy Original Settings: $984
Strategy New Settings: $1861
Delta: $1366

LTC:
Hodl: $603
Strategy Original Settings: $988
Strategy New Settings: $1144
Delta: $540

NEO:
Hodl: $514
Strategy Original Settings: $758
Strategy New Settings:: $1722
Delta: $1207

BTC:
hodl: $492
Strategy Original Settings: $897
Strategy New Settings: $587
delta: $94

So aside from BTC, this thing still made coin during the past 3 months.

A final caveat. I'm not actually using gekko for my testing. I have written my own test platform in PHP using the trader extension, which in turns uses TA Lib. I have re-written the strategy in this thread in PHP to suit. Side to side testing has given similar results - but please I beg you to do your own testing with these settings to make sure they line up with your own settings! For some reason I don't 100% trust the hodling results that my script is giving... I think it's getting it's initial value from the wrong place.

I still feel there is more to get out of this strategy, but the shear amount of settings would mean there could be billions of different combinations to test. I feel that the 4 variables I tested above are the most "important", but if anyone else begs to differ and wishes me to bulk-test other settings, let me know!

Happy to hear your thougths

Sorry I am new but I dont find any settings You have mentioned. Is this for BSI_BULL_BEAR_ADX.js ?

My settings look like this wher is other to set ? I will be glad if anyone guide me through this . Thanks
[Image: 29497216_416538028788000_587500209394050...e=5B2FD2F4]


RE: [SHARE] Simple RSI BULL/BEAR strategy - imsami - 03-20-2018

Any suggestions for btc-xrp pari on binance? It will be really helpful. Thanks


RE: [SHARE] Simple RSI BULL/BEAR strategy - timvang - 03-21-2018

(03-20-2018, 08:20 PM)mfilipow Wrote: Hi guys,
sorry if this is a simple issue, but I have problems installing the ADX version of the script.
I installed the extra indicators to the following order: gekko\strategies\indicators, but when I try to run a backtest, I get the following error:

2018-03-20 20:39:54 (ERROR):    Failed to load indicator ADX
2018-03-20 20:39:54 (ERROR):    Failed to load indicator ATR
2018-03-20 20:39:54 (ERROR):    Failed to load indicator BBANDS
2018-03-20 20:39:54 (ERROR):    Failed to load indicator DX
2018-03-20 20:39:54 (ERROR):    Failed to load indicator TRANGE

am I missing something? I run gekko under Win 10 with WSL (Debian).
Talib and Tulip did install well, so no problem there. Just those 5 indicators Tommie modified on March 18th.

BTW: is there an option to get the older Version of the ADX script (the latest befor March 18th), - before this change was made? I was not able to find it on github anymore.

Thank you in advance.
Michael

Did you copy those indicators from gekko-extra-indicators to your gekko/strategies/indicators?

I just downloaded and tested the March 18th version. It ran much faster than the old version as expected. However, the simulated profit from the new version was always less than the one from the old version for every backtest I ran. I wonder if anyone is getting the same result?
 


RE: [SHARE] Simple RSI BULL/BEAR strategy - tommiehansen - 03-21-2018

(03-21-2018, 05:54 AM)timvang Wrote: I just downloaded and tested the March 18th version. It ran much faster than the old version as expected. However, the simulated profit from the new version was always less than the one from the old version for every backtest I ran. I wonder if anyone is getting the same result?
 

Yes, i've seen that too. The problem is that tulip rsi and native rsi differs. This can be seen pretty easily since the both the ADX and the regular version comes with a logger that logs min/max that can be setup to show that stuff after a run.

Which of the one is more correct then the other is a different question though.


RE: [SHARE] Simple RSI BULL/BEAR strategy - FeRm00 - 03-23-2018

(01-31-2018, 07:53 PM)tommiehanse Wrote: 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.

First of all, thank you so much to share your strategy and your time with us!

I have done test for a lone time,  i am playing now a little with the live Gekko. I would like to ask you about this point.

If a set SMA_long in 600, I will should also set the warmup period in 600 ? With CandleSize in 11 minutes, it means I need 1 week and 15 hours of data.


RE: [SHARE] Simple RSI BULL/BEAR strategy - Kris191 - 03-24-2018

Hi all, not sure if this has been asked before but can this strategy be programmed to only short on prices above the the previous buy price? and go long below the previous sell price?

I'm aware that bots will make negative trades and the market is bearish these day but just wondering?


RE: [SHARE] Simple RSI BULL/BEAR strategy - tommiehansen - 03-24-2018

(03-23-2018, 06:52 PM)FeRm00 Wrote:
(01-31-2018, 07:53 PM)tommiehanse Wrote: 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.

First of all, thank you so much to share your strategy and your time with us!

I have done test for a lone time,  i am playing now a little with the live Gekko. I would like to ask you about this point.

If a set SMA_long in 600, I will should also set the warmup period in 600 ? With CandleSize in 11 minutes, it means I need 1 week and 15 hours of data.

Yes, but your calculation is wrong.

600 @ 11 minutes = 600 x 11 = 6600 minutes
-
6600 / 60 = 110 (hours)
110/24 = 4.5833 (days)
4.5833/7 = 0.6547 (weeks)

This might be a good tip (for those that don't know):
If using browser Google Chrome...
1. Type 600*11= in your adress bar (where you type urls..)
2. When you get the number type 6600 minutes to days in the adress bar and you'll get the number of days directly instead of having to do the calculations

If you're using Android's Google Voice or Apple's Siri you can ask it to calculate such things as well.

Screen:

[Image: bw65F9k.png]