Being the observant guy that I am, it seems that the cycles may have shifted back 15min today
I will provide some updated code, but this will be my last update. Rest assured, if you see changes like this you can always manually edit the indicator yourself if you would like.
//+------------------------------------------------------------------+
//| Husky_45min_reversals-2.mq4 |
//| This has been adapted from the Tim zones: by |
//| Brad Eckert's Time Zones added by Jacob Yego |
//| Creates lines every 45 minutes. |
//| The slots are based on FXDD +2GMT |
//+------------------------------------------------------------------+
#property indicator_chart_window
//------- 45 Minute Times -------------------------------
extern int NumberOfDays = 10; // ���������� ����
extern string Begin_1 = "02:00";
extern string End_1 = "02:00";
extern color Color_1 = Red;
extern string Begin_2 = "02:45";
extern string End_2 = "02:45";
extern color Color_2 = Green;
extern string Begin_3 = "03:30";
extern string End_3 = "03:30";
extern color Color_3 = Red;
extern string Begin_4 = "04:15";
extern string End_4 = "04:15";
extern color Color_4 = Green;
extern string Begin_5 = "05:00";
extern string End_5 = "05:00";
extern color Color_5 = Red;
extern string Begin_6 = "05:45";
extern string End_6 = "05:45";
extern color Color_6 = Green;
extern string Begin_7 = "06:30";
extern string End_7 = "06:30";
extern color Color_7 = Red;
extern string Begin_8 = "07:15";
extern string End_8 = "07:15";
extern color Color_8 = Green;
extern string Begin_9 = "08:00";
extern string End_9 = "08:00";
extern color Color_9 = Red;
extern string Begin_10 = "08:45";
extern string End_10 = "08:45";
extern color Color_10 = Green;
extern string Begin_11 = "09:30";
extern string End_11 = "09:30";
extern color Color_11 = Red;
extern string Begin_12 = "10:15";
extern string End_12 = "10:15";
extern color Color_12 = Green;
extern string Begin_13 = "11:00";
extern string End_13 = "11:00";
extern color Color_13 = Red;
extern string Begin_14 = "11:45";
extern string End_14 = "11:45";
extern color Color_14 = Green;
extern string Begin_15 = "12:30";
extern string End_15 = "12:30";
extern color Color_15 = Red;
extern string Begin_16 = "13:15";
extern string End_16 = "13:15";
extern color Color_16 = Green;
extern string Begin_17 = "14:00";
extern string End_17 = "14:00";
extern color Color_17 = Red;
extern string Begin_18 = "14:45";
extern string End_18 = "14:45";
extern color Color_18 = Green;
extern string Begin_19 = "15:30";
extern string End_19 = "15:30";
extern color Color_19 = Red;
extern string Begin_20 = "16:15";
extern string End_20 = "16:15";
extern color Color_20 = Green;
extern string Begin_21 = "17:00";
extern string End_21 = "17:00";
extern color Color_21 = Red;
extern string Begin_22 = "17:45";
extern string End_22 = "17:45";
extern color Color_22 = Green;
extern string Begin_23 = "18:30";
extern string End_23 = "18:30";
extern color Color_23 = Red;
extern string Begin_24 = "19:15";
extern string End_24 = "19:15";
extern color Color_24 = Green;
extern string Begin_25 = "20:00";
extern string End_25 = "20:00";
extern color Color_25 = Red;
extern string Begin_26 = "20:45";
extern string End_26 = "20:45";
extern color Color_26 = Green;
extern string Begin_27 = "21:30";
extern string End_27 = "21:30";
extern color Color_27 = Red;
extern string Begin_28 = "22:15";
extern string End_28 = "22:15";
extern color Color_28 = Green;
extern string Begin_29 = "23:00";
extern string End_29 = "23:00";
extern color Color_29 = Red;
extern string Begin_30 = "23:45";
extern string End_30 = "23:45";
extern color Color_30 = Green;
extern string Begin_31 = "00:30";
extern string End_31 = "00:30";
extern color Color_31 = Red;
extern string Begin_32 = "01:15";
extern string End_32 = "01:15";
extern color Color_32 = Green;
extern bool HighRange = True;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init() {
DeleteObjects();
for (int i=0; i<NumberOfDays; i++) {
CreateObjects("PWT1"+i, Color_1);
CreateObjects("PWT2"+i, Color_2);
CreateObjects("PWT3"+i, Color_3);
CreateObjects("PWT4"+i, Color_4);
CreateObjects("PWT5"+i, Color_5);
CreateObjects("PWT6"+i, Color_6);
CreateObjects("PWT7"+i, Color_1);
CreateObjects("PWT8"+i, Color_2);
CreateObjects("PWT9"+i, Color_3);
CreateObjects("PWT10"+i, Color_4);
CreateObjects("PWT11"+i, Color_5);
CreateObjects("PWT12"+i, Color_6);
CreateObjects("PWT13"+i, Color_1);
CreateObjects("PWT14"+i, Color_2);
CreateObjects("PWT15"+i, Color_3);
CreateObjects("PWT16"+i, Color_4);
CreateObjects("PWT17"+i, Color_5);
CreateObjects("PWT18"+i, Color_6);
CreateObjects("PWT19"+i, Color_1);
CreateObjects("PWT20"+i, Color_2);
CreateObjects("PWT21"+i, Color_3);
CreateObjects("PWT22"+i, Color_4);
CreateObjects("PWT23"+i, Color_5);
CreateObjects("PWT24"+i, Color_6);
CreateObjects("PWT25"+i, Color_3);
CreateObjects("PWT26"+i, Color_4);
CreateObjects("PWT27"+i, Color_5);
CreateObjects("PWT28"+i, Color_6);
CreateObjects("PWT29"+i, Color_1);
CreateObjects("PWT30"+i, Color_2);
CreateObjects("PWT31"+i, Color_3);
CreateObjects("PWT32"+i, Color_4);
}
Comment("");
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
void deinit() {
DeleteObjects();
Comment("");
}
//+------------------------------------------------------------------+
void CreateObjects(string no, color cl) {
ObjectCreate(no, OBJ_VLINE, 0, 0,0, 0,0);
ObjectSet(no, OBJPROP_STYLE, STYLE_SOLID);
ObjectSet(no, OBJPROP_COLOR, cl);
ObjectSet(no, OBJPROP_BACK, True);
}
//+------------------------------------------------------------------+
void DeleteObjects() {
for (int i=0; i<NumberOfDays; i++) {
ObjectDelete("PWT1"+i);
ObjectDelete("PWT2"+i);
ObjectDelete("PWT3"+i);
ObjectDelete("PWT4"+i);
ObjectDelete("PWT5"+i);
ObjectDelete("PWT6"+i);
ObjectDelete("PWT7"+i);
ObjectDelete("PWT8"+i);
ObjectDelete("PWT9"+i);
ObjectDelete("PWT10"+i);
ObjectDelete("PWT11"+i);
ObjectDelete("PWT12"+i);
ObjectDelete("PWT13"+i);
ObjectDelete("PWT14"+i);
ObjectDelete("PWT15"+i);
ObjectDelete("PWT16"+i);
ObjectDelete("PWT17"+i);
ObjectDelete("PWT18"+i);
ObjectDelete("PWT19"+i);
ObjectDelete("PWT20"+i);
ObjectDelete("PWT21"+i);
ObjectDelete("PWT22"+i);
ObjectDelete("PWT23"+i);
ObjectDelete("PWT24"+i);
ObjectDelete("PWT25"+i);
ObjectDelete("PWT26"+i);
ObjectDelete("PWT27"+i);
ObjectDelete("PWT28"+i);
ObjectDelete("PWT29"+i);
ObjectDelete("PWT30"+i);
ObjectDelete("PWT31"+i);
ObjectDelete("PWT32"+i);
}
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
void start() {
datetime dt=CurTime();
for (int i=0; i<NumberOfDays; i++) {
DrawObjects(dt, "PWT1"+i, Begin_1, End_1);
DrawObjects(dt, "PWT2"+i, Begin_2, End_2);
DrawObjects(dt, "PWT3"+i, Begin_3, End_3);
DrawObjects(dt, "PWT4"+i, Begin_4, End_4);
DrawObjects(dt, "PWT5"+i, Begin_5, End_5);
DrawObjects(dt, "PWT6"+i, Begin_6, End_6);
DrawObjects(dt, "PWT7"+i, Begin_7, End_7);
DrawObjects(dt, "PWT8"+i, Begin_8, End_8);
DrawObjects(dt, "PWT9"+i, Begin_9, End_9);
DrawObjects(dt, "PWT10"+i, Begin_10, End_10);
DrawObjects(dt, "PWT11"+i, Begin_11, End_11);
DrawObjects(dt, "PWT12"+i, Begin_12, End_12);
DrawObjects(dt, "PWT13"+i, Begin_13, End_13);
DrawObjects(dt, "PWT14"+i, Begin_14, End_14);
DrawObjects(dt, "PWT15"+i, Begin_15, End_15);
DrawObjects(dt, "PWT16"+i, Begin_16, End_16);
DrawObjects(dt, "PWT17"+i, Begin_17, End_17);
DrawObjects(dt, "PWT18"+i, Begin_18, End_18);
DrawObjects(dt, "PWT19"+i, Begin_19, End_19);
DrawObjects(dt, "PWT20"+i, Begin_20, End_20);
DrawObjects(dt, "PWT21"+i, Begin_21, End_21);
DrawObjects(dt, "PWT22"+i, Begin_22, End_22);
DrawObjects(dt, "PWT23"+i, Begin_23, End_23);
DrawObjects(dt, "PWT24"+i, Begin_24, End_24);
DrawObjects(dt, "PWT25"+i, Begin_25, End_25);
DrawObjects(dt, "PWT26"+i, Begin_26, End_26);
DrawObjects(dt, "PWT27"+i, Begin_27, End_27);
DrawObjects(dt, "PWT28"+i, Begin_28, End_28);
DrawObjects(dt, "PWT29"+i, Begin_29, End_29);
DrawObjects(dt, "PWT30"+i, Begin_30, End_30);
DrawObjects(dt, "PWT31"+i, Begin_31, End_31);
DrawObjects(dt, "PWT32"+i, Begin_32, End_32);
dt=decDateTradeDay(dt);
while (TimeDayOfWeek(dt)>5) dt=decDateTradeDay(dt);
}
}
//+------------------------------------------------------------------+
void DrawObjects(datetime dt, string no, string tb, string te) {
datetime t1, t2;
double p1, p2;
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=High[Highest(NULL, 0, MODE_HIGH, b1-b2, b2)];
p2=Low [Lowest (NULL, 0, MODE_LOW , b1-b2, b2)];
if (!HighRange) {p1=0; p2=2*p2;}
ObjectSet(no, OBJPROP_TIME1 , t1);
ObjectSet(no, OBJPROP_PRICE1, p1);
ObjectSet(no, OBJPROP_TIME2 , t2);
ObjectSet(no, OBJPROP_PRICE2, p2);
}
//+------------------------------------------------------------------+
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));
}
//+------------------------------------------------------------------+