Haehnchen / crypto-trading-bot

Cryptocurrency trading bot in javascript for Bitfinex, Bitmex, Binance, Bybit ... (public edition)
MIT License
3.12k stars 983 forks source link

added StochRSI? #240

Open Cemlik opened 3 years ago

Cemlik commented 3 years ago

Hello. What should we do to buy/sell with a new strategy? Can anyone do a favor and share the strategy that trades with the StochRSI indicator for this bot? Unfortunately, I do not have enough information to create a new strategy.

ArnisL commented 3 years ago
buildIndicator('stochRsi', 'stoch_rsi', '1m', { length: whatever })

let indicators = indicatorPeriod.getCurrentValues()
let stochRsi = indicators.stochRsi

if (stochRsi.stoch_k > 80) // <-- btw, bad idea
  return somethingsomethingcreateSignal('short')
Cemlik commented 3 years ago
buildIndicator('stochRsi', 'stoch_rsi', '1m', { length: whatever })

let indicators = indicatorPeriod.getCurrentValues()
let stochRsi = indicators.stochRsi

if (stochRsi.stoch_k > 80) // <-- btw, bad idea
  return somethingsomethingcreateSignal('short')

Thank you very much for the help. But as I said, my knowledge on this subject is very limited.

When I create stochrsi.js in the strategy folder, can you help me with exactly what codes should I write in it?

About creating a structure like in macd.js.

'strategies': [ { 'strategy': '**stochrsi**', 'options': { 'period': '15m' } },

What should I do to trade with stochrsi like in the example? can you create this file?

If stochrsi >80, let it sell. If Stochrsi < 20, let him buy.

ArnisL commented 3 years ago

Such strategy will lead to losses. Some of the biggest pumps happen at stochk_k 100. Likewise - time and length params are of utmost importance.

When I create stochrsi.js in the strategy folder, can you help me with exactly what codes should I write in it?

Already did.

Cemlik commented 3 years ago

Where do I write these values when I use this indicator with the sequence 3,3,14,33? Sorry I couldn't find this part.

buildIndicator('stochRsi', 'stoch_rsi', '1m', { length: whatever }) How do I fill in the whatever part of the code? with these periods?

ArnisL commented 3 years ago

Open up src/utils/indicators.js and search for stoch_rsi function.

Cemlik commented 3 years ago

I guess I couldn't explain the problem exactly :) I already examined that file first. maybe to give you an idea. my request was a sample file for stochRsi. Unfortunately, I don't have the knowledge to examine the indicator.js :)

but still thank you for your interest.

Excuse me for my English.

ArnisL commented 3 years ago

Unfortunately, I don't have the knowledge to examine the indicator.js :)

Well. You need to build it up. There's no way around it.

File you examined specifies available inputs for stoch_rsi indicator.

Which is the answer to your question:

Where do I write these values when I use this indicator with the sequence 3,3,14,33? Sorry I couldn't find this part.

Cemlik commented 3 years ago

I am having trouble placing the necessary codes as there is no example for this strategy file. thanks again. I will handle it somehow.

Cemlik commented 3 years ago

Could someone please share a working stoch_rsi strategy?

And again, I beg you not to lead the way. If I could do that, I would have done it already. Please do not guide except sharing.

ArnisL commented 3 years ago

As in - profitable? Probably no one.

Cemlik commented 3 years ago

As in - profitable? Probably no one.

Everyone has to decide for himself whether it is profitable or not. My only request is for someone to share a stochRsi strategy. I failed to write a stochrsi strategy file that trades in the 80-20 range.

ArnisL commented 3 years ago

With fees included:

Backtesting Results - cemliks_stoch_rsi - 5m
Dashboard
Backtesting Results
Summary - 21-07-31 19:00:00 - 21-08-07 19:25:00
Initial Capital 10000 $
Final Capital   11402.27 $
Net Return on Investment    14.02 %
Sharpe Ratio    -2.42
Average Return Per Trade    0.13 %
Total Number of Trades  111
Number of Winning Trades    76
Percentage of Winning Trades    68.47
const SignalResult = require('../dict/signal_result')

class CemliksStochRsi {
  buildIndicator = (builder, options) => {
    builder.add('stoch_rsi', 'stoch_rsi', '5m', { k: 3, d: 3, stoch_length: 14, rsi_length: 33  })
  }

  setup(period) {
    const indicators = period.getLatestIndicators();
    const candles = period.indicators.candles
    const candle = candles.slice(-1)[0]

    this.indicatorPeriod = period
    this.close = candle.close
    this.stoch_rsi = indicators.stoch_rsi

    this.entry = this.indicatorPeriod.strategyContext.entry
    this.profit = period.strategyContext.profit
    this.backtest = period.strategyContext.backtest
    this.lastSignal = period.getLastSignal()
    this.signal = SignalResult.createEmptySignal()
    this.signal.mergeDebug(this.debug())
  }

  period(indicatorPeriod) {
    this.setup(indicatorPeriod)

    const lastSignal = this.lastSignal,
          signal = this.signal

    if (lastSignal) {
      if (lastSignal == 'long' && this.stoch_rsi.stoch_k > 80) signal.setSignal('close')
      if (lastSignal == 'short' && this.stoch_rsi.stoch_k < 20) signal.setSignal('close')
    } else {
      if (this.stoch_rsi.stoch_k > 80) signal.setSignal('short')
      if (this.stoch_rsi.stoch_k < 20) signal.setSignal('long')
    }

    return this.signal
  }

  debug() { return {} }
  getBacktestColumns() { return [] }
  getName() { return 'cemliks_stoch_rsi' }
  getTickPeriod() { return '5m' }
  getOptions() { return {} }
}

module.exports = CemliksStochRsi