Get current timeframe

 

Hello. I wonder how to get timeframe on which EA or indicator is executing?

 

here it is

Period()

 
The_N:
Hello. I wonder how to get timeframe on which EA or indicator is executing?

Use this:

string tf()

{

switch(Period())

{

case PERIOD_M1: return("M(1)");

case PERIOD_M5: return("M(5)");

case PERIOD_M15: return("M(15)");

case PERIOD_M30: return("M(30)");

case PERIOD_H1: return("H(1)");

case PERIOD_H4: return("H(4)");

case PERIOD_D1: return("D(1)");

case PERIOD_W1: return("W(1)");

case PERIOD_MN1: return("MN(1)");

default:return("Unknown timeframe");

}

}

Reason: