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

Работа завершена

Время выполнения 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
Оценка
(636)
Проекты
1006
47%
Арбитраж
33
36% / 36%
Просрочено
99
10%
Работает
Опубликовал: 6 примеров
2
Разработчик 2
Оценка
(90)
Проекты
136
14%
Арбитраж
43
21% / 28%
Просрочено
14
10%
Свободен
Опубликовал: 2 примера
3
Разработчик 3
Оценка
(115)
Проекты
129
18%
Арбитраж
11
27% / 55%
Просрочено
4
3%
Свободен
4
Разработчик 4
Оценка
(163)
Проекты
236
32%
Арбитраж
30
27% / 30%
Просрочено
26
11%
Свободен
5
Разработчик 5
Оценка
(45)
Проекты
58
33%
Арбитраж
12
42% / 42%
Просрочено
7
12%
Свободен
6
Разработчик 6
Оценка
(3)
Проекты
4
0%
Арбитраж
2
0% / 100%
Просрочено
1
25%
Свободен
7
Разработчик 7
Оценка
(269)
Проекты
284
55%
Арбитраж
0
Просрочено
5
2%
Свободен
8
Разработчик 8
Оценка
(24)
Проекты
28
32%
Арбитраж
1
0% / 0%
Просрочено
0
Свободен
Опубликовал: 1 пример
9
Разработчик 9
Оценка
(21)
Проекты
24
17%
Арбитраж
15
20% / 40%
Просрочено
6
25%
Свободен
10
Разработчик 10
Оценка
(1156)
Проекты
1462
63%
Арбитраж
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
Свободен
Похожие заказы
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

Информация о проекте

Бюджет
30+ USD
Сроки выполнения
до 2 дн.