trader.strategies.ma_crossover module¶
Trend following on a moving-average crossover.
Buy the golden cross (short SMA crosses above long SMA); sell the death cross (short SMA crosses below long SMA). Unlike the level-based strategies (rsi_revert, bollinger_revert), the signal here is a transition, so detecting it needs the current bar’s SMAs and the prior bar’s.
- class trader.strategies.ma_crossover.MaCrossoverStrategy(id, short_period=10, long_period=30)[source]¶
Bases:
objectBuy when the short SMA crosses above the long SMA; sell on the reverse cross.
A crossover is a change in which average leads, not a level either sits at, so both the current bar and the bar before it need a defined short and long SMA before a cross can be detected.
- Parameters:
id (str)
short_period (int)
long_period (int)
- id: str¶
- short_period: int¶
- long_period: int¶
- backtestable: ClassVar[bool] = True¶