Skip to content

Number of trades might not be correct #1047

Answered by peacerider
huytradingz asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,

I checked by my simple code.
But, the trade number is decrease when I add the RSI trigger.
sorry. I don't know why your situation is occured.

Example

from backtesting import Backtest, Strategy
from backtesting.lib import crossover
import talib as ta

from backtesting.test import SMA, GOOG


def get_rsi(close, n3):
    return ta.RSI(close, timeperiod=n3)


class SmaCross(Strategy):
    n1 = 12
    n2 = 21
    n3 = 14

    def init(self):
        close = self.data.Close
        self.sma1 = self.I(SMA, close, self.n1)
        self.sma2 = self.I(SMA, close, self.n2)
        self.RSI = self.I(get_rsi, close, self.n3)

    def next(self):
        # if crossover(self.sma1, self.sma2) and sel…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by huytradingz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants