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

MQL4 Göstergeler Komut dosyaları

İş tamamlandı

Tamamlanma süresi: 2 saat
Müşteri tarafından geri bildirim
John knows his programming! And he did more than was expected. I can strongly recommend him to anyone who is looking for a programmer.
Geliştirici tarafından geri bildirim
Great customer, prompt communication, clear specs, recommended+

Şartname

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:


 



Yanıtlandı

1
Geliştirici 1
Derecelendirme
(630)
Projeler
995
47%
Arabuluculuk
33
36% / 36%
Süresi dolmuş
98
10%
Çalışıyor
Yayınlandı: 6 kod
2
Geliştirici 2
Derecelendirme
(90)
Projeler
136
14%
Arabuluculuk
43
21% / 28%
Süresi dolmuş
14
10%
Serbest
Yayınlandı: 2 kod
3
Geliştirici 3
Derecelendirme
(115)
Projeler
129
18%
Arabuluculuk
11
27% / 55%
Süresi dolmuş
4
3%
Serbest
4
Geliştirici 4
Derecelendirme
(163)
Projeler
236
32%
Arabuluculuk
30
27% / 30%
Süresi dolmuş
26
11%
Serbest
5
Geliştirici 5
Derecelendirme
(45)
Projeler
58
33%
Arabuluculuk
12
42% / 42%
Süresi dolmuş
7
12%
Serbest
6
Geliştirici 6
Derecelendirme
(3)
Projeler
4
0%
Arabuluculuk
2
0% / 100%
Süresi dolmuş
1
25%
Serbest
7
Geliştirici 7
Derecelendirme
(265)
Projeler
280
55%
Arabuluculuk
0
Süresi dolmuş
5
2%
Serbest
8
Geliştirici 8
Derecelendirme
(24)
Projeler
28
32%
Arabuluculuk
1
0% / 0%
Süresi dolmuş
0
Serbest
Yayınlandı: 1 kod
9
Geliştirici 9
Derecelendirme
(21)
Projeler
24
17%
Arabuluculuk
15
20% / 40%
Süresi dolmuş
6
25%
Serbest
10
Geliştirici 10
Derecelendirme
(1156)
Projeler
1462
63%
Arabuluculuk
21
57% / 10%
Süresi dolmuş
43
3%
Serbest
11
Geliştirici 11
Derecelendirme
Projeler
0
0%
Arabuluculuk
0
Süresi dolmuş
0
Serbest
12
Geliştirici 12
Derecelendirme
(41)
Projeler
46
28%
Arabuluculuk
9
0% / 100%
Süresi dolmuş
7
15%
Serbest
13
Geliştirici 13
Derecelendirme
(3)
Projeler
4
0%
Arabuluculuk
1
100% / 0%
Süresi dolmuş
0
Serbest

Proje bilgisi

Bütçe
30+ USD
Son teslim tarihi
to 2 gün