Caching Live Bars for Rolling Indicators and Multi-Timeframe Strategies
Summary
This programming note explains how to keep a rolling cache of recent bars for use in strategies that calculate time-series indicators from live data. A bounded array is updated from bar callbacks, and strategy logic waits until the cache is initialized before reading price series. The examples show generating bars from ticks, computing Donchian channel levels and ATR, and maintaining separate caches for different timeframes to calculate indicators such as RSI and MACD.
It also shows how a cache class can expose derived fields such as VWAP. The document is an implementation walkthrough rather than a tested trading system: it provides code examples but no backtest, execution analysis, or performance evidence. The channel breakout example illustrates how cached highs and lows might inform orders, but the note does not assess the signal’s profitability or discuss operational edge cases such as missing or corrected data.
Key ideas
- A rolling bar cache provides recent history needed for indicators in live strategies.
- Strategy calculations should wait until the cache has accumulated enough bars to initialize.
- Tick data can be converted into bars and delivered to callbacks for cache updates.
- Separate caches can support indicator calculations on different timeframes.
- The examples demonstrate implementation patterns but provide no evidence that the illustrative signals are profitable.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.