//+------------------------------------------------------------------+ //| Sessions.mq4 | //+------------------------------------------------------------------+ #property indicator_chart_window //+------------------------------------------------------------------+ int NumberOfDays = 99; string AsiaBegin = "00:00"; string AsiaEnd = "09:00"; color AsiaColor = clrGray; extern int ADR_N_days=10; extern string Pair_1 ="EURUSD"; extern string Pair_2 ="EURGBP"; extern string Pair_3 ="EURJPY"; extern string Pair_4 ="EURNZD"; extern string Pair_5 ="USDCHF"; extern string Pair_6 ="USDJPY"; extern string Pair_7 ="USDCAD"; extern string Pair_8 ="EURCAD"; extern string Pair_9 ="GBPUSD"; extern string Pair_10 ="GBPAUD"; extern string Pair_11 ="AUDUSD"; extern string Pair_12 ="AUDCAD"; extern int Corner = 0 ; extern int Move_X = 0; extern int Move_Y = 0; extern string B00001 = "===================="; extern int Button_Width = 100; extern int Hight_button = 1; extern int space_button = 3; extern string Font_Type = "Arial Bold"; extern int Font_Size = 7; extern color Font_Color = White; string asia_symbol_name= "ASIA"; bool ShowPrice = false; color clFont = Blue; int SizeFont = 8; int OffSet = 10; bool Background = true; int dig; double pnt, spr, tickval; string ccy; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void init() { ccy = Symbol(); pnt = MarketInfo(ccy,MODE_POINT); dig = MarketInfo(ccy,MODE_DIGITS); spr = MarketInfo(ccy,MODE_SPREAD); tickval = MarketInfo(ccy,MODE_TICKVALUE); if (dig == 3 || dig == 5) { pnt *= 10; spr /= 10; tickval *= 10; } Comment(""); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ void deinit() { ObjectsDeleteAll(); Comment(""); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ void start() { datetime dt=CurTime(); ObjectsDeleteAll(); for (int i=1; i5) dt=decDateTradeDay(dt); } objects_draw(Pair_1,20); objects_draw(Pair_2,40); objects_draw(Pair_3,60); objects_draw(Pair_4,80); objects_draw(Pair_5,100); objects_draw(Pair_6,120); objects_draw(Pair_7,140); objects_draw(Pair_8,160); objects_draw(Pair_9,180); objects_draw(Pair_10,200); objects_draw(Pair_11,220); objects_draw(Pair_12,240); } //+------------------------------------------------------------------+ void DrawObjects(datetime dt, string no, string tb, string te, color couleur, string text, int linestyle) { //+------------------------------------------------------------------+ datetime t1, t2; double p1; int b1, b2; t1=StrToTime(TimeToStr(dt, TIME_DATE)+" "+tb); t2=StrToTime(TimeToStr(dt, TIME_DATE)+" "+te); b1=iBarShift(NULL, 0, t1); b2=iBarShift(NULL, 0, t2); p1=Open[b1]; Trend_Line(t1,t2,High[iHighest(NULL,0,MODE_HIGH,b1-b2,b2)],Low[iLowest(NULL,0,MODE_LOW,b1-b2,b2)],couleur,text,linestyle); } //+------------------------------------------------------------------+ datetime decDateTradeDay (datetime dt) { //+------------------------------------------------------------------+ int ty=TimeYear(dt); int tm=TimeMonth(dt); int td=TimeDay(dt); int th=TimeHour(dt); int ti=TimeMinute(dt); td--; if (td==0) { tm--; if (tm==0) { ty--; tm=12; } if (tm==1 || tm==3 || tm==5 || tm==7 || tm==8 || tm==10 || tm==12) td=31; if (tm==2) if (MathMod(ty, 4)==0) td=29; else td=28; if (tm==4 || tm==6 || tm==9 || tm==11) td=30; } return(StrToTime(ty+"."+tm+"."+td+" "+th+":"+ti)); } void Trend_Line( datetime x1, datetime x2, double y1, double y2, color lineColor, string text, int Line_StyleV){ //~~~~~~~~~~ /* string label = "_Trend_Line_"+y1; ObjectDelete(label); ObjectCreate(label, OBJ_TREND, 0, x1, y1, x2, y2, 0, 0); ObjectSet(label, OBJPROP_RAY, 0); ObjectSet(label, OBJPROP_COLOR, lineColor); ObjectSet(label, OBJPROP_STYLE, Line_StyleV); string label_text = "_Trend_Text_"+y1; ObjectCreate(0,label_text,OBJ_TEXT,0,x1,y1); ObjectSetText(label_text,text,font_size,"Arial",EMPTY); ObjectSet(label_text,OBJPROP_COLOR,lineColor); */ ObjectCreate(0,"res1"+y1,OBJ_RECTANGLE,0,x1, y1, x2, y2 ); //couleur(high_1); ObjectSetInteger(0, "res1"+y1, OBJPROP_COLOR, AsiaColor); } void Line(double level,string text, color couleur, int Line_StyleV) { ObjectCreate(0,"res1"+text,OBJ_HLINE,0,0,level); ObjectSetInteger(0, "res1"+text, OBJPROP_COLOR, couleur); ObjectSetInteger(0, "res1"+text, OBJPROP_STYLE, Line_StyleV); ObjectCreate(0,"Label"+text,OBJ_TEXT,0,Time[0],level); ObjectSetText("Label"+text,text,9,"Arial",EMPTY); ObjectSet("Label"+text,OBJPROP_COLOR,couleur); } bool ButtonCreate (const long chart_ID=0, const string name="Button", const int sub_window=0, const int x=0, const int y=0, const int width=500, const int height=18, int corner=0, const string text="Button", const string font="Arial Bold", const int font_size=10, const color clr=clrBlack, const color back_clr=C'170,170,170', const color border_clr=clrNONE, const bool state=false, const bool back=false, const bool selection=false, const bool hidden=true, const long z_order=0) { ResetLastError(); if (!ObjectCreate (chart_ID,name, OBJ_BUTTON, sub_window, 0, 0)) { Print (__FUNCTION__, ": failed to create the button! Error code = "+name, GetLastError()); return(false); } ObjectSetInteger (chart_ID, name, OBJPROP_XDISTANCE, x); ObjectSetInteger (chart_ID, name, OBJPROP_YDISTANCE, y); ObjectSetInteger (chart_ID, name, OBJPROP_XSIZE, width); ObjectSetInteger (chart_ID, name, OBJPROP_YSIZE, height); ObjectSetInteger (chart_ID, name, OBJPROP_CORNER, corner); ObjectSetInteger (chart_ID, name, OBJPROP_FONTSIZE, font_size); ObjectSetInteger (chart_ID, name, OBJPROP_COLOR, clr); ObjectSetInteger (chart_ID, name, OBJPROP_BGCOLOR, back_clr); ObjectSetInteger (chart_ID, name, OBJPROP_BORDER_COLOR, border_clr); ObjectSetInteger (chart_ID, name, OBJPROP_BACK, back); ObjectSetInteger (chart_ID, name, OBJPROP_STATE, state); ObjectSetInteger (chart_ID, name, OBJPROP_SELECTABLE, selection); ObjectSetInteger (chart_ID, name, OBJPROP_SELECTED, selection); ObjectSetInteger (chart_ID, name, OBJPROP_HIDDEN, hidden); ObjectSetInteger (chart_ID, name, OBJPROP_ZORDER,z_order); ObjectSetString (chart_ID, name, OBJPROP_TEXT, text); ObjectSetString (chart_ID, name, OBJPROP_FONT, font); return(true); } void objects_draw(string sym,int y_axe ) { int Button_Height = Font_Size*2.8+Hight_button; double adr= 0; for(int a=0; a