#property strict #property indicator_chart_window input color ColorUP=Lime; input color ColorDN=Red; input bool back = false;//Solid color? datetime T; string MQL_name; int f,Bar; //--- string LabelID = "DRange_"; int OnInit() { MQL_name=MQLInfoString(MQL_PROGRAM_NAME); return(INIT_SUCCEEDED); } //--- void OnDeinit(const int reason) { DeleteObjects(); } void DeleteObjects() { string lookFor = LabelID; int lookForLength = StringLen(lookFor); for (int i=ObjectsTotal()-1; i>=0; i--) { string objectName = ObjectName(i); if (StringSubstr(objectName,0,lookForLength) == lookFor) ObjectDelete(objectName); } //WindowRedraw(); } //--- int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { DeleteObjects(); DrawWeekBox(); ChartRedraw(); return(rates_total); } //--- void DrawWeekBox() { if(f==0) { Bar=50; } else { Bar=1; } for(int iw=0; iwclose) { clr=ColorDN; } else { clr=ColorUP; } if(TimeDayOfWeek(iTime(NULL,PERIOD_D1,iw))==2) { TXT=" Tue("; } if(TimeDayOfWeek(iTime(NULL,PERIOD_D1,iw))==3) { TXT=" Wed("; } if(TimeDayOfWeek(iTime(NULL,PERIOD_D1,iw))==4) { TXT=" Thu("; } if(TimeDayOfWeek(iTime(NULL,PERIOD_D1,iw))==5) { TXT=" Fri("; } Draw_TrandLine_or_Box(0,"WeekDay"+tname,OBJ_RECTANGLE,t+86400,high,t,low,clr,+1,STYLE_DOT); DrawTXT(TXT+tname,TXT,range,t,high,clr); } } //--- void DrawTXT(string name,string daytext,double Range, datetime time,double price,color clr,ENUM_ANCHOR_POINT ANCHOR_=ANCHOR_LEFT_LOWER,int size=8) { name=LabelID+name; string RangeTXT = DoubleToStr(Range,0)+")"; string text = daytext + RangeTXT; if(ObjectFind(0,name)<0) { ObjectCreate(0,name,OBJ_TEXT,0,time,price); ObjectSetString(0,name,OBJPROP_TEXT,text); ObjectSetInteger(0,name,OBJPROP_BACK,true); ObjectSetString(0,name,OBJPROP_FONT,"Verdana"); ObjectSetInteger(0,name,OBJPROP_FONTSIZE,size); ObjectSetInteger(0,name,OBJPROP_ANCHOR,ANCHOR_); ObjectSetInteger(0,name,OBJPROP_COLOR,clr); ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false); ObjectSetInteger(0,name,OBJPROP_SELECTED,false); ObjectSetInteger(0,name,OBJPROP_HIDDEN,true); } else { ObjectMove(0,name,0,time,price); ObjectSetInteger(0,name,OBJPROP_COLOR,clr); ObjectSetString(0,name,OBJPROP_TEXT,text); ObjectSetInteger(0,name,OBJPROP_FONTSIZE,size); } } //--- void Draw_TrandLine_or_Box(int sub_window,string name,ENUM_OBJECT OBJ_,datetime t1,double p1,datetime t2,double p2,color clr,int scale,int STYLE,bool BACK=false) { name=LabelID+name; if(ObjectFind(0,name)<0) { ObjectCreate(0,name,OBJ_,sub_window,t1,p1,t2,p2); ObjectSetInteger(0,name,OBJPROP_WIDTH,0); ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false); ObjectSetInteger(0,name,OBJPROP_SELECTED,false); ObjectSetInteger(0,name,OBJPROP_HIDDEN,true); ObjectSetInteger(0,name,OBJPROP_BACK,back); ObjectSetInteger(0,name,OBJPROP_RAY,true); ObjectSetInteger(0,name,OBJPROP_COLOR,clr); ObjectSetInteger(0,name,OBJPROP_WIDTH,scale); ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE); } else { ObjectMove(0,name,0,t1,p1); ObjectMove(0,name,1,t2,p2); ObjectSetInteger(0,name,OBJPROP_COLOR,clr); ObjectSetInteger(0,name,OBJPROP_WIDTH,scale); ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE); ObjectSetInteger(0,name,OBJPROP_BACK,BACK); } } //+------------------------------------------------------------------+