Download MetaTrader 5

CopyBuffer takes too long when there isn't enough bars to calculate Indicator for high periods

To add comments, please log in or register
Use the Pocket to paste your content. It is convenient!
mbingol
26
mbingol 2015.08.21 13:29 

Hi,

I am working on TEMA indicator values of different periods (500,1000, 2000 etc) for different time frames.

When I add these indicators on the graph of H1 timeframe, I can see 500 and 1000. But since there is not enough number of bars for 2000, it can't be calculated which is normal.

In my EA, I am using CopyBuffer to get the values of these indicators for selected symbol and timeframe (M1 through W1). So for Short time frames like M1, M5; since there are enough number of bars to calculate TEMA2000, everything is normal. But for H1, the CopyBuffer command for TEMA2000 WAITS TOO LONG (around 1 minute) to understand that there is not enough number of bars to calculate any value.

I thought getting the "PLOT_DRAW_BEGIN" property of the indicator for the selected timeframe would be a good idea. I could compare the period (2000) with it and decide whether I should run the CopyBuffer command at all, but there isn't a PlotIndexGetInteger command. We can only set the property with :

PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);

Thanks in advance.

Alain Verleyen
Moderator
30742
Alain Verleyen 2015.08.21 14:32  
Did you try to use Bars() function, see documentation.
To add comments, please log in or register