Is it possible to use CopyBuffer specifically for using it in time frames?

 

Hi there,

I am using the function CopyBuffer inside OnCalculate this way:

if(CopyBuffer(DEMAHandler,0,0,rates_total,DEMABuffer)<=0) return(0);

I understand that the programming sentence above generates an array with the info of all the rates (MN, month). But is it possible to call CopyBuffer in order to fill DEMABuffer with as many elements as the total number of rates of a given time frame (H1, H4, etc.)? In other words, how can you ask for the number of rates of a given time frame? Thks a lot in advance! 

 
laplacianlab:

Hi there,

I am using the function CopyBuffer inside OnCalculate this way:

I understand that the programming sentence above generates an array with the info of all the rates (MN, month). But is it possible to call CopyBuffer in order to fill DEMABuffer with as many elements as the total number of rates of a given time frame (H1, H4, etc.)? In other words, how can you ask for the number of rates of a given time frame? Thks a lot in advance! 

You have to use an other handle for DEMA with requested Period as parameter.

Then you can use Bars() function. That gives something like :

int count = Bars(_Symbol, RequestedPeriod);
if(CopyBuffer(DEMAHandler_RequestedPeriod,0,0,count,DEMABuffer_RequestedPeriod)<=0) return(0);
 
angevoyageur:

You have to use an other handle for DEMA with requested Period as parameter.

Then you can use Bars() function. That gives something like :

You're a truly expert! Thank you for this detail.
 
laplacianlab:
You're a truly expert! Thank you for this detail.
You are welcome, I try my best.