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

MQL4 Indicatori Script

Lavoro terminato

Tempo di esecuzione 2 ore
Feedback 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.
Feedback del dipendente
Great customer, prompt communication, clear specs, recommended+

Specifiche

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:


 



Con risposta

1
Sviluppatore 1
Valutazioni
(600)
Progetti
935
46%
Arbitraggio
31
39% / 29%
In ritardo
93
10%
Gratuito
2
Sviluppatore 2
Valutazioni
(87)
Progetti
134
14%
Arbitraggio
41
22% / 29%
In ritardo
14
10%
In elaborazione
3
Sviluppatore 3
Valutazioni
(115)
Progetti
129
18%
Arbitraggio
11
27% / 55%
In ritardo
4
3%
Gratuito
4
Sviluppatore 4
Valutazioni
(155)
Progetti
224
33%
Arbitraggio
27
26% / 26%
In ritardo
23
10%
Gratuito
5
Sviluppatore 5
Valutazioni
(45)
Progetti
58
33%
Arbitraggio
12
42% / 42%
In ritardo
7
12%
Gratuito
6
Sviluppatore 6
Valutazioni
(3)
Progetti
4
0%
Arbitraggio
2
0% / 100%
In ritardo
1
25%
Gratuito
7
Sviluppatore 7
Valutazioni
(184)
Progetti
199
47%
Arbitraggio
0
In ritardo
5
3%
Gratuito
8
Sviluppatore 8
Valutazioni
(24)
Progetti
28
32%
Arbitraggio
1
0% / 0%
In ritardo
0
Gratuito
9
Sviluppatore 9
Valutazioni
(21)
Progetti
24
17%
Arbitraggio
15
20% / 40%
In ritardo
6
25%
Gratuito
10
Sviluppatore 10
Valutazioni
(1135)
Progetti
1438
62%
Arbitraggio
21
57% / 10%
In ritardo
43
3%
Gratuito
11
Sviluppatore 11
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
12
Sviluppatore 12
Valutazioni
(41)
Progetti
46
28%
Arbitraggio
9
0% / 100%
In ritardo
7
15%
Gratuito
13
Sviluppatore 13
Valutazioni
(3)
Progetti
4
0%
Arbitraggio
1
100% / 0%
In ritardo
0
Gratuito
Ordini simili
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

Informazioni sul progetto

Budget
30+ USD
Per lo sviluppatore
27 USD
Scadenze
a 2 giorno(i)