Perhaps you should read the manual.
MQL5
Reference → Object Functions → ObjectGetInteger
→ ENUM_OBJECT_PROPERTY_INTEGER
→ you find:
Identifier | Description | Property Type |
OBJPROP_TIMEFRAMES | Visibility of an object at timeframes | set of flags flags |
And the flags link takes you to:
MQL5
Reference → Objects Constants → Visibility
of Objects → Constants, Enumerations and Structures / Objects Constants /
Visibility of Objects - Reference on algorithmic/automated trading language for MetaTrader 5 → where you find the
corresponding bit maps.
Hi,
can anyone help me how to write IF statement to check if object is visible on current time frame...
For example: object is hidden on Daily and M15, now i need to check this with IF statement.
How to do this?
Please make your homework and search before posting.
Forum on trading, automated trading systems and testing trading strategies
Question about OBJPROP_TIMEFRAMES
Alain Verleyen, 2015.01.24 13:53
Just for fun.
By the way I found 2 bugs in the process, see comments (first one already found by Gumrai)
input string objname="test"; //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { long objTimeframes=0; ENUM_TIMEFRAMES period=(ENUM_TIMEFRAMES)Period(); //--- Get visibility property of the object if(ObjectGetInteger(0,"test",OBJPROP_TIMEFRAMES,0,objTimeframes)) { long mask=-1; //--- set mask from period switch(period) { case PERIOD_M1 : mask=0x0001; break; // The object is drawn in 1-minute chart case PERIOD_M5 : mask=0x0002; break; // The object is drawn in 5-minute chart case PERIOD_M15: mask=0x0004; break; // The object is drawn in 15-minute chart case PERIOD_M30: mask=0x0008; break; // The object is drawn in 30-minute chart case PERIOD_H1 : mask=0x0010; break; // The object is drawn in 1-hour chart case PERIOD_H4 : mask=0x0020; break; // The object is drawn in 4-hour chart case PERIOD_D1 : mask=0x0040; break; // The object is drawn in day charts case PERIOD_W1 : mask=0x0080; break; // The object is drawn in week charts case PERIOD_MN1: mask=0x0100; break; // The object is drawn in month charts default: break; } //--- check mask. Special cases : //--- 1° BUG 1: if "Show on all timeframes" is enabled, objTimeframes=0 is returned and not '0x01ff' as stated in documentation. //--- 2° BUG 2: it's not possible with MT4 to disable "Show on all timeframes" without enabled at least 1 period ; //--- but it's possible to set it to -1 with mql4. In this case, MT4 object properties window will display erroneously "Show on all timeframes" enabled. if(objTimeframes==0 || (objTimeframes!=-1 && (objTimeframes&mask)==mask)) { printf("Object %s is visible on this chart %s",objname,EnumToString(period)); } else { printf("Object %s exists but is not visible on this chart %s",objname,EnumToString(period)); } } //--- ObjectGetInteger error processing else { int err=GetLastError(); if(err==ERR_OBJECT_DOES_NOT_EXIST) { printf("Object %s doesn't exist!",objname); } else { printf("Error(%i) whily getting properties of %s",err,objname); } } } //+------------------------------------------------------------------+

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
can anyone help me how to write IF statement to check if object is visible on current time frame...
For example: object is hidden on Daily and M15, now i need to check this with IF statement.
How to do this?