Skip to content

Commit

Permalink
Switch samplestrategy from ADX to RSI
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Oct 15, 2019
1 parent ace7051 commit e6e35c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions docs/strategy-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""
dataframe.loc[
(
(qtpylib.crossed_above(dataframe['adx'], 30)) & # Signal: ADX crosses above 30
(qtpylib.crossed_above(dataframe['rsi'], 30)) & # Signal: RSI crosses above 30
(dataframe['tema'] <= dataframe['bb_middleband']) & # Guard
(dataframe['tema'] > dataframe['tema'].shift(1)) & # Guard
(dataframe['volume'] > 0) # Make sure Volume is not 0
Expand All @@ -149,7 +149,7 @@ def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
```

!!! Note
Buying requires sellers to buy from - therefore volume needs to be > 0 (`dataframe['volume'] > 0`) to make sure that the does not buy/sell in no-activity periods.
Buying requires sellers to buy from - therefore volume needs to be > 0 (`dataframe['volume'] > 0`) to make sure that the bot does not buy/sell in no-activity periods.

### Sell signal rules

Expand All @@ -172,7 +172,7 @@ def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame
"""
dataframe.loc[
(
(qtpylib.crossed_above(dataframe['adx'], 70)) & # Signal: ADX crosses above 70
(qtpylib.crossed_above(dataframe['rsi'], 70)) & # Signal: RSI crosses above 70
(dataframe['tema'] > dataframe['bb_middleband']) & # Guard
(dataframe['tema'] < dataframe['tema'].shift(1)) & # Guard
(dataframe['volume'] > 0) # Make sure Volume is not 0
Expand Down
4 changes: 2 additions & 2 deletions tests/strategy/test_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_search_strategy():
def test_load_strategy(default_conf, result):
default_conf.update({'strategy': 'SampleStrategy'})
resolver = StrategyResolver(default_conf)
assert 'adx' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
assert 'rsi' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})


def test_load_strategy_base64(result, caplog, default_conf):
Expand All @@ -48,7 +48,7 @@ def test_load_strategy_base64(result, caplog, default_conf):
default_conf.update({'strategy': 'SampleStrategy:{}'.format(encoded_string)})

resolver = StrategyResolver(default_conf)
assert 'adx' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
assert 'rsi' in resolver.strategy.advise_indicators(result, {'pair': 'ETH/BTC'})
# Make sure strategy was loaded from base64 (using temp directory)!!
assert log_has_re(r"Using resolved strategy SampleStrategy from '"
+ tempfile.gettempdir() + r"/.*/SampleStrategy\.py'\.\.\.", caplog)
Expand Down
11 changes: 5 additions & 6 deletions user_data/strategies/sample_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame
# ------------------------------------

# ADX
dataframe['adx'] = ta.ADX(dataframe)
# dataframe['adx'] = ta.ADX(dataframe)

# RSI
dataframe['rsi'] = ta.RSI(dataframe)
"""
# Awesome oscillator
dataframe['ao'] = qtpylib.awesome_oscillator(dataframe)
Expand Down Expand Up @@ -132,9 +134,6 @@ def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame
# ROC
dataframe['roc'] = ta.ROC(dataframe)
# RSI
dataframe['rsi'] = ta.RSI(dataframe)
# Inverse Fisher transform on RSI, values [-1.0, 1.0] (https://goo.gl/2JGGoy)
rsi = 0.1 * (dataframe['rsi'] - 50)
dataframe['fisher_rsi'] = (numpy.exp(2 * rsi) - 1) / (numpy.exp(2 * rsi) + 1)
Expand Down Expand Up @@ -276,7 +275,7 @@ def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""
dataframe.loc[
(
(qtpylib.crossed_above(dataframe['adx'], 30)) & # Signal: ADX crosses above 30
(qtpylib.crossed_above(dataframe['rsi'], 30)) & # Signal: RSI crosses above 30
(dataframe['tema'] <= dataframe['bb_middleband']) & # Guard: tema below BB middle
(dataframe['tema'] > dataframe['tema'].shift(1)) & # Guard: tema is raising
(dataframe['volume'] > 0) # Make sure Volume is not 0
Expand All @@ -294,7 +293,7 @@ def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame
"""
dataframe.loc[
(
(qtpylib.crossed_above(dataframe['adx'], 70)) & # Signal: ADX crosses above 70
(qtpylib.crossed_above(dataframe['rsi'], 70)) & # Signal: RSI crosses above 70
(dataframe['tema'] > dataframe['bb_middleband']) & # Guard: tema above BB middle
(dataframe['tema'] < dataframe['tema'].shift(1)) & # Guard: tema is falling
(dataframe['volume'] > 0) # Make sure Volume is not 0
Expand Down

0 comments on commit e6e35c2

Please sign in to comment.