Please help me find the bug in 5 lines of MQL4 code

MQL4 Indicadores Sripts

Trabajo finalizado

Plazo de ejecución 2 horas
Comentario del Cliente
John knows his programming! And he did more than was expected. I can strongly recommend him to anyone who is looking for a programmer.
Comentario del Ejecutor
Great customer, prompt communication, clear specs, recommended+

Tarea técnica

I need help with a small piece of code that calculates the moving average of the Williams Percent Range indicator.

Here is the code:

         ArrayResize(WPRArray, WPR_MAPeriod);

         for (int j = 0; j < WPR_MAPeriod; j++)
         {
            WPRArray[j] = iWPR(symbol, WPR_Timeframe, WPR_Period, j);
         }
         double WPR_Average = iMAOnArray(WPRArray, 0, WPR_MAPeriod, 0, WPR_MAMethod, 0);
         
         WPR = DoubleToString(WPR_Average, 0);

It gives different values on the indicator on the chart and the value in the variable calculated for WPR, e.g.
Here the value on the indicator is -52,4541 where the value in the Variable WPR = -73 (rounded off)



And here is another example:
Value of the indicator = -63.5457 but the variable has the value -41(rounded off)

I have researched the issue and found that there is a 12 hour difference where the value in the variable lags the value of the indicator. 

Here is a chart over 20 hours of the values of the indi and the var to illustrate:


 



Han respondido

1
Desarrollador 1
Evaluación
(600)
Proyectos
935
46%
Arbitraje
31
39% / 29%
Caducado
93
10%
Libre
2
Desarrollador 2
Evaluación
(87)
Proyectos
134
14%
Arbitraje
41
22% / 29%
Caducado
14
10%
Trabaja
3
Desarrollador 3
Evaluación
(115)
Proyectos
129
18%
Arbitraje
11
27% / 55%
Caducado
4
3%
Libre
4
Desarrollador 4
Evaluación
(155)
Proyectos
224
33%
Arbitraje
27
26% / 26%
Caducado
23
10%
Libre
5
Desarrollador 5
Evaluación
(45)
Proyectos
58
33%
Arbitraje
12
42% / 42%
Caducado
7
12%
Libre
6
Desarrollador 6
Evaluación
(3)
Proyectos
4
0%
Arbitraje
2
0% / 100%
Caducado
1
25%
Libre
7
Desarrollador 7
Evaluación
(184)
Proyectos
199
47%
Arbitraje
0
Caducado
5
3%
Libre
8
Desarrollador 8
Evaluación
(24)
Proyectos
28
32%
Arbitraje
1
0% / 0%
Caducado
0
Libre
9
Desarrollador 9
Evaluación
(21)
Proyectos
24
17%
Arbitraje
15
20% / 40%
Caducado
6
25%
Libre
10
Desarrollador 10
Evaluación
(1135)
Proyectos
1438
62%
Arbitraje
21
57% / 10%
Caducado
43
3%
Libre
11
Desarrollador 11
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
12
Desarrollador 12
Evaluación
(41)
Proyectos
46
28%
Arbitraje
9
0% / 100%
Caducado
7
15%
Libre
13
Desarrollador 13
Evaluación
(3)
Proyectos
4
0%
Arbitraje
1
100% / 0%
Caducado
0
Libre
Solicitudes similares
I'm looking for a skilled developer to help build a custom trading strategy for NinjaTrader 8 (N8). The project involves developing and fine-tuning a strategy tailored to specific market conditions. Experience with NinjaScript, strategy optimization, and backtesting is highly preferred. If you're available and have expertise in N8 strategy development, please get in touch to discuss further details
I have a python script that connects MT5 to Deriv for binary trading which is having some bug. It stops executing trades after a while. I need someone to check the code and fix it. Negotiable price
I currently have a Forex trading script in .txt format that I want to be converted to a functional/working robot (in .mq4), without altering the strategy of the script. The strategy of the script is already in and shouldn't be changed unless with mutual understanding

Información sobre el proyecto

Presupuesto
30+ USD
Para el ejecutor
27 USD
Plazo límite de ejecución
a 2 día(s)