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

MQL4 Indicators Scripts

Job finished

Execution time 2 hours
Feedback from customer
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 from employee
Great customer, prompt communication, clear specs, recommended+

Specification

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:


 



Responded

1
Developer 1
Rating
(620)
Projects
971
46%
Arbitration
32
38% / 34%
Overdue
96
10%
Working
Published: 6 codes
2
Developer 2
Rating
(90)
Projects
136
14%
Arbitration
43
21% / 28%
Overdue
14
10%
Free
Published: 2 codes
3
Developer 3
Rating
(115)
Projects
129
18%
Arbitration
11
27% / 55%
Overdue
4
3%
Free
4
Developer 4
Rating
(163)
Projects
236
32%
Arbitration
28
29% / 25%
Overdue
26
11%
Free
5
Developer 5
Rating
(45)
Projects
58
33%
Arbitration
12
42% / 42%
Overdue
7
12%
Free
6
Developer 6
Rating
(3)
Projects
4
0%
Arbitration
2
0% / 100%
Overdue
1
25%
Free
7
Developer 7
Rating
(256)
Projects
271
54%
Arbitration
0
Overdue
5
2%
Free
8
Developer 8
Rating
(24)
Projects
28
32%
Arbitration
1
0% / 0%
Overdue
0
Free
Published: 1 code
9
Developer 9
Rating
(21)
Projects
24
17%
Arbitration
15
20% / 40%
Overdue
6
25%
Free
10
Developer 10
Rating
(1156)
Projects
1462
63%
Arbitration
21
57% / 10%
Overdue
43
3%
Free
11
Developer 11
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
12
Developer 12
Rating
(41)
Projects
46
28%
Arbitration
9
0% / 100%
Overdue
7
15%
Free
13
Developer 13
Rating
(3)
Projects
4
0%
Arbitration
1
100% / 0%
Overdue
0
Free
Similar orders
Ninjatrader 200+ USD
hello great developer I have 3 indicators and trend lines with 11 entries that need analysis. I can provide detailed instructions and charts to guide the work. Scope of work - Analyze 3 indicators and trend lines with 11 entries. References - I can send 8 pages of instructions and 22 charts to show what's needed. Trading platform NinjaTrader
I’m looking for a reliable indicator that places buy/sell signals directly on the chart. The key requirement is that signals must appear only after candle close and must not repaint under any condition. I'll be able to send you screenshots so you can understand my accurcy expectations... I’m offering a high budget for a smooth and professional collaboration. To ensure transparency and fairness for both sides, I
1. What does our Algo do ? Enhanced version of the Algo Market Structure indicator with sophisticated Valid Trading Range (VTA) alert system that prevents fake alerts and provides visual/audio notifications based on the trading flowchart logic. 2. This is a new script in Trading view must follow the requirements written here We use the standard functionality from Trading view to generate a specific
Objective: Develop a highly reliable Expert Advisor (EA) capable of passing and maintaining FTMO prop firm challenges by achieving steady, consistent profits with controlled risk and minimal drawdown. Key Goals: 1. Reliability: EA must perform consistently across different market conditions — trending, ranging, and high-volatility periods. 2. Profitability: Target an average monthly gain of 11–15%, while respecting
(Isolated ×3 Leverage | Trailing Profit Lock | Bybit Futures Trading) No demo account available. Developer must use personal testing setup or Bybit testnet API keys to validate connectivity, simulate runs, and deploy to the specified VPS prior to handover. 🔴 Pre-Flight Checklist (NON-NEGOTIABLE – Complete Before Coding) 🟥 API Validation: • Enable: Trading + Info Read (Zero withdrawal perms). • Whitelist VPS IP if
New options in Account Management: I have an EA, which does trade and does some account management as well. Need to add the following options as well in the existing code. 1. Enable Maximum Exposure control - True / False Breakeven closure after max trades - 15 Immediate closure after max trades – 25 ExposureTrailingSLLevel – 1.5 ExposureTrailingNextLevel – 2.5 New trades after - immediate /session /day/week
Necesito convertir un indicador de código abierto de Tradingview a MT5, es un indicador sencillo, solo necesito que copie los MSS por lo que se puede obviar todo lo demás
I need a fully automated trading bot for MetaTrader 5 that can open and close positions around major U.S. news releases, specifically Non-Farm Payrolls (NFP) and CPI. Before each release I will enter the exact price level where I want to sell; at the scheduled announcement the bot must instantly check that price and, if it is reached or crossed, execute the trade without manual intervention. To achieve this, the code
I need a skilled MQL5 developer to convert the meter section of the LuxAlgo Market Sentiment Technicals indicator from TradingView (Pine Script) into a fully functional MetaTrader 5 (MT5) version. The MT5 indicator should display the same sentiment states — Bullish, Strong Bullish, Neutral, Bearish, and Strong Bearish — and match the TradingView version in both logic and timing accuracy (within 1–2 seconds)
Code already Build need someone to debug it so I can compile it and make it work very elaborate code don't want it changed. this is what it has let me know if you can fix What's Included - ALL 4 PARTS! ✅ PART 1: Initialization & Database Layer (788 lines) Core constants & enumerations Advanced data structures Global variables & arrays Memory management system Indicator manager class Main functions (OnInit

Project information

Budget
30+ USD
For the developer
27 USD
Deadline
to 2 day(s)