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

MQL4 指标 脚本

工作已完成

执行时间2 小时
客户反馈
John knows his programming! And he did more than was expected. I can strongly recommend him to anyone who is looking for a programmer.
员工反馈
Great customer, prompt communication, clear specs, recommended+

指定

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:


 



反馈

1
开发者 1
等级
(600)
项目
935
46%
仲裁
31
39% / 29%
逾期
93
10%
空闲
2
开发者 2
等级
(87)
项目
134
14%
仲裁
41
22% / 29%
逾期
14
10%
工作中
3
开发者 3
等级
(115)
项目
129
18%
仲裁
11
27% / 55%
逾期
4
3%
空闲
4
开发者 4
等级
(155)
项目
224
33%
仲裁
27
26% / 26%
逾期
23
10%
空闲
5
开发者 5
等级
(45)
项目
58
33%
仲裁
12
42% / 42%
逾期
7
12%
空闲
6
开发者 6
等级
(3)
项目
4
0%
仲裁
2
0% / 100%
逾期
1
25%
空闲
7
开发者 7
等级
(184)
项目
199
47%
仲裁
0
逾期
5
3%
空闲
8
开发者 8
等级
(24)
项目
28
32%
仲裁
1
0% / 0%
逾期
0
空闲
9
开发者 9
等级
(21)
项目
24
17%
仲裁
15
20% / 40%
逾期
6
25%
空闲
10
开发者 10
等级
(1135)
项目
1438
62%
仲裁
21
57% / 10%
逾期
43
3%
空闲
11
开发者 11
等级
项目
0
0%
仲裁
0
逾期
0
空闲
12
开发者 12
等级
(41)
项目
46
28%
仲裁
9
0% / 100%
逾期
7
15%
空闲
13
开发者 13
等级
(3)
项目
4
0%
仲裁
1
100% / 0%
逾期
0
空闲
相似订单
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

项目信息

预算
30+ USD
开发人员
27 USD
截止日期
 2 天