Generating Daily Bars from Ticks for a Moving Average Crossover
Summary
This VeighNa CTA example shows how to build daily bars from incoming ticks and use them in a moving average crossover strategy. A BarGenerator aggregates ticks into daily bars, while an ArrayManager stores the resulting history. On each completed daily bar, the strategy calculates fast and slow simple moving averages and compares their current and prior values to detect crossovers. A bullish crossover enters or reverses to a long position; a bearish crossover enters or reverses to a short position.
The example separately loads historical daily bars during initialization and updates strategy variables for display through the event mechanism. It illustrates that a strategy can process daily signals even when the ordinary bar callback is associated with minute bars, provided the daily aggregation callback is wired correctly. The document gives code but no performance results or execution analysis. Practical details such as market-specific daily session boundaries, data availability, order fill behavior, and whether signals should execute at the bar close require further consideration.
Key ideas
- Use a BarGenerator configured for the daily interval to aggregate ticks into daily bars.
- Pass completed daily bars to a dedicated callback that updates an ArrayManager and calculates indicators.
- A moving average crossover is detected by comparing the current and previous fast and slow averages.
- The sample reverses between long and short positions when the opposing crossover occurs.
- No backtest or live performance evidence is provided, and session timing and order execution need separate validation.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.