//+------------------------------------------------------------------+ //| Pivot Lines TimeZone.mq5 | //| Copyright 2012, Integer | //| https://login.mql5.com/ru/users/Integer | //+------------------------------------------------------------------+ #property copyright "Integer" #property link "https://login.mql5.com/ru/users/Integer" #property description "" #property version "1.00" #property description "Expert rewritten from MQL4, the author: Alejandro Galindo, published on mql4.com by Scriptor (http://www.mql4.com/ru/users/Scriptor), link - http://codebase.mql4.com/ru/1395" #property indicator_chart_window #property indicator_buffers 19 #property indicator_plots 17 //--- plot Pivot #property indicator_label1 "Pivot" #property indicator_type1 DRAW_LINE #property indicator_color1 clrDarkOrange #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot S1 #property indicator_label2 "S1" #property indicator_type2 DRAW_LINE #property indicator_color2 clrRed #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- plot R1 #property indicator_label3 "R1" #property indicator_type3 DRAW_LINE #property indicator_color3 clrDeepSkyBlue #property indicator_style3 STYLE_SOLID #property indicator_width3 1 //--- plot S2 #property indicator_label4 "S2" #property indicator_type4 DRAW_LINE #property indicator_color4 clrRed #property indicator_style4 STYLE_SOLID #property indicator_width4 1 //--- plot R2 #property indicator_label5 "R2" #property indicator_type5 DRAW_LINE #property indicator_color5 clrDeepSkyBlue #property indicator_style5 STYLE_SOLID #property indicator_width5 1 //--- plot S3 #property indicator_label6 "S3" #property indicator_type6 DRAW_LINE #property indicator_color6 clrRed #property indicator_style6 STYLE_SOLID #property indicator_width6 1 //--- plot R3 #property indicator_label7 "R3" #property indicator_type7 DRAW_LINE #property indicator_color7 clrDeepSkyBlue #property indicator_style7 STYLE_SOLID #property indicator_width7 1 //--- plot M0 #property indicator_label8 "M0" #property indicator_type8 DRAW_LINE #property indicator_color8 clrBlue #property indicator_style8 STYLE_SOLID #property indicator_width8 1 //--- plot M1 #property indicator_label9 "M1" #property indicator_type9 DRAW_LINE #property indicator_color9 clrBlue #property indicator_style9 STYLE_SOLID #property indicator_width9 1 //--- plot M2 #property indicator_label10 "M2" #property indicator_type10 DRAW_LINE #property indicator_color10 clrBlue #property indicator_style10 STYLE_SOLID #property indicator_width10 1 //--- plot M3 #property indicator_label11 "M3" #property indicator_type11 DRAW_LINE #property indicator_color11 clrBlue #property indicator_style11 STYLE_SOLID #property indicator_width11 1 //--- plot M4 #property indicator_label12 "M4" #property indicator_type12 DRAW_LINE #property indicator_color12 clrBlue #property indicator_style12 STYLE_SOLID #property indicator_width12 1 //--- plot M5 #property indicator_label13 "M5" #property indicator_type13 DRAW_LINE #property indicator_color13 clrBlue #property indicator_style13 STYLE_SOLID #property indicator_width13 1 //--- plot L3 #property indicator_label14 "L3" #property indicator_type14 DRAW_LINE #property indicator_color14 clrYellow #property indicator_style14 STYLE_SOLID #property indicator_width14 1 //--- plot H3 #property indicator_label15 "H3" #property indicator_type15 DRAW_LINE #property indicator_color15 clrYellow #property indicator_style15 STYLE_SOLID #property indicator_width15 1 //--- plot L4 #property indicator_label16 "L4" #property indicator_type16 DRAW_LINE #property indicator_color16 clrYellow #property indicator_style16 STYLE_SOLID #property indicator_width16 1 //--- plot H4 #property indicator_label17 "H4" #property indicator_type17 DRAW_LINE #property indicator_color17 clrYellow #property indicator_style17 STYLE_SOLID #property indicator_width17 1 //--- input parameters input int DayStartHour = 0; /*DayStartHour*/ // Hour of day start input int DayStartMinute = 0; /*DayStartMinute*/ // Minute of day start input bool PivotsBufers = false; /*PivotsBufers*/ // Show the Pivot levels as the indicator bufers input bool MidpivotsBuffers = false; /*MidpivotsBuffers*/ // Show the intermediate Pivot levels as the indicator bufers input bool CamarillaBuffers = false; /*CamarillaBuffers*/ // Show the Camarilla levels as the indicator bufers input bool PivotsLines = true; /*PivotsLines*/ // Show the current lines of Pivot as the horizontal lines input bool MidpivotsLines = false; /*MidpivotsLines*/ // Show the current intermediate lines of Pivot as the horizontal lines input bool CamarillaLines = false; /*CamarillaLines*/ // Show the current lines of Camarilla as the horizontal lines input color ClrPivot = clrOrange; /*ClrPivot*/ // Color of the horizontal Pivot line input color ClrS = clrRed; /*ClrS*/ // Color of the horizontal lines - S1, S2, S3 input color ClrR = clrDeepSkyBlue; /*ClrR*/ // Color of the horizontal lines - R1, R2, R3 input color ClrM = clrBlue; /*ClrM*/ // Color of the horizontal lines - M0, M1, M2, M3, M4, M5 input color ClrCamarilla = clrYellow; /*ClrCamarilla*/ // Color of the horizontal lines - Camarilla input color ClrTxt = clrWhite; /*ClrTxt*/ // Color of labels with names of horizontal lines input bool AttachSundToMond = true; /*AttachSundToMond*/ // Attach the sunday bars to monday //--- indicator buffers double PivotBuffer[]; double S1Buffer[]; double R1Buffer[]; double S2Buffer[]; double R2Buffer[]; double S3Buffer[]; double R3Buffer[]; double M0Buffer[]; double M1Buffer[]; double M2Buffer[]; double M3Buffer[]; double M4Buffer[]; double M5Buffer[]; double H3Buffer[]; double L3Buffer[]; double H4Buffer[]; double L4Buffer[]; double BufHigh[]; double BufLow[]; datetime TimeShift; double P; double R1; double S1; double R2; double S2; double R3; double S3; double Q; double H4; double H3; double L3; double L4; double M5; double M4; double M3; double M2; double M1; double M0; bool Redr; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { if(PivotsLines) { fObjHLine("Pivot",0,"Pivot",0,ClrPivot,1,STYLE_DOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("S1",0,"S1",0,ClrS,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("R1",0,"R1",0,ClrR,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("S2",0,"S2",0,ClrS,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("R2",0,"R2",0,ClrR,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("S3",0,"S3",0,ClrS,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("R3",0,"R3",0,ClrR,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjText("TxtPivot",0,0,"P",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtS1",0,0,"S1",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtR1",0,0,"R1",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtS2",0,0,"S2",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtR2",0,0,"R2",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtS3",0,0,"S3",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtR3",0,0,"R3",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); } if(MidpivotsLines) { fObjHLine("M0",0,"M0",0,ClrM,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("M1",0,"M1",0,ClrM,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("M2",0,"M2",0,ClrM,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("M3",0,"M3",0,ClrM,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("M4",0,"M4",0,ClrM,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("M5",0,"M5",0,ClrM,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjText("TxtM0",0,0,"M0",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtM1",0,0,"M1",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtM2",0,0,"M2",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtM3",0,0,"M3",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtM4",0,0,"M4",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtM5",0,0,"M5",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); } if(CamarillaLines) { fObjHLine("L3",0,"L3",0,ClrCamarilla,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("H3",0,"H3",0,ClrCamarilla,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("L4",0,"L4",0,ClrCamarilla,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjHLine("H4",0,"H4",0,ClrCamarilla,1,STYLE_DASHDOTDOT,0,true,false,false,OBJ_ALL_PERIODS); fObjText("TxtL3",0,0,"L3",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtH3",0,0,"H3",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtL4",0,0,"L4",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); fObjText("TxtH4",0,0,"H4",0,ANCHOR_LEFT_UPPER,ClrTxt,8,"Arial",0,false,0,false,false,OBJ_ALL_PERIODS); } Redr=(PivotsLines || MidpivotsLines || CamarillaLines); TimeShift=DayStartHour*3600+DayStartMinute*60; //--- indicator buffers mapping SetIndexBuffer(0,PivotBuffer,INDICATOR_DATA); SetIndexBuffer(1,S1Buffer,INDICATOR_DATA); SetIndexBuffer(2,R1Buffer,INDICATOR_DATA); SetIndexBuffer(3,S2Buffer,INDICATOR_DATA); SetIndexBuffer(4,R2Buffer,INDICATOR_DATA); SetIndexBuffer(5,S3Buffer,INDICATOR_DATA); SetIndexBuffer(6,R3Buffer,INDICATOR_DATA); SetIndexBuffer(7,M0Buffer,INDICATOR_DATA); SetIndexBuffer(8,M1Buffer,INDICATOR_DATA); SetIndexBuffer(9,M2Buffer,INDICATOR_DATA); SetIndexBuffer(10,M3Buffer,INDICATOR_DATA); SetIndexBuffer(11,M4Buffer,INDICATOR_DATA); SetIndexBuffer(12,M5Buffer,INDICATOR_DATA); SetIndexBuffer(13,L3Buffer,INDICATOR_DATA); SetIndexBuffer(14,H3Buffer,INDICATOR_DATA); SetIndexBuffer(15,L4Buffer,INDICATOR_DATA); SetIndexBuffer(16,H4Buffer,INDICATOR_DATA); SetIndexBuffer(17,BufHigh,INDICATOR_CALCULATIONS); SetIndexBuffer(18,BufLow,INDICATOR_CALCULATIONS); //--- return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnDeinit(const int Rason) { if(PivotsLines) { ObjectDelete(0,"Pivot"); ObjectDelete(0,"S1"); ObjectDelete(0,"R1"); ObjectDelete(0,"S2"); ObjectDelete(0,"R2"); ObjectDelete(0,"S3"); ObjectDelete(0,"R3"); ObjectDelete(0,"TxtPivot"); ObjectDelete(0,"TxtS1"); ObjectDelete(0,"TxtR1"); ObjectDelete(0,"TxtS2"); ObjectDelete(0,"TxtR2"); ObjectDelete(0,"TxtS3"); ObjectDelete(0,"TxtR3"); } if(MidpivotsLines) { ObjectDelete(0,"M0"); ObjectDelete(0,"M1"); ObjectDelete(0,"M2"); ObjectDelete(0,"M3"); ObjectDelete(0,"M4"); ObjectDelete(0,"M5"); ObjectDelete(0,"TxtM0"); ObjectDelete(0,"TxtM1"); ObjectDelete(0,"TxtM2"); ObjectDelete(0,"TxtM3"); ObjectDelete(0,"TxtM4"); ObjectDelete(0,"TxtM5"); } if(CamarillaLines) { ObjectDelete(0,"L3"); ObjectDelete(0,"H3"); ObjectDelete(0,"L4"); ObjectDelete(0,"H4"); ObjectDelete(0,"TxtL3"); ObjectDelete(0,"TxtH3"); ObjectDelete(0,"TxtL4"); ObjectDelete(0,"TxtH4"); } if(Redr) ChartRedraw(); } //+------------------------------------------------------------------+ //| 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[] ) { static bool error=true; int start; if(prev_calculated==0) { error=true; } if(error) { start=1; error=false; } else { start=prev_calculated-1; } for(int i=start; i