For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Some Trading Strategies which can be coded and tested in back trader

  • I came across some strategies , which can be used to code and backtest.
    We can share codes/ ideas on this forum and try to learn more on backtrader capabilities.
    The logic can be tweaked to start with and later add complexities

    Trading system: 2x3xCumRSIL
    Creator: Bloominonion, although similar to systems in books by Larry Connors
    Platform: Thinkorswim Prodigio

    1. System buy/sell signals occur at the close each day
    2. This system applies to the 2x and 3x leveraged ETFs (long and shorts) with average volume > 100,000 per day, and 5 < stock price < 75
    3. Share size is 100 shares (regardless of stock price)
    4. ETF is above the 200 day MA
    5. Cumulative RSI for the last 2 days must be under 30
    6. Enter on a limit order 8% below the closing price when rule 5 triggers
    7. The first exit triggers when the price falls below the entry price (0% stop); exit at 5% profit
    8. The second exit takes over when the price rises from the entry or the 5% profit target does not occur; exit on the open at market the day after the price closes above the 10 day SMA
      Trades come in lumps; much of the time the market is not trading at extremes which trigger a trade.
      So far this month there have only been two trades; URE which triggered 7/6 and closed 7/9, making $415; and SQQQ which triggered 7/13 and closed 7/16, making $286.

    Note how the system is objective and trades the extremes, long or short, without bias. URE is 2X long real estate; SQQQ is 3X short NASDAQ.
    The market went from one extreme to another rapidly in July.

    11 of the 64 trades occurred in June 2010. The next busiest month was 8 trades in May 2010.
    The dormancy of the system isn’t necessarily bad; capital is employed only when the market reaches an extreme that provides a good edge.
    And the system isn’t very capital intensive, trading just a few times a month on average.

    The 8% limit order is the key to the profitability of the system.
    It seems to enable homing in on ETFs which are truly oversold, not just the random noise that 2X and 3X leverage generates.

    Overall the system appears to do well when it is generating trades, as it did last month.
    And with 2 trades already in July I hope to take a few trades soon.

  • administrators

    Thx for proposing. At least a couple of points would need some clarification:

    1. Cumulative RSI for the last 2 days must be under 30
    • Any standard definition reference for CumulativeRSI?
    1. The first exit triggers when the price falls below the entry price (0% stop); exit at 5% profit
    • What would be the definition of falling below? Close price at the end of the day (including entry day)? Low of same or any posterior day?

  • CUMRSI on 2 period is the same thing as addition of last 2 RSI values
    It's like : define RSI(period=14)
    then CUMRSI2 = RSI[0] + RSI[1]

    Price Falling below is simply Price Cross Down the Stop Loss/ Buy Price
    Reference of Cum RSI based Strategy

  • administrators

    In case anyone would be tempted to try it, here a pre-packaged CumulativeRSI indicator.

    class CumulativeRSI(bt.Indicator):
        lines = ('cumrsi',)
        params = (('period', 14), ('count', 2),)
        alias = ('CumRSI',)
        def __init__(self):
            rsi = bt.ind.RSI(, period=self.p.period)
            self.lines.cumrsi = bt.indicators.SumN(rsi, period=self.p.count)

Log in to reply