1. Use ObjectsDeleteAll to remove objects on chart(with a prefix included to avoid affecting other objects).
2. Then you call Draw_Pivotlevels. This will force to only have the SR levels you want for that specific time frame.
3. And make sure to do this procedure in OnInit so it will be executed every time you change time frame or load a chart.
1. Use ObjectsDeleteAll to remove objects on chart(with a prefix included to avoid affecting other objects).
2. Then you call Draw_Pivotlevels. This will force to only have the SR levels you want for that specific time frame.
3. And make sure to do this procedure in OnInit so it will be executed every time you change time frame or load a chart.
bro, I'm struggling with three issues now.. can you help me.
01. is it correct comparing if (ChartPeriod() == PPERIOD_M15) {} or should I use another function?
02. I used this way, but nothing happens... I checked the object list. Object has drawn, but the visibility is not correctly setup.
03. I also used Color property directly from inputs, it's not working too. the I tried clrAliceblue. it worked btw.
input color H1_Resistance; input color H1_Support; if(ChartPeriod(0) == PERIOD_M15) // H1 Pivot Levels { Draw_Lines("H1_R1",Time1H,H1_R1,TimeEnd_Month,H1_R1,H1_Resistance,"H1_R1",PERIOD_M15); Draw_Lines("H1_R2",Time1H,H1_R2,TimeEnd_Month,H1_R2,H1_Resistance,"H1_R2",PERIOD_M15); Draw_Lines("H1_R3",Time1H,H1_R3,TimeEnd_Month,H1_R3,H1_Resistance,"H1_R3",PERIOD_M15); Draw_Lines("H1_S1",Time1H,H1_S1,TimeEnd_Month,H1_S1,H1_Support,"H1_S1",PERIOD_M15); Draw_Lines("H1_S2",Time1H,H1_S2,TimeEnd_Month,H1_S2,H1_Support,"H1_S2",PERIOD_M15); Draw_Lines("H1_S3",Time1H,H1_S3,TimeEnd_Month,H1_S3,H1_Support,"H1_S3",PERIOD_M15); } } //+------------------------------------------------------------------+ //| Expert Object Function -- 00 -- Draw Vertiacl Line | //+------------------------------------------------------------------+ void Draw_Lines(string ObjName,datetime Time1, double price1, datetime Time2, double price2, color clr, string label, ENUM_TIMEFRAMES TF) { ObjectDelete(0,ObjName); ObjectCreate(0,ObjName,OBJ_TREND,0,Time1,price1,Time2,price2); // Horizonal Ray Line with times ObjectSetInteger(0,ObjName, OBJPROP_COLOR, clr); ObjectSetInteger(0, ObjName, OBJPROP_WIDTH, 1); ObjectSetInteger(0, ObjName, OBJPROP_BACK,1); ObjectSetInteger(0,ObjName,OBJPROP_COLOR,clrAliceBlue); ObjectSetString(0,ObjName,OBJPROP_TEXT,label); ObjectSetInteger(0,ObjName,OBJPROP_TIMEFRAMES,TF); }
The way you use ChartPeriod is correct I believe.
But there is a good solution in this topic to set visibility:

- 2015.01.23
- mar
- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to know how to set objects visible only for certain time frame. ex - Line 01 should be visible only for timeframes bellow 1h.
I'm here in the Weekly timeframe, so I want to only to see monthly pivot points. Can you suggest me a function to achieve this?
currently used this functions to draw these lines.