Strategy
This strategy is backtested on daily OHLCV price data across major US equity indices and ETFs. Entry and exit signals are generated from the strategy's indicators with no lookahead bias; trades execute at the open of the bar following the signal.
Performance metrics are computed per symbol and shown individually. The parameter optimization section, where available, runs a grid search over the strategy's key parameters, optimizing for Sharpe ratio. Transaction costs and slippage are not modeled.
The signal logic and indicator code for this strategy is shown in the methodology code section below.
Price Oscillator is the percentage difference between a fast and slow EMA. Enters long when the oscillator crosses above zero (fast EMA overtaking slow), exits on the reverse. A percentage-normalised version of MACD.
class PriceOscillator(Strategy):
fast = 12
slow = 26
def init(self):
self.po = self.I(_price_oscillator, self.data.Close, self.fast, self.slow)
def next(self):
if self.po[-1] > 0 and self.po[-2] <= 0 and not self.position:
self.buy()
elif self.po[-1] < 0 and self.position:
self.position.close()