//+------------------------------------------------------------------+ //| MondayH4Box.mq4 | //| Modified from WeeklyPivot.mq4 | //+------------------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 Red #property indicator_color2 Green #property indicator_color3 Crimson #property indicator_color4 Green #property indicator_color5 Crimson #property indicator_color6 Green #property indicator_color7 Crimson #property indicator_color8 Green //---- input parameters //---- buffers double Lo5Buffer[]; double Hi5Buffer[]; double Lo6Buffer[]; double Hi6Buffer[]; double Lo7Buffer[]; double Hi7Buffer[]; double Lo8Buffer[]; double Hi8Buffer[]; double Lo5,Hi5,Lo6,Hi6,Lo7,Hi7,Lo8,Hi8; double H4Low, H4High; double x; //string Lo1="Lo1",Hi1="Hi1", Lo2="Lo2"; //string Hi2="Hi2", Lo3="Lo3", Hi4="Hi4", Lo4="Lo4"; //string H4Low="H4Low",H4High="H4High"; int fontsize=8; int nDigits; //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- TODO: add your code here ObjectDelete("Hi5"); ObjectDelete("Lo5"); ObjectDelete("Hi6"); ObjectDelete("Lo6"); ObjectDelete("Hi7"); ObjectDelete("Lo7"); ObjectDelete("Hi8"); ObjectDelete("Lo8"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { string short_name; //---- indicator line SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,160); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,160); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,160); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,160); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,160); SetIndexStyle(5,DRAW_ARROW); SetIndexArrow(5,160); SetIndexStyle(6,DRAW_ARROW); SetIndexArrow(6,160); SetIndexStyle(7,DRAW_ARROW); SetIndexArrow(7,160); SetIndexBuffer(0,Lo5Buffer); SetIndexBuffer(1,Hi5Buffer); SetIndexBuffer(2,Lo6Buffer); SetIndexBuffer(3,Hi6Buffer); SetIndexBuffer(4,Lo7Buffer); SetIndexBuffer(5,Hi7Buffer); SetIndexBuffer(6,Lo8Buffer); SetIndexBuffer(7,Hi8Buffer); SetIndexLabel(0,NULL); SetIndexLabel(1,NULL); SetIndexLabel(2,NULL); SetIndexLabel(3,NULL); SetIndexLabel(4,NULL); SetIndexLabel(5,NULL); SetIndexLabel(6,NULL); SetIndexLabel(7,NULL); //---- name for DataWindow and indicator subwindow label short_name="1 Box 4 30"; IndicatorShortName(short_name); SetIndexLabel(0,short_name); //---- SetIndexDrawBegin(0,1); //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int limit, i; //---- indicator calculation if(counted_bars<0) return(-1); limit=(Bars-counted_bars)-1; { x=Period(); if (x>240) return(-1); if (i==0) { Print(i); ObjectCreate("Hi5", OBJ_TEXT, 0, 100, 0); ObjectSetText("Hi5", " Long " +DoubleToStr(Hi5,4),fontsize,"Arial bold ",Green); SetIndexLabel(0, "Hi5"); ObjectCreate("Lo5", OBJ_TEXT, 0, 100, 0); ObjectSetText("Lo5", " Short " +DoubleToStr(Lo5,4),fontsize,"Arial bold ",Red); SetIndexLabel(1, "Lo5"); ObjectCreate("Hi6", OBJ_TEXT, 0, 100, 0); ObjectSetText("Hi6", " TP4 " +DoubleToStr(Hi6,4),fontsize,"Arial bold ",Green); SetIndexLabel(2, "Hi6"); ObjectCreate("Lo6", OBJ_TEXT, 0, 100, 0); ObjectSetText("Lo6", " TP4 " +DoubleToStr(Lo6,4),fontsize,"Arial bold ",Red); SetIndexLabel(3, "Lo6"); ObjectCreate("Hi7", OBJ_TEXT, 0, 100, 0); ObjectSetText("Hi7", " TP5 " +DoubleToStr(Hi7,4),fontsize,"Arial bold ",Green); SetIndexLabel(4, "Hi7"); ObjectCreate("Lo7", OBJ_TEXT, 0, 100, 0); ObjectSetText("Lo7", " TP5 " +DoubleToStr(Lo7,4),fontsize,"Arial bold ",Red); SetIndexLabel(5, "Lo7"); ObjectCreate("Hi8", OBJ_TEXT, 0, 100, 0); ObjectSetText("Hi8", " TP6 " +DoubleToStr(Hi8,4),fontsize,"Arial bold ",Green); SetIndexLabel(6, "Hi8"); ObjectCreate("Lo8", OBJ_TEXT, 0, 100, 0); ObjectSetText("Lo8", " TP6 " +DoubleToStr(Lo8,4),fontsize,"Arial bold ",Red); SetIndexLabel(6, "Lo8"); Print("ObjectSet Done"); ObjectMove("Hi8", 0, 100,Hi8); ObjectMove("Hi7", 0, 100,Hi7); ObjectMove("Hi6", 0, 100,Hi6); ObjectMove("Hi5", 0, 100,Hi5); ObjectMove("Lo5", 0, 100,Lo5); ObjectMove("Lo6", 0, 100,Lo6); ObjectMove("Lo7", 0, 100,Lo7); ObjectMove("Lo8", 0, 100,Lo8); Print("ObjectMove Done"); ObjectsRedraw(); Print("ObjectsRedraw Done"); } } if(counted_bars<0) return(-1); for (i=limit; i>=0;i--) { // Monday if ( 1 == TimeDayOfWeek(Time[i]) && 1 != TimeDayOfWeek(Time[i+1]) ) { H4High = iHigh(0,PERIOD_H4,i); H4Low = iLow(0,PERIOD_H4,i); } Hi5 = H4High + 0.30; Lo5 = H4Low - 0.30; Hi6 = H4High + 4*(H4High-H4Low); Lo6 = H4Low - 4*(H4High-H4Low); Hi7 = H4High + 5*(H4High-H4Low); Lo7 = H4Low - 5*(H4High-H4Low); Hi8 = H4High + 6*(H4High-H4Low); Lo8 = H4Low - 6*(H4High-H4Low); Lo5Buffer[i]=Lo5; Hi5Buffer[i]=Hi5; Lo6Buffer[i]=Lo6; Hi6Buffer[i]=Hi6; Lo7Buffer[i]=Lo7; Hi7Buffer[i]=Hi7; Lo8Buffer[i]=Lo8; Hi8Buffer[i]=Hi8; ObjectMove("Hi5", 0, Time[i],Hi5); ObjectMove("Lo5", 0, Time[i],Lo5); ObjectMove("Hi6", 0, Time[i],Hi6); ObjectMove("Lo6", 0, Time[i],Lo6); ObjectMove("Hi7", 0, Time[i],Hi7); ObjectMove("Lo7", 0, Time[i],Lo7); ObjectMove("Hi8", 0, Time[i],Hi8); ObjectMove("Lo8", 0, Time[i],Lo8); } //---- return(0); } //+------------------------------------------------------------------+