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

MQL4 Indicadores Sripts

Trabajo finalizado

Plazo de ejecución 2 horas
Comentario 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.
Comentario del Ejecutor
Great customer, prompt communication, clear specs, recommended+

Tarea técnica

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:


 



Han respondido

1
Desarrollador 1
Evaluación
(636)
Proyectos
1006
47%
Arbitraje
33
36% / 36%
Caducado
99
10%
Trabaja
Ha publicado: 6 ejemplos
2
Desarrollador 2
Evaluación
(90)
Proyectos
136
14%
Arbitraje
43
21% / 28%
Caducado
14
10%
Libre
Ha publicado: 2 ejemplos
3
Desarrollador 3
Evaluación
(115)
Proyectos
129
18%
Arbitraje
11
27% / 55%
Caducado
4
3%
Libre
4
Desarrollador 4
Evaluación
(163)
Proyectos
236
32%
Arbitraje
30
27% / 30%
Caducado
26
11%
Libre
5
Desarrollador 5
Evaluación
(45)
Proyectos
58
33%
Arbitraje
12
42% / 42%
Caducado
7
12%
Libre
6
Desarrollador 6
Evaluación
(3)
Proyectos
4
0%
Arbitraje
2
0% / 100%
Caducado
1
25%
Libre
7
Desarrollador 7
Evaluación
(269)
Proyectos
284
55%
Arbitraje
0
Caducado
5
2%
Libre
8
Desarrollador 8
Evaluación
(24)
Proyectos
28
32%
Arbitraje
1
0% / 0%
Caducado
0
Libre
Ha publicado: 1 ejemplo
9
Desarrollador 9
Evaluación
(21)
Proyectos
24
17%
Arbitraje
15
20% / 40%
Caducado
6
25%
Libre
10
Desarrollador 10
Evaluación
(1156)
Proyectos
1462
63%
Arbitraje
21
57% / 10%
Caducado
43
3%
Libre
11
Desarrollador 11
Evaluación
Proyectos
0
0%
Arbitraje
0
Caducado
0
Libre
12
Desarrollador 12
Evaluación
(41)
Proyectos
46
28%
Arbitraje
9
0% / 100%
Caducado
7
15%
Libre
13
Desarrollador 13
Evaluación
(3)
Proyectos
4
0%
Arbitraje
1
100% / 0%
Caducado
0
Libre
Solicitudes similares
Mamba EA Scalper 30 - 40 USD
Hi, i need a aggressive mobile trading bot which supports both IOS and Android versions, the bot will use stochastic oscillator indicator %K period:15 , while % D period:9 and slowing :9 ,price field should be Low/High while it's method should be simple , Levels: 20,80 and time frames: all . The styles should have a main line which should be green and signal line which should be red . The bot should be able to trade
a one min scalper which will scalp on a one minute timeframe and can trade a low account to a big one and is more effective in mt4 and mt5 for a very short period of time yeah
Mt5 ea 30+ USD
I have a fast execution ea that need a little touch, it trade on gold and my problem is about the risk ratio the tp is 3pip and stop loss 20 but i cannot get it right to make the average win larger and average loss lower. I would like to know if i can get help to get it right without touching the tragedy and the trade frequency. Those two pictures I attached is the example of what my bot actually do like i explained
hello could you make me same indicator for ninja ? https://www.youtube.com/watch?v=pxs2MuqvH3w if yes for how much and timeline ? thks in advance and please reply me as soon as possible you get my notification
Hello, I want a simple bot for NinjaTrader8. I need a bot that operates automatically on Nasdaq (NQ/MNQ). Requirements: open buys and sells following a simple trend strategy, configurable stop loss and take profit, risk per trade of 1 to 2% of capital, if it loses 3% in a day, stop trading until the next day. Compatible with backtesting, delivery of the source code and the working bot in NinjaTrader 8. My initial
[8/4/2026 4:54 AM] DR.HassaN: AI Gold Analysis Web Platform Requirements Hello, I would like to build a professional AI-powered web platform dedicated exclusively to Gold (XAU/USD) analysis . This is NOT a trading platform or broker . It is an intelligent analysis platform that provides high-quality trading signals and detailed market analysis. The platform should have a modern, premium design with my own branding
Ema100+Fibo 30+ USD
I need a robot that sends me a notification when the price aligns with the EMA and my Fibonacci levels—using specific Fibonacci settings—and then either opens a trade based on the Fibonacci SL and TP or simply sends me a notification. And I want the robot to run in both the Strategy Tester and on a demo account, so I can test it beforehand
I need a custom technical indicator that generates an equidistant channel with two specific structural features: 1. Vertical Multi-Intervals: The ability to plot more than 5 parallel, able to allow me to put intervals 2. Horizontal Angle Input: The ability to manually input geometric angle to strictly define the horizontal slope of the channel or allow me to pick two points manually. i am looking for something like
//+------------------------------------------------------------------+ //| DX_Structure_H1.mq5 | //| Copyright 2026, Seu Nome | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2026" #property link " https://www.mql5.com " #property version "1.00" #property strict // Parâmetros de Entrada input string InpSymbol = "DX.F"; // Nome do Ativo
Hola, traders e inversores: Desarrollamos soluciones de trading algorítmico para MetaTrader 4 y MetaTrader 5. Creamos bots, indicadores y herramientas a medida que convierten estrategias manuales en sistemas automáticos, configurables y orientados a una gestión de riesgo sólida. Hemos trabajado en automatizaciones que integran entradas y salidas por reglas, cálculo de lotaje, control de drawdown, filtros de horario y

Información sobre el proyecto

Presupuesto
30+ USD
Plazo límite de ejecución
a 2 día(s)