EMA, SMMA, and LWMA join SMA as modules of the indicator framework from Part 1, all four derived from a new base class, CSmoothingBase. The root object, CIndicator, dynamically creates the module of the chosen smoothing method and works with it through a base-class pointer. Besides the code, the article explains the smoothing methods themselves, with formulas and worked examples, and compares the four: how they weight the bars, what they need to start, and what their calculation costs.
The framework currently has two modules: CAppliedPrice and CSma. This article adds one for each of the other three standard moving averages: EMA, SMMA, and LWMA. Before the first of them, we fix a bug in CSma, extract a common base class for all smoothing methods, and make the smoothing method selectable at runtime. Finally, we optimize the LWMA module, whose straightforward implementation loops over the whole averaging window for every bar.
The article also explains the smoothing methods that the modules implement. It gives their formulas, works through examples, and compares the four: how they weight the bars, what they need for their first value, and what a full calculation costs.
In Part 1, I promised that this article would put the framework to work: new indicators, ready-made modules combined into more complex ones, and an AlgoForge project template. I planned to start by completing the set of standard moving averages, the building blocks behind a large share of indicators. That alone took the whole article. Combining modules and the project template will have to wait for later parts of the series. The template in particular benefits from the delay. Projects created from a template inherit its structure, so any later change to the framework's foundation would have to be repeated in each of them. The work continues in the same evolution repository, where the tag article-part1 marks the state of the code at the end of Part 1.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Check out the new article: Modular Indicator Architecture in MQL5 (Part 2): Standard Smoothing Methods as Interchangeable Modules.
The framework currently has two modules: CAppliedPrice and CSma. This article adds one for each of the other three standard moving averages: EMA, SMMA, and LWMA. Before the first of them, we fix a bug in CSma, extract a common base class for all smoothing methods, and make the smoothing method selectable at runtime. Finally, we optimize the LWMA module, whose straightforward implementation loops over the whole averaging window for every bar.
The article also explains the smoothing methods that the modules implement. It gives their formulas, works through examples, and compares the four: how they weight the bars, what they need for their first value, and what a full calculation costs.
In Part 1, I promised that this article would put the framework to work: new indicators, ready-made modules combined into more complex ones, and an AlgoForge project template. I planned to start by completing the set of standard moving averages, the building blocks behind a large share of indicators. That alone took the whole article. Combining modules and the project template will have to wait for later parts of the series. The template in particular benefits from the delay. Projects created from a template inherit its structure, so any later change to the framework's foundation would have to be repeated in each of them. The work continues in the same evolution repository, where the tag article-part1 marks the state of the code at the end of Part 1.
Author: Vladislav Boyko