EA31337 / EA31337-indicators-common

Collection of common indicators used for EA31337 strategies.
6 stars 3 forks source link

[MT4][SOLVED] MA.mq5 index error (timeseries vs buffer indexation) #19

Open cgava opened 7 months ago

cgava commented 7 months ago

There is an index error in the MA.mq5 code, which produces the following result:

image

Can be fixed by adding:

@@ -103,6 +104,9 @@ int OnCalculate(const int rates_total, const int prev_calculated,
   if (rates_total < 2 * InpMAPeriod) {
     return (0);
   }
+  
+  ArraySetAsSeries(ExtMABuffer,false);
+  
   // Initialize calculations.
   start = prev_calculated == 0 ? 2 * InpMAPeriod - 1 : prev_calculated - 1;
   if (prev_calculated == 0) {

image

Configuration statement

MT4 4.0 build 1415
The issue is visible on both:
Classes: v2.013.1                   /Common Indicator: v0.013
Classes: v3.001-dev-new       /Common Indicator: dev (19a01e6)

The cloning of EA31337 repo in MQL4 folder is:

[submodule "MQL4/Include/classes"]
    path = MQL4/Include/classes
    url = https://github.com/EA31337/EA31337-classes
[submodule "MQL4/Indicators/EA31337-indicators"]
    path = MQL4/Indicators/EA31337-indicators
    url = git@github.com:EA31337/EA31337-indicators.git
kenorb commented 7 months ago

Thank you, we're going to check the fix. This will apply for MT4/MQL4 due to differences between MT4 and MT5 on how the series are calculated in indicator buffers.