zenbot icon indicating copy to clipboard operation
zenbot copied to clipboard

Backwards RSI logic?

Open alternativesurfer opened this issue 9 years ago • 15 comments

Hi, As I understand it when trading using RSI indicators: Buy when RSI rises above the low limit (30 in the default logic) Sell when RSI drops below the upper limit (70, in the default logic)

It appears as though Zenbot is buying when the price raises above the upper limit (70), and selling when it drops below the lower (30).

I can see below thatat 12:40:15 RSI hit 70, and triggered an attempt to purchase, which doesn't make sense because that indicates the market is oversold (why would we purchase here)?

`01/19/2017 12:40:15 PM PST [ reporter] m24747639 2 trades. ++++ RSI: 70 CLOSE: $907.00 USD gdax.BTC-USD BAL: $99.76 ROI:1.000 [link]'

'01/19/2017 12:40:15 PM PST [ trader] gdax.BTC-USD trend: UP not enough funds ($1.75 USD) to execute min. buy 0.01, aborting trade! [link]'

'01/19/2017 12:40:15 PM PST [ trader] gdax.BTC-USD attempting to buy 0.00189704 BTC for $1.72 USD [link]'

'01/19/2017 12:40:15 PM PST [ trader] gdax.BTC-USD RSI:70 trend: null -> UP [link]`

alternativesurfer avatar Jan 19 '17 21:01 alternativesurfer

I noticed the same thing. You are correct in that the buy/sell signals are backwards. In fact, one of the first things I tried doing was reversing them and running against the historic data. Funny enough, It gave nearly the same results. My opinion is that buying and selling your full bankroll based only on RSI and the time since the last transaction is not a very good strategy. Sure you can come up with decent returns on a particular dataset, but that means nothing for next week. I found it a little more adaptable to base the signals off MACD and compare that to the RSI strength to help determine how much to wager. I played around with other TA indicators but I am a believer that adding more indicators is just adding more noise. Pure price is king IMHO. I recommend writting a logic that is based off your strategy. Really just more of a conditional statements to trigger the buys or sells you would do when the price reaches certain areas instead of buying/selling based on what a TA tells you. Besides, watching the market I think whales really gobble up TA based bot orders.

s-ftf avatar Jan 19 '17 21:01 s-ftf

And for that I am planning to spend a few days slogging through this code to understand everything I am looking at... ;-) Right now it looks like Greek.

Any advice on simply reversing the RSI logic or otherwise?

alternativesurfer avatar Jan 19 '17 22:01 alternativesurfer

For me, playing with zenbot was just a motivating excuse to learn node. Once I can have more time to test I will submit some pull requests to this project

In the meantime, I found this package useful to add other indicators such as MACD: https://www.npmjs.com/package/technicalindicators

s-ftf avatar Jan 19 '17 23:01 s-ftf

Sorry to butt in since I won't be submitting any code, but I wanted to comment that I think the logic of the original code wasn't necessarily backwards, but just that the mindset behind was the opposite of what most people would think of when using ZenBot. Basically, as the code is written, the focus is more on increasing the USD value of holdings, rather than the BTC/ETH/etc amount.

I think the point was more that the original code is focused on growing USD holdings whereas we'd rather increase crypto holdings, if that makes any sense. Point is I'm in support of the new request.

robsteady avatar Jan 24 '17 00:01 robsteady

@robsteady Hi! I watched the trader for a few days and all it appeared to do was buy high ($ value) and sell low. Since reversing the logic it now sells high and buys low, increasing USD value (and BTC holdings).

At least I think that's what it is doing. Adviser mode's ROI has done some screwy things on me so I can't trust it's results. Yesterday before I implemented my changes it looks like it attempted to "buy" a negative amount of BTC and that somehow skyrocketed my ROI to 10.5 with a USD value of over 100k, haha.

But with me manually making trades based on the advisers logic, my USD value has gone up around 1% (after 18 hours of work).

So...going to run a live test with Zenbot trading today and see how it manages $100.

alternativesurfer avatar Jan 24 '17 17:01 alternativesurfer

I also grabbed the new logic code and switched to it last night. It made a more sensible purchase on a low RSI. After this is verified to be a proper move, maybe we should have a look at the 24 hour restrictions.

robsteady avatar Jan 24 '17 18:01 robsteady

Agreed, I've actually had my own copy set a lot lower just to see how it performs when allowed to purchase/sell more often.

alternativesurfer avatar Jan 24 '17 18:01 alternativesurfer

So considering this afternoon's crash, I'm wondering if that's why the logic was written the way it was. Maybe the idea was that RSI was being used as a safety against a major crash (selling when RSI is down) and making sure we profit off of a spike (buying when RSI is up). It does seem counter-intuitive, but when bigger moves happen, it does actually make sense. Just figured I'd throw out some food for thought.

robsteady avatar Jan 25 '17 00:01 robsteady

As long as the upper and lower limits of RSI were set accordingly the "crash" this afternoon wouldn't affect anything.

My bot purchased at 890 (RSI 23), price rose to 894 (RSI 55, didn't trigger purchase), price dropped to 880 or so (RSI 15 or so, bot tried to purchase more but didn't have the cash to), price just raised back up to 895 (RSI 75) triggering a sell as it breached the RSI upper limit 65.

I made $13 :-)

I can't imagine a circumstance where you would trade RSI in reverse, and can't find any reason in my reading of RSI trading techniques.

Just realized the real culprit is probably the 24/18 hour trade restrictions. I have mine set to 20 minutes, and 10 minutes respectively (same trade/opposite trade) and have been messing around with intraday trading (I don't suggest this, still testing). Also been using an RSI period of 1 minute if anyone has a larger History to backfill test this against (I only have a few days....).

On Jan 24, 2017 4:46 PM, "R. Samuel Tiedemann" [email protected] wrote:

So considering this afternoon's crash, I'm wondering if that's why the logic was written the way it was. Maybe the idea was that RSI was being used as a safety against a major crash (selling when RSI is down) and making sure we profit off of a spike (buying when RSI is up). It does seem counter-intuitive, but when bigger moves happen, it does actually make sense. Just figured I'd throw out some food for thought.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/carlos8f/zenbot/issues/102#issuecomment-274986371, or mute the thread https://github.com/notifications/unsubscribe-auth/AJqpeUtJeRj0xgde5IORSwpS4V5CZKQdks5rVptIgaJpZM4Lom3C .

alternativesurfer avatar Jan 25 '17 00:01 alternativesurfer

Did we come to a consensus here on the backwards logic? Buying when RSI is low and selling when RSI is high seems like the right strategy here but I think zenbot is doing the exact opposite...

johanatan avatar Feb 14 '17 20:02 johanatan

Actually upon closer inspection (actually just careful reading of the README), it seems like zenbot is using a very short window RSI (14-hours) to calculate its RSI. I think that given this very short window, the RSI can be seen as more of a predictor of major swings and thus when the strength is high, an uptrend is just beginning and vice versa.

johanatan avatar Feb 15 '17 04:02 johanatan

It may look counter-intuitive, but simulations throw a better ROI as it is.

By the way, a RSI lower threshold of 25, instead of 28, makes a better ROI than default settings.

To reverse default logic, it should be enough to change these lines:

353 if (r.value >= rs.rsi_up) { trend = 'UP' (change to down) } else if (r.value <= rs.rsi_down) { trend = 'DOWN' (change to up) } else { 360 trend = null

Sims ROI are very poor

Leandrosson avatar Feb 19 '17 15:02 Leandrosson

Yup, i also understand that this logic buys/sells based on trends, not on absolute peaks/pits. So when things start to go down the drain, i would consider it a rather good idea to dump my assets before they hit rock bottom, not when the bot thinks "well, this price is now high enough to sell". Same for buying: how do you know it's the lowest low, the right time to buy? I think it's better to buy when things are just starting to peak again, because then you have a higher chance of actually having assets when that peak hits. But the 24 hours seem a bit long, indeed.

jangrewe avatar Feb 26 '17 01:02 jangrewe

I guess that is why the bot simulation was tested in a 3 months lapse.

carlosfvp avatar Mar 12 '17 20:03 carlosfvp

Zenbot 4 is out, so I'm cleaning up 3.x issues. Please use and test 4, thanks!

carlos8f avatar May 20 '17 23:05 carlos8f