Работа завершена
![](https://c.mql5.com/i/avatar/avatar_na2.png)
![](https://c.mql5.com/i/avatar/avatar_na2.png)
Техническое задание
I found out that the calculated moving average (mode SMMA) is different vom the same moving average in the normal chart window.
The consequence is a wrong behavour of the EA.
Let's take this small "EA" to show the problem:
void OnTick() { // Create an array double myMovingAverageArray[]; // define properties of moving average int MovingAverageDefinition = iMA (_Symbol, _Period, 400, 0, MODE_SMMA, PRICE_CLOSE); // sort the price array downwards ArraySetAsSeries (myMovingAverageArray, true); // Copy values CopyBuffer (MovingAverageDefinition, 0, 0, 3, myMovingAverageArray); // Calculate moving average for the current candle double myMovingAverageValue = myMovingAverageArray[0]; // Print the value on chart Comment ("myMovingAverageValue: ", myMovingAverageValue); }
The EA is working with the dow jones index and has the following settings:
This is the standard chart with the moving average (black line):
This is the settings of the moving average:
I saved exactly this chart as template "tester.tpl".
Then I start the EA.
Result:
As you can see, the values for the moving average on the "standard chart" is different from the moving average produced by the tester:
Date | Mode | Value Standard Chart | Value Tester |
---|---|---|---|
28.12.2018 | SMMA | 22107 | 23459 |
What I also found out:
- The problem only appears in the "SMMA" mode. If I use the "SMA" mode, then there is no difference between normal chart and tester.
- If I rise the number of periods from 400 to 600 (in mode "SMMA") then the moving average does not appear at all in tester.
Job: Fix this problem by
- modifying the small EA (see above) OR
- create an indicator
The Job is done when the correct values (= same values as in the normal chart) of the SMMA 400 are available in strategy tester / mql5 code for further calculations