Hi all,

I've just gotten around to implementing the relatively new continuous futures feature. I copied the moving average crossover strategy from Martin Molinero with few lines adjusted.

The issue I'm having is that on the first day of the algo it makes 40 orders with a stream of constant buy and sell orders. Which doesn't make much sense to me since the order execution is:

        if self.fast_sma > self.slow_sma:
            self.SetHoldings(self._continuousContract.Symbol, 1)
            
        else:
            if self.fast_sma < self.slow_sma:
                self.SetHoldings(self._continuousContract.Symbol, -1)     

 

Considering that the first period is a downtrend with fast ma being < slow ma, one would expect a single short sale order to ride the downtrend. I'm sure I'm missing something here as only 1 order should be made per signal. 

Cheers,

 

Mike

 

Author