Transferring Indicator Calculations into an Expert Advisor
Summary
This article explains why and how to move custom indicator calculations into an Expert Advisor. It identifies two motivations: avoiding recalculation on the forming bar when the EA does not need that value, and keeping commercial EA logic less exposed. An example shows modifying an indicator’s calculation loop to skip the zero bar, while warning that the prior bar may still need recalculation as the current bar changes, or buffer values can become inconsistent.
The broader discussion outlines indicator buffers, incremental calculation with counted bars, and the changes needed when adapting indicator code for an EA. Since EAs do not provide the same counted-bar function or indicator-buffer behavior, the author describes emulating recalculation tracking and storing values in ordinary arrays. The text also notes that time-series indexing and smoothing functions may need adaptation. The proposed transfer method is explicitly presented as awkward and nonoptimal, and the article offers a general overview rather than a complete, polished implementation or comparative performance evidence.
Key ideas
- Skipping calculations on the forming bar can save work when an EA does not use that bar’s values.
- Recalculate the prior bar when needed to keep values correct as the current bar changes.
- Expert Advisors require substitutes for indicator-specific counted-bar tracking and buffers.
- When transferring calculations, adapt timeseries indexing and any indicator-specific helper functions.
- The article presents a conceptual workflow and acknowledges that its method is not optimized.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.