Get indicator timeframe by indicator_handle

 

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!

 
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.

 
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,...);
 

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
Reason: