//+------------------------------------------------------------------+ //| Waddah Attar Strong Level | //| Copyright © 2007, www.metaforex.net | //| Waddah Attar www.metaforex.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2007, www.metaforex.net" #property link "www.metaforex.net" //---- #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 Red #property indicator_color2 Green #property indicator_color3 Blue #property indicator_color4 Red #property indicator_color5 Green #property indicator_color6 Blue #property indicator_color7 Orange #property indicator_color8 Orange extern bool BackTest=false; extern bool DrawMonth=true; extern bool DrawWeek=true; extern bool DrawDay=true; extern bool DrawH4=false; //---- buffers double P1Buffer[]; double P2Buffer[]; double P3Buffer[]; double P4Buffer[]; double P5Buffer[]; double P6Buffer[]; double P7Buffer[]; double P8Buffer[]; //---- int levelPeriod1 = PERIOD_D1; int levelPeriod2 = PERIOD_H4; int levelPeriod3 = PERIOD_W1; int levelPeriod4 = PERIOD_MN1; bool FixSunday; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { SetIndexBuffer(0, P1Buffer); SetIndexBuffer(1, P2Buffer); SetIndexBuffer(2, P3Buffer); SetIndexBuffer(3, P4Buffer); SetIndexBuffer(4, P5Buffer); SetIndexBuffer(5, P6Buffer); SetIndexBuffer(6, P7Buffer); SetIndexBuffer(7, P8Buffer); //---- SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2); SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1); SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 3); SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 2); SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 1); SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 3); SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 4); SetIndexStyle(7, DRAW_LINE, STYLE_SOLID, 4); //---- Comment("Strong Level By eng.Waddah Attar www.metaforex.net"); FixSunday=false; for(int i = 0; i <7; i++) { if (TimeDayOfWeek(iTime(Symbol(),PERIOD_D1,i))==0) { FixSunday=true; } } return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { ObjectDelete("level1"); ObjectDelete("txtlevel1"); ObjectDelete("level2"); ObjectDelete("txtlevel2"); ObjectDelete("level3"); ObjectDelete("txtlevel3"); ObjectDelete("level4"); ObjectDelete("txtlevel4"); ObjectDelete("level5"); ObjectDelete("txtlevel5"); ObjectDelete("level6"); ObjectDelete("txtlevel6"); ObjectDelete("level7"); ObjectDelete("txtlevel7"); ObjectDelete("level8"); ObjectDelete("txtlevel8"); //---- Comment(""); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { if(DrawDay) DrawPeriod1(); if(DrawH4) DrawPeriod2(); if(DrawWeek) DrawPeriod3(); if(DrawMonth) DrawPeriod4(); if (BackTest==false) { for(int i=1; i < Bars; i++) { P1Buffer[i]=P1Buffer[0]; P2Buffer[i]=P2Buffer[0]; P3Buffer[i]=P3Buffer[0]; P4Buffer[i]=P4Buffer[0]; P5Buffer[i]=P5Buffer[0]; P6Buffer[i]=P6Buffer[0]; P7Buffer[i]=P7Buffer[0]; P8Buffer[i]=P8Buffer[0]; } } return(0); } int DrawPeriod1() { int i, ii, counted_bars = IndicatorCounted(); double c1, c2, dc; string TrendType; //---- 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--) { ii = iBarShift(Symbol(), levelPeriod1, Time[i],true); if (TimeDayOfWeek(Time[i])==1 && FixSunday==true) { ii=ii+1; } if(ii != -1) { c1 = iClose(Symbol(), levelPeriod1, ii + 1); c2 = iClose(Symbol(), levelPeriod1, ii + 2); //---- dc = c1 - c2; //---- if(dc == 0) { c2 = iClose(Symbol(), levelPeriod1, ii + 3); } //---- dc = c1 - c2; //---- if(dc == 0) { dc = c1; } //---- P1Buffer[i] = c1-dc; P4Buffer[i] = c1+dc; if (P1Buffer[i] 0) counted_bars--; int limit = Bars - counted_bars; //---- for(i = limit - 1; i >= 0; i--) { ii = iBarShift(Symbol(), levelPeriod2, Time[i],true); if(ii != -1) { c1 = iClose(Symbol(), levelPeriod2, ii + 1); c2 = iClose(Symbol(), levelPeriod2, ii + 2); //---- dc = c1 - c2; //---- if(dc == 0) { c2 = iClose(Symbol(), levelPeriod2, ii + 3); } //---- dc = c1 - c2; //---- if(dc == 0) { dc = c1; } //---- P2Buffer[i] = c1-dc; P5Buffer[i] = c1+dc; if (P2Buffer[i] 0) counted_bars--; int limit = Bars - counted_bars; //---- for(i = limit - 1; i >= 0; i--) { ii = iBarShift(Symbol(), levelPeriod3, Time[i],true); if(ii != -1) { c1 = iClose(Symbol(), levelPeriod3, ii + 1); c2 = iClose(Symbol(), levelPeriod3, ii + 2); //---- dc = c1 - c2; //---- if(dc == 0) { c2 = iClose(Symbol(), levelPeriod3, ii + 3); } //---- dc = c1 - c2; //---- if(dc == 0) { dc = c1; } //---- P3Buffer[i] = c1-dc; P6Buffer[i] = c1+dc; if (P3Buffer[i] 0) counted_bars--; int limit = Bars - counted_bars; //---- for(i = limit - 1; i >= 0; i--) { ii = iBarShift(Symbol(), levelPeriod4, Time[i],true); if(ii != -1) { c1 = iClose(Symbol(), levelPeriod4, ii + 1); c2 = iClose(Symbol(), levelPeriod4, ii + 2); //---- dc = c1 - c2; //---- if(dc == 0) { c2 = iClose(Symbol(), levelPeriod4, ii + 3); } //---- dc = c1 - c2; //---- if(dc == 0) { dc = c1; } //---- P7Buffer[i] = c1-dc; P8Buffer[i] = c1+dc; if (P7Buffer[i]