Why does extracted indicator data on the chart delays reading on larger timeframes eg 1 hr or 4hr TF?
This is most likely an issue caused by the way your indicator handles data or calculations (coding). Without reviewing the code, we cannot pinpoint the exact issue; it would only be speculation. Please attach the source code of your indicator and, if possible, a screenshot describing the issue so we can better understand and analyze the situation. Once you share it, we will be happy to help!
This is most likely an issue caused by the way your indicator handles data or calculations (coding). Without reviewing the code, we cannot pinpoint the exact issue; it would only be speculation. Please attach the source code of your indicator and, if possible, a screenshot describing the issue so we can better understand and analyze the situation. Once you share it, we will be happy to help!
Hello Vinicius,
Below is the sample code of the indicator am facing the issue with. So I extract the data from macor indicator to create the signal line, on 1 min TF both the value and signal line with exactly as the macor indicator, but on larger timeframes like 4hrs, the signal line data reads different in decimals.
Below is a sample code of how I extract the value from the indicator.
//+------------------------------------------------------------------+ //| MA of Macor.mq5 | //| Copyright 2025, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, MetaQuotes Ltd." #property link "https://www.mql5.com" #property description "Moving Average of Macor" #property version "1.00" #property indicator_separate_window #property indicator_buffers 2 #property indicator_plots 2 //--- plot Macor #property indicator_label1 "Macor" #property indicator_type1 DRAW_LINE #property indicator_color1 clrWhite #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot MaOfMacor #property indicator_label2 "MaOfMacor" #property indicator_type2 DRAW_LINE #property indicator_color2 clrRed #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- inputs input int iMA1Period = 14; //Ma1 input int iMA2Period = 100; //Ma2 input int MaPeriod =100; //Ma Period input ENUM_MA_METHOD MaMethod = MODE_SMA; //Ma Method //--- indicator buffers double Macor[]; double MaOfMacor[]; //atr handle int macor_handle=INVALID_HANDLE,ma_handle=INVALID_HANDLE,deflector=0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,Macor,INDICATOR_DATA); SetIndexBuffer(1,MaOfMacor,INDICATOR_DATA); macor_handle=iCustom(_Symbol,_Period,"macor.ex5",iMA1Period,iMA2Period); if(macor_handle==INVALID_HANDLE) { Print("Cant Create MACOR Handle "); return(INIT_FAILED); } //we create an ma and provide the handle of the atr indicator we just created as a price ma_handle=iMA(_Symbol,_Period,MaPeriod,0,MaMethod,macor_handle); if(ma_handle==INVALID_HANDLE) { Print("Cant Create Ma on MACOR Handle "); return(INIT_FAILED); } deflector=iMA1Period; if(MaPeriod>deflector) { deflector=MaPeriod; } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- //a hasty copier double copiando[]; int i_from=rates_total-deflector,i_to=0; if(prev_calculated==rates_total) { i_from=0; } if((rates_total-prev_calculated)==1) { i_from=1; } for(int i=i_from;i>=i_to;i--) { int j=rates_total-i-1;//point to the storage adress int copi=CopyBuffer(macor_handle,0,i,1,copiando); if(copi==1) { Macor[j]=copiando[0]; } copi=CopyBuffer(ma_handle,0,i,1,copiando); if(copi==1) { MaOfMacor[j]=copiando[0]; } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
Hi Mark Anthony, I couldn't reproduce the failure you described... Here the values of M1 and H4 match in the 2 indicators (Macor / MA of Macor):
//+------------------------------------------------------------------+ //| Macor.mq5 | //| Copyright 2025, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, MetaQuotes Ltd." #property link "https://www.mql5.com" #property description "Macor" #property version "1.00" #property indicator_separate_window #property indicator_buffers 3 #property indicator_plots 1 input int iMA1Period = 14; input int iMA2Period = 100; double ExtMA1[], ExtMA2[], ExtDelta[]; int Handle_MA1, Handle_MA2; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0,ExtDelta); SetIndexBuffer(1,ExtMA1); SetIndexBuffer(2,ExtMA2); PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_LINE); PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrBlue); if((Handle_MA1 = iMA(NULL,0,iMA1Period,0,MODE_EMA,PRICE_CLOSE)) == INVALID_HANDLE) return INIT_FAILED; if((Handle_MA2 = iMA(NULL,0,iMA2Period,0,MODE_EMA,PRICE_CLOSE)) == INVALID_HANDLE) return INIT_FAILED; return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { if(prev_calculated<1) { ArrayInitialize(ExtMA1,EMPTY_VALUE); ArrayInitialize(ExtMA2,EMPTY_VALUE); ArrayInitialize(ExtDelta,EMPTY_VALUE); } if(CopyBuffer(Handle_MA1,0,0,MathMin(rates_total-prev_calculated+1,rates_total-1),ExtMA1)<=0) return 0; if(CopyBuffer(Handle_MA2,0,0,MathMin(rates_total-prev_calculated+1,rates_total-1),ExtMA2)<=0) return 0; for(int i=MathMax(0,prev_calculated-1); i<rates_total && !_StopFlag; i++) ExtDelta[i] = ExtMA1[i] - ExtMA2[i]; return(rates_total); } //+------------------------------------------------------------------+... I may not have understood your question... 😊
Hi Mark Anthony, I couldn't reproduce the failure you described... Here the values of M1 and H4 match in the 2 indicators (Macor / MA of Macor):
... I may not have understood your question... 😊Hello Vinicius,
You are on track Sir, Kindly extract the data to the chart, both the macor value and the signal line value.
You will notice the indicator value (displayed directly on the indicator) is slightly different from the extracted data on the chart when on the 4hr timeframe.
You currently have the data displayed on the indicator, but my issue is when I extract it to the price chart, it turns to read slightly sluggish on higher timeframes like 4hr, mean while I extracted directly from the same indicator.
See if the IndicatorSetInteger() function helps with this problem:
//--- set accuracy IndicatorSetInteger(INDICATOR_DIGITS, _Digits);

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello MT folks,
I have a sample indicator I extracted. On the 1-minute timeframe, the data displayed on the indicator appears the same on the chart as I have extracted.
But immediately, I switch the timeframe to 4 hours, the data displayed on the indicator is mostly slightly different in decimals from the extracted data on the chart.
Why does this happen? I believe it would impact the performance of my EA if it functions in that manner. If there is a way to correct this, kindly assist me, please.