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
등급
(599)
프로젝트
932
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
등급
(180)
프로젝트
195
46%
중재
0
기한 초과
5
3%
무료
8
개발자 8
등급
(24)
프로젝트
28
32%
중재
1
0% / 0%
기한 초과
0
무료
9
개발자 9
등급
(21)
프로젝트
24
17%
중재
15
20% / 40%
기한 초과
6
25%
무료
10
개발자 10
등급
(1134)
프로젝트
1436
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 someone experienced with Think or Swim to create a backtesting script for an in-the-money Iron Condor strategy using options on the SPX. The strategy involves setting up 10 contracts of an Iron Condor with a 10-point spread width and a net credit requirement of $11 per contract. The goal is to backtest the performance over the last three years, focusing on trades where the SPX closes outside a
I currently have a license code that connects to my web server, and I add the account number, client name, and expiration date. I’d like something more automated. Currently I allow clients 10 licenses, but adding for them on my side can get exhausting. I’d like a better solution for myself and clients

프로젝트 정보

예산
30+ USD
개발자에게
27 USD
기한
 2 일