Read custom indicator with different time frame

 

Hello, I have a custom indicator and I would like to read it 2 times, the first for the current time and the second for a different time, when I call the indicator I change the time to the second as shown in the image, but it returns the same value for the current time frame. Can someone help me please . I thank you.


I attach the indicator so that you can test it please


int    handle_BAND;
int    handle_BAND_H1;

double CAP_UP[];
double CAP_DW[];
double CAP_UP_1[];
double CAP_DW_1[];  

 int OnInit()
  {
   handle_BAND=iCustom (Symbol() , PERIOD_CURRENT,"tma-centered-bands-indicator",PeriodChannel,6,100,2.0,4); 
   handle_BAND_H1=iCustom (Symbol() ,PERIOD_H1,"tma-centered-bands-indicator",12,6,80,2.5,4);
}

void OnTick()
{
      ArraySetAsSeries(CAP_UP,true);
      ArraySetAsSeries(CAP_DW,true);
      double CAP_0=CopyBuffer(handle_BAND,2,0,20,CAP_UP);
      double CAP_1=CopyBuffer(handle_BAND,3,0,20,CAP_DW);
      Print("Canal UP  actual: ",CAP_UP[0]);
      Print("Canal DW  actual: ",CAP_DW[0]);
      
      ArraySetAsSeries(CAP_UP_1,true);
      ArraySetAsSeries(CAP_DW_1,true);
      bool band_1=CopyBuffer(handle_BAND_H1,2,0,10,CAP_UP_1);
      bool band_2=CopyBuffer(handle_BAND_H1,3,0,10,CAP_DW_1);
	
Print("Canal UP  actual: ",CAP_UP_1[0]);
Print("Canal DW  actual: ",CAP_DW_1[0]);
}



The result is as follows:

Step on New Rails: Custom Indicators in MQL5
Step on New Rails: Custom Indicators in MQL5
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
 

Please post in English only. Use the automatic translation tool if needed.

Your topic has been moved to the section: Technical Indicators

If you need help with your code, then show your code useing the CODE button (Alt-S) or attach source files. Don't show your code as a screenshot.

Code button in editor

 
Fernando Carreiro #:

Please post in English only. Use the automatic translation tool if needed.

Your topic has been moved to the section: Technical Indicators

If you need help with your code, then show your code useing the CODE button (Alt-S) or attach source files. Don't show your code as a screenshot.

Ok thanks, I have updated the post.

Reason: