//+------------------------------------------------------------------+ //| 66479.mq4 | //| Copyright 2015, Alain Verleyen. | //| https://login.mql5.com/en/users/angevoyageur | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, Alain Verleyen." #property link "http://docs.mql4.com/constants/objectconstants/visible" #property version "1.00" #property strict 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 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". 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); } } } //+------------------------------------------------------------------+