Download MetaTrader 5

Get indicator timeframe by indicator_handle

To add comments, please log in or register
Do you need private account monitoring? The Signals will provide you one!
Gabor Torma
2676
Gabor Torma 2012.11.20 14:35 

Hi!

Is it possible to get the time frame of indicator using only indicator_handle?

int MAHandle=iMA(_Symbol,PERIOD_M5,5,0,MODE_EMA,PRICE_HIGH);

ENUM_TIMEFRAMES indicator_period = ???(MAHandle);  // result is PERIOD_M5

Thanx!

Biantoro Kunarto
14896
Biantoro Kunarto 2012.11.21 03:12  
VincentX:

Hi!

Is it possible to get the time frame of indicator using only indicator_handle?

Thanx!

I don't understand why you need to get the time frame from indicator handle, maybe you can do this:


ENUM_TIMEFRAMES indicator_period = PERIOD_M5;
int MAHandle=iMA(_Symbol,indicator_period,5,0,MODE_EMA,PRICE_HIGH);

and if you need to get the time frame then you just call variable indicator_period.

Gabor Torma
2676
Gabor Torma 2012.11.21 08:40  
biantoro:

I don't understand why you need to get the time frame from indicator handle, maybe you can do this:

I want to use the value of indicator_period in an external predefined function. This function has only indicator_handle input parameter like CopyBuffer.

// Lib.mqh
#property library

int MyCopyBuffer(int indicator_handle,...) export
   {
    ENUM_TIMEFRAMES indicator_period = ???(indicator_handle);
   }

// Indicator.mq5
#import "Lib.ex5"
int MyCopyBuffer(int indicator_handle,...);
#import

int MAHandle=iMA(_Symbol,PERIOD_M5,5,0,MODE_EMA,PRICE_HIGH);
MyCopyBuffer(MAHandle,...);
Gabor Torma
2676
Gabor Torma 2012.11.21 08:42  

Of course, I know one solution. I can set a parameter for MyCopyBuffer with indicator_period, but it's not nice for me.

int MyCopyBuffer(int indicator_handle,ENUM_TIMEFRAMES indicator_period,...) export
To add comments, please log in or register