I defined a flag in "Initialize(self)" as "self.traded = False"

The only order-generating code is housed in "OnData" and guarded by:

if not self.traded and not self.Portfolio.Invested:

I must be missing something because on every minute bar a new series of orders is submitted, and I can't logically understand how this could be given the flag.

In fact, to further prevent unwanted behavior, every time this order block of code is run, "self.Liquidate()" is the first method called, so in my mind margin should never become exhausted because the order backlog should never build up enough to cause this.

And self.traded is reset once a day, when my daily consolidator spits out a new bar. The time portion of the consolidator code is as follows: "pivotConsolidator = TradeBarConsolidator(timedelta(days=1))"


I also tried to import a seperate module into "main.py" using "from pivots import carmillaPivots" ... does this functionality not work? I ended up embedding the module as a class method to get it to function.

This is my first backtest, and part of a project family of algorithms I plan to explore to learn the platform.

What am I missing?

P.S To verify I wasn't getting confused with the python language, I've done a few simple exercises such as the following:

'''simple script to test flags etc''' class QC(): def __init__(self): self.traded = False self.invested = False def m(self): if not self.traded and not self.invested: print('Executing trades') def st(self, traded): self.traded = traded print(str(self.traded)) def si(self, invested): self.invested = invested print(str(self.invested)) #instantiate class instance f = QC()