//+------------------------------------------------------------------+ //| Weekly CAMARRILLA.mq4 | //| Copyright © 2010, Кущенко Никита | //| www.tradestrateg.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2010, Кущенко Никита" #property link "www.tradestrateg.ru" #property indicator_chart_window #property indicator_buffers 6 #property indicator_color1 Silver #property indicator_color2 Silver #property indicator_color3 Red #property indicator_color4 Lime #property indicator_color5 BlueViolet #property indicator_color6 BlueViolet //---- buffers double P1Buffer[]; double P2Buffer[]; double P3Buffer[]; double P4Buffer[]; double P5Buffer[]; double P6Buffer[]; //---- int myPeriod = PERIOD_W1; //---- double H1, L1, H2, L2, H4, L4, Q; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexBuffer(0, P1Buffer); SetIndexBuffer(1, P2Buffer); SetIndexBuffer(2, P3Buffer); SetIndexBuffer(3, P4Buffer); SetIndexBuffer(4, P5Buffer); SetIndexBuffer(5, P6Buffer); //---- SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 0); SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 0); SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 4); SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 4); SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 4); SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 4); //---- Comment("Weekly CAMARRILLA"); return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { ObjectDelete("WeekH1"); ObjectDelete("WeekH2"); ObjectDelete("WeekH4"); ObjectDelete("WeekL1"); ObjectDelete("WeekL2"); ObjectDelete("WeekL4"); ObjectDelete("txtWeekH1"); ObjectDelete("txtWeekH2"); ObjectDelete("txtWeekH4"); ObjectDelete("txtWeekL1"); ObjectDelete("txtWeekL2"); ObjectDelete("txtWeekL4"); Comment(""); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int i, dayi, counted_bars = IndicatorCounted(); //---- check for possible errors if(counted_bars < 0) return(-1); //---- last counted bar will be recounted if(counted_bars > 0) counted_bars--; int limit = Bars - counted_bars; //---- for(i = limit - 1; i >= 0; i--) { dayi = iBarShift(Symbol(), myPeriod, Time[i], false); Q = (iHigh(Symbol(), myPeriod,dayi+1) - iLow(Symbol(), myPeriod, dayi + 1)); //---- H1 = iClose(Symbol(), myPeriod,dayi+1) + (Q * 0.09); L1 = iClose(Symbol(), myPeriod,dayi+1) - (Q * 0.09); //---- H2 = iClose(Symbol(), myPeriod,dayi+1) + (Q * 0.18); L2 = iClose(Symbol(), myPeriod,dayi+1) - (Q * 0.18); //---- H4 = iClose(Symbol(), myPeriod,dayi+1) + (Q * 0.55); L4 = iClose(Symbol(), myPeriod,dayi+1) - (Q * 0.55); //---- P1Buffer[i] = H1; SetPrice("WeekH1", Time[i], H1, Red); SetText("txtWeekH1", "H1", Time[i], H1, Red); //---- P2Buffer[i] = L1; SetPrice("WeekL1", Time[i], L1, Lime); SetText("txtWeekL1", "L1", Time[i], L1, Lime); //---- P3Buffer[i] = H2; SetPrice("WeekH2", Time[i], H2, Red); SetText("txtWeekH2", "H2", Time[i], H2, Red); //---- P4Buffer[i] = L2; SetPrice("WeekL2",Time[i],L2,Lime); SetText("txtWeekL2","L2",Time[i],L2,Lime); //---- P5Buffer[i] = H4; SetPrice("WeekH4", Time[i], H4, BlueViolet); SetText("txtWeekH4", "H4", Time[i], H4, BlueViolet); //---- P6Buffer[i] = L4; SetPrice("WeekL4", Time[i], L4, BlueViolet); SetText("txtWeekL4", "L4", Time[i], L4, BlueViolet); } //---- return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void SetPrice(string name, datetime Tm, double Prc, color clr) { if(ObjectFind(name) == -1) { ObjectCreate(name, OBJ_ARROW, 0, Tm, Prc); ObjectSet(name, OBJPROP_COLOR, clr); ObjectSet(name, OBJPROP_WIDTH, 2); ObjectSet(name, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); } else { ObjectSet(name, OBJPROP_TIME1, Tm); ObjectSet(name, OBJPROP_PRICE1, Prc); ObjectSet(name, OBJPROP_COLOR, clr); ObjectSet(name, OBJPROP_WIDTH, 2); ObjectSet(name, OBJPROP_ARROWCODE, SYMBOL_RIGHTPRICE); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void SetText(string name, string txt, datetime Tm, double Prc, color clr) { if(ObjectFind(name) == -1) { ObjectCreate(name, OBJ_TEXT, 0, Tm, Prc); ObjectSetText(name, txt, 9, "Times New Roman", clr); } else { ObjectSet(name, OBJPROP_TIME1, Tm); ObjectSet(name, OBJPROP_PRICE1, Prc); ObjectSetText(name, txt, 9, "Times New Roman", clr); } } //+------------------------------------------------------------------+