Download MetaTrader 5

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

To add comments, please log in or register
Move from theory to practice. Code Base will help you!
Jordi Bassaganas
3528
Jordi Bassaganas 2013.09.25 12:24 

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! 

Alain Verleyen
Moderator
30737
Alain Verleyen 2013.09.25 12:56  
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);
Jordi Bassaganas
3528
Jordi Bassaganas 2013.09.25 13:05  
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.
Alain Verleyen
Moderator
30737
Alain Verleyen 2013.09.25 16:25  
laplacianlab:
You're a truly expert! Thank you for this detail.
You are welcome, I try my best.
To add comments, please log in or register