kernc / backtesting.py

:mag_right: :chart_with_upwards_trend: :snake: :moneybag: Backtest trading strategies in Python.

Home Page:https://kernc.github.io/backtesting.py/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

entry exit check condition problem

Avalanchecoder opened this issue · comments

Expected Behavior

when supertrend is greater than open and no position present it should take trade

Actual Behavior

random trade are being taken.

Steps to Reproduce

  1. Include attached strategy.
  2. run on data
class Supertrend(Strategy):
    def init(self):
        self.sup = self.I(Z.closefn,self.data.df.ST)
        self.ope = self.I(Z.closefn,self.data.Open)


    def next(self):
        if ((self.ope > self.sup)  and ((self.position.is_long) or (self.position.is_short)))  :
            self.position.close()
        elif ((self.sup > self.ope) and ((self.position.is_long!=True) or (self.position.is_short!=True)) ) :
            self.sell(size=50)

Additional info

I'm new to backtesting.py if i am mistaking anything let me know

image

  • OS: Linux