DeviaVir / zenbot

Zenbot is a command-line cryptocurrency trading bot using Node.js and MongoDB.
MIT License
8.22k stars 2.04k forks source link

Zenbot still buy high and sell low #1811

Closed dgallig closed 5 years ago

dgallig commented 5 years ago

System information

Describe the problem

Hello , Zenbot it's buying high and selling low, causing a loss. I have testing with different parameters for a week and it's always buying high and selling low. Is this still the old bug?

Thanks in advance

voravitl commented 5 years ago

Just try to use other --strategy for Default it use trend_ema . it kind be like buy and sell following volume . that not good enough . Just try to use other strategy like MACD or SAR it better more than EMA

rountrey commented 5 years ago

If this is a constant thing for you, and if it is the same bug, just go into the strategy.js file and reverse all the buy/sell signals. Change all "buy" to "sell" and vice versa.

When I started playing with zenbot, I actually made a copy of trend_ema and made a trend_ema_sim. The sim was original and the new trend_ema was all reversed signals to work in live and paper. I have since moved on to other/custom strategies to suit my needs. Honestly, I think trend_ema is a great learning tool but should not be used.

mrseeker commented 5 years ago
  1. Your period is 1 minute. This is way too short for any parameters to work properly. Too many false signals that cause your bot to start buying and selling.
  2. Neutral_rate is automatic. This means that your bot will automatically adjust the spread, this can cause the bot to trigger too soon.
  3. Have you tried backtesting? When does it start buying/selling, and what is the trend_ema trigger? It should buy when the trigger is low, and sell when the trigger is high...
marcelomf commented 5 years ago

I have the same problem describe by dgallig. I try the indicators: speed sar trend_ema pivot momentum ehlers_ft macd ta_macd

The result of simulation its very good! But reversed :(

I try change strategy.js, but in this case i dont have the reverse result. I try change engine.js, in all calls before of executeSignal() changing s.signal, but i dont have reverse result too.

What is the best strategy to take the orders on a reverse result? Thanks!

mrseeker commented 5 years ago

@marcelomf What is your strategy? Have you tried using it using --verbose, and what does it say? Does the signal switch too soon, or not? "selling at a loss" can mean multiple things. Does it always try to buy/sell at a loss due to buying at the wrong signal, or does it try to buy/sell at a loss because the market dumped when it bought? EDIT: Example of a wrong trigger would be buying when the market is dumping, and selling when the market is pumping...

marcelomf commented 5 years ago

@mrseeker by example, i run: ./zenbot.sh sim --strategy pivot binance.TRX-BTC --order_adjust_time 30000 --days 3

And this is result: pivot

A similar behavior occurs with the other strategies: speed sar trend_ema pivot momentum ehlers_ft macd ta_macd

I try change: https://github.com/DeviaVir/zenbot/blob/unstable/lib/engine.js#L270 for this: s.exchange[(type == "sell") ? "buy" : "sell"](order_copy, function (err, api_order) {

But dont have success, because i need change the price and size of the order_copy.

I will try to move the code that discovers the size of the buy and sell order in the executeSignal() to two new funcitons: getSizeOfBuy() and getSizeOfSell(), and can use them before calling exchange.buy() and exchange.sell( ). Do you think it can work?

I have already tried to invert the signal in strategy.js, inside executeSignal(), before calling executeSignal(), before and within doOrder() and placeOrder(), after calling s.strategy.onPeriod.call(). But i dont have success...

mrseeker commented 5 years ago

I checked all your strategies that you mentioned, but the issue is that you might be trading in a market that is simply too prone to fluctuations on a micro scale... Bitcoin works with fluctuations that are 40-60 USD, while you are working with fluctuations that are on a scale of sats, which makes it really difficult to get it timed right. And all the indicators that you mention are working on a "trendline", which means that the market needs to have a certain direction it needs to go in. In your case, you are working with a very small spread with a very high fluctuation...

This is a nice example of what I am talking about, using the pivot strategy image

It initially goes into profit, but then the price pushes up really fast just because the market goes up by couple of "sats", and then it tries to buy at a loss, since it hits the upper band again.

marcelomf commented 5 years ago

@mrseeker you are correct! The reverse signal occurs only in no liquid markets. Thanks.

marcelomf commented 5 years ago

In my pull request i add --reverse :) https://github.com/DeviaVir/zenbot/pull/1838

marcelomf commented 5 years ago

Today i did maked tests in coinbasepro(GDAX) with ETH-USD and the --reverse didn't make sense. But in binance did make be sense! I think we have bugs in binance related code.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.