Skip to content
All library documents

A Moving Average and MACD Stock Strategy with a SQL Parser Error

Article BigQuant

Summary

The example builds a single-stock daily strategy from trend and momentum conditions. Entry requires the 21-period simple moving average to exceed the 60-period average, price to be above both averages, and daily and weekly MACD histograms to be positive. It proposes trimming a position when price falls below the 10-period average and exiting when price falls below the 20-period average. The backtest configuration also specifies daily rebalancing, opening prices for orders, commissions, and a broad-market benchmark.

The reported run fails during data extraction with a parser error near a comma, after the feature-generation step completes. The document includes the expression and module setup but does not identify the offending syntax or give a corrected query, so it is not a resolution guide. It tests only one named stock over a stated historical interval, and presents no completed backtest results. The position-sizing code and exit logic therefore remain example mechanics rather than validated performance claims.

Key ideas

  • Entry combines moving-average alignment with daily and weekly MACD confirmation.
  • The proposed exits reduce exposure below a shorter average and close below a longer one.
  • The run fails at data extraction with a parser error near a comma, and no fix is provided.
  • The example gives no completed backtest results or evidence of strategy performance.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.