I have this code and it works fine, but i would like to be able to moved the text up so it's i.e 10 pips from the top of the chart and the same time i would like to be able to center the text to the day period separators so it's always in the middle
How can i do that?
Here's the code i have
How can i do that?
Here's the code i have
Inserted Code
//+------------------------------------------------------------------+ //| Week_Days.mq4 | //+------------------------------------------------------------------+ #property indicator_chart_window input int Days=100;// Days Boxs //input bool OpenCloseBox=true;// Open Close Boxs input bool DrawBox = true; datetime T; string mql_name; int a,Bar; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- mql_name=MQLInfoString(MQL_PROGRAM_NAME); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- ObjectsDeleteAll(0,mql_name); //--- } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { //--- if(iTime(NULL,PERIOD_D1,0)!=T) { T=iTime(NULL,PERIOD_D1,0); DrawWeekDays(); } //--- return(rates_total); } //+------------------------------------------------------------------+ void DrawWeekDays() { if(a==0){Bar=Days;}else{Bar=1;} for(int i=0;i<Bar;i++) { string tname=TimeToString(iTime(NULL,PERIOD_D1,i)); datetime t=iTime(NULL,PERIOD_D1,i); double high=iHigh(NULL,PERIOD_D1,i); double low=iLow(NULL,PERIOD_D1,i); double open=iOpen(NULL,PERIOD_D1,i); double close=iClose(NULL,PERIOD_D1,i); color clr=clrDimGray;string TXT=" Monday"; if(TimeDayOfWeek(iTime(NULL,PERIOD_D1,i))==2){clr=clrDimGray;TXT=" Tuesday";} if(TimeDayOfWeek(iTime(NULL,PERIOD_D1,i))==3){clr=clrDimGray;TXT=" Wednesday";} if(TimeDayOfWeek(iTime(NULL,PERIOD_D1,i))==4){clr=clrDimGray;TXT=" Thursday";} if(TimeDayOfWeek(iTime(NULL,PERIOD_D1,i))==5){clr=clrDimGray;TXT=" Friday";} DrawTXT(TXT+tname,TXT,t,high+10*Point,clr); } } //-------------------------------------------------------------------+ void DrawTXT(string name,string text,datetime time,double price,color clr,ENUM_ANCHOR_POINT ANCHOR_=ANCHOR_LEFT_LOWER,int size=16) { name = mql_name+name; 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,"Arial"); 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); } } //--------------------------------------------------------------------
Blindly following others will make you blind!