chrisleekr / binance-trading-bot

Automated Binance trading bot - Trade multiple cryptocurrencies. Buy low/sell high with Grid Trading. Integrated with TradingView technical analysis
MIT License
5k stars 1.09k forks source link

Handling bearish market #212

Open arminfro opened 3 years ago

arminfro commented 3 years ago

Is your proposal related to a problem?

Bearish market is a problem for the bot. When prices are falling the buy strategy is not a good option.

Describe the solution you'd like

I'd like the bot to either handle bearish market (by a better buy strategy) or to recognize the situation and stop buying until price evolution trend changes again.

Describe alternatives you've considered

Manually stop the bot and manually trade for the time of falling prices. Or get a advanced buy strategy.

Additional context

I've found an interesting open source library which may improve the bot a lot. There is a software to analyse candle stick charts, it's TA-Lib : Technical Analysis Library (link goes to a summary of functions which are implemented). There is python wrapper available at TA-Lib Github. There is also a Technical Analysis Bot called Crypto-Signal in python available.

Unfortunately I don't speak python. Otherwise I'd start looking into it. Just thought it makes sense to post these libraries, since I haven't found any mention of them in here, making sure you're aware of them :v:.

Offtopic: Thanks for your awesome bot, really like it, it got me interested into trading :wink:

chrisleekr commented 3 years ago

Hi @arminfro

Originally, the bot was using Bollinger Bands and MACD indicators.

I used Tulip Indicators

The Tulip Indicators have all kinds of indicators that you can use.

After some tests, I found those indicators are not effective and keep losing money because most indicators are after hood, it won't predict the future. It may work with the stock market, but definitely not with the crypto market.

However, I am not a mathematician or learnt any financial strategies.

If you point me to which indicators should use or any strategies, I will consider implementing them. :)

arminfro commented 3 years ago

Interesting, so there has been already a try to use some indicators on the chart data. I'm also not a mathematician or technical trader, so I can't tell which strategies may work or not. Actually the third lib Crypto Signal is specifically for the crypto market.

But without any specific strategy, let's just look at this chart.

We may could handle a bearish market better if we would just recognise the final swing low (Number 2 in the picture). Otherwise the bot may buy in just above the 61.8 green horizontal line to watch it loosing value.

You may already have tried something like this. Not sure if it'd make sense to hold back the buy signal, for another candle, to buy later on. The price may raise fast as well before we buy in. I'd feel more comfortable placing higher bids if I know it waits for the swing low.

Also looking at the support and resistance zone could give us some security. I'm more willing to place higher bids if I know there had been a support area before. While I'd place lower bids if there was never a support at this price level. Maybe same for selling vica-versa.

I'm just thinking how we could model risk and chance. If you (@chrisleekr) see no point in these vague descriptions I provided, we may just close the issue and I'll continue switching on and off the bot per situation.

Maxoos commented 3 years ago

I've been thinking about this for a long time now. Trading is all about when to Buy it seems, and I find that this bot needs some help with buying.

I've been trying to think of ways to improve the buy algorithm, and I think using orders from Binance could help understand which way the market is heading (in combination of the current buying algorithm).

If you look at the Binance web interface (not the app), and you change the order rounding to say 50, like this:

image

It's much easier to read the market, for example:

image

The market is likely to stop going down at around 2650 due to resistance.

I don't know how yet, but this could somehow provide more sophistication to the current buy signal.

chrisleekr commented 3 years ago

@Maxoos

So you are suggesting checking the volume of the tick. It does give some indicators.

Hm... Let's keep thinking. We can come up with a good strategy.

Maxoos commented 3 years ago

@chrisleekr to continues our brain storming, I've researched this a bit and looks someone already looked into this:

https://medium.com/@rani_64949/bitcoin-price-prediction-from-orderbook-data-559c95c69d54 https://github.com/Ranykhalil/btc_orderbook_prediction

They ended up training a natural network to make the prediction. I think this by itself probably isn't a good enough, but it might be a helper to the bot's current logic.

Maxoos commented 3 years ago

I have a few more ideas, they are not yet developed but I'll just note them down here anyway:

  1. Look at max/min of higher candles to make decisions, for example, if on a 15/4 candle we are at the bottom but on 4H/1 candle we are at the top, maybe it's not a good idea to buy.
  2. Follow other coin pair current price to try and predict the future. For example, often BTC will move faster then BTCUP so if there's a sudden drop it will happen on BTC before BTCUP. Same is true for some other alt coins like LINK, they follow BTC but are slower.
chrisleekr commented 3 years ago

@Maxoos Just finished to read https://medium.com/@rani_64949/bitcoin-price-prediction-from-orderbook-data-559c95c69d54 I didn't understand fully, but I can understand the concept.

The first NN model attempted was a Sequential Dense layered network that was capable of achieving a high training accuracy of 0.96 which was a clear sign of overfitting since the validation accuracy was 0.71 (some adjustments would have included lower epoch number or smaller bin arrangements)

Hm, 0.96 accuracy is really high. Oh, it was training accuracy and identified overfitting. Hm.

They have used Tensorflow, but I have no experience with it. So it won't be a quick solution for me to deploy the prediction price feature. In addition, still don't know what variables they have used. Don't think they have achieved a good model as well.

Look at max/min of higher candles to make decisions, for example, if on a 15/4 candle we are at the bottom but on 4H/1 candle we are at the top, maybe it's not a good idea to buy.

This is a pretty interesting idea, which I am doing manually. So when I manually trade, I see 5m/15m/1h/4h/1d charts to see Bollinger Bands/EMA. Well, mostly it's not moving as I anticipated.

Follow other coin pair current price to try and predict the future. For example, often BTC will move faster then BTCUP so if there's a sudden drop it will happen on BTC before BTCUP. Same is true for some other alt coins like LINK, they follow BTC but are slower.

This can give wrong indicators. In some case yes, such as BNB and CAKE. But in some case, de-coupling is happening (like XRP on Apr/2021) But how will we use this indicator? So let's say BTC and BTCUP.

Or

In both cases, as we don't know the next move, feel like a pretty risky buy/sell decision.

eth-man commented 2 years ago

Trading View intergration could be a great solution since on bear market you can prevent buying coins that does not have Buy signal for example or the opposite on the bull market

chopeta commented 2 years ago

Hi guys,

Sorry for jumping in... I just think this issue is extremely relevant.

I've been thinking on how to approach this, but it's actually very hard and complex.

One idea that I would like to propose is to implement a different buy strategy called DCA (Dollar Cost Average).

Here's a example of an implementation that could help us understand the idea. Actually very simple, but it could be very effective against bear market.

This is the only big problem I have with the bot is making buys when market is going down. Bot always buys the top. Otherwise it's awesome and I use it a lot.

Maybe this can be accomplished or mitigated by using multiple buy grid strategies and/or different parameters for the buy grid. Please let me know if it's the case.

Thanks for the awesome work @chrisleekr!

chopeta commented 2 years ago

Ok, please ignore my previous comment.

I've just figured out that I can actually accomplish DCA by using multiple Grid Trade records.

Simply awesome.

I am going fully automated now.

Screenshot_20210919-015649

chrisleekr commented 2 years ago

Oh, @chopeta. I missed your comment.

Yeah, the grid trade is now in place and you can use that to do DCA. :)

It's still not perfect to handle a bearish market, though.

chopeta commented 2 years ago

I can't say anything about perfection right now since I am actually testing the DCA strategy for buying, if it works I will say that is very close to perfection. Let's see how it goes... had a issue with API weight but I think it's solved now after finding #251

Next step for me would be either create an APP and/or improve the web interface to mobile, displaying a more light and executive view of your monitoring symbols and the real-time results per symbol. Will try to figure something about and will report a new issue with some design ideas. I just notice #307, maybe I will just add ideas in there.

I would also like to see somewhere in the screen, a feature where the bot display and/or recommend symbols with higher volatility, which in theory would be better to use with the bot instead of symbols that are running sideways.

Anyway, thanks once again for the great work. Really love it @chrisleekr

Elyx0 commented 2 years ago

How did that perform @chopeta ?

chopeta commented 2 years ago

How did that perform @chopeta ?

My first try of DCA went wrong. Very aggressive params. End end up with lots of red bags for a couple of weeks.

Didn't had to test new params because @eth-man was right. The integration with TV prevent the bot from making bad purchases.

I am pretty happy right now.

Still testing that new PR, but so far so good.