Calculating a Moving Average of Close-to-MA Deviations in VeighNa
Summary
The forum exchange explains how to calculate a series based on the difference between closing price and its 10-period simple moving average, then average that difference over 10 periods. A respondent shows how to update VeighNa’s bar array, wait for initialization, retrieve the moving-average and close-price arrays, subtract them, and take a slice mean that excludes the current bar.
This is a coding example for expressing a time-series calculation, not a trading strategy. The snippet’s slice uses indices chosen to average prior observations; the exact indexing depends on how the arrays are populated and should be checked against the intended bar timing. The discussion offers no backtest or evidence that this derived series is predictive. It is most useful as an implementation pattern for indicator calculations in VeighNa.
Key ideas
- The requested series subtracts a 10-period moving average from each closing price.
- The second step averages those deviations over 10 prior bars.
- The example waits for the bar array to initialize before calculating the arrays.
- The slice excludes the current bar, so its indexing should be checked against the desired timing.
- The discussion provides implementation guidance but no evidence of trading performance.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.