Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
RSI indicator

When I apply the RSI indicator on the open or close price, I get always a mean-reversion style of trading.
Thats mean, when the indicator is between 0 and 20 I can Buy, when it is between 70 and 80 I can sell.
In this case I am trading againts the trend.
Buy low and sell high.
How can I use the RSI to trade with the trend and not againts it?!

5 responses

Just do the opposite...

If i do the opposite, i get negative result.

You can’t expect to make money from both mean reversion (MR) and trend using the same factor during the same time period. Trend/Momentum I believe tends to work better on longer lookback periods (compared to MR, which tends to be shorter term), so maybe increase the RSI window_lenght if you want to use it as a Momentum factor.

No, you dont have right!
99% of the indicators are gives you mean-reversion stlye of trading. Buy low Sell high!
CCI, RSI, Stochastic, ADX, WPR%, you can choose any indicator! You will be fooled!
All the problem came from the averaging effect.

Adam,

Both Quant Trader and Joakim Arvidsson are right.
In order to use the RSI to trade with the trend and not againts it you need:

Change your logic (do the opposite) and Increase the RSI window_lenght,

I would add change your triggers.

Try this:

import talib  
# ---------------------------------------------------------------------------  
STOCK, BOND, RSI, UB, LB, LEV = symbol('QQQ'), symbol('TLT'), 50, 55, 45, 1.0  
# ---------------------------------------------------------------------------  
def initialize(context):  
    schedule_function(trade, date_rules.week_start(2), time_rules.market_open(minutes = 65))

def trade(context, data):  
    if get_open_orders(): return   

    rsi = talib.RSI(data.history(STOCK, 'price', RSI + 2, '1d'), RSI)[-2]

    if all(data.can_trade([STOCK, BOND])):  
        if rsi > UB:  
            order_target_percent(STOCK, LEV)  
            order_target_percent(BOND, 0)  
        elif rsi < LB:  
            order_target_percent(STOCK, 0)  
            order_target_percent(BOND, LEV)    

    record(leverage = context.account.leverage)