#property copyright "" #property link "mail@webtemp.org" #property indicator_chart_window int MaxLines = 500; double L[500], S[500]; datetime LT[500], ST[500]; bool first = true; int init() { if (first) { first = false; for(int i = 0; i < MaxLines; i++) { L[i] = 0; S[i] = 0; } } return(0); } int deinit() { for(int j = 0; j < MaxLines; j++) { string n = "L"+j; ObjectDelete(n); n = "S"+j; ObjectDelete(n); } return(0); } int start() { for(int i = Bars - IndicatorCounted() + 1; i > 0; i--) { double h = MathMax(Open[i+2], Close[i+2]); if ((MathMax(Open[i+3], Close[i+3]) > h) && (Close[i] > h)) { for(int j = 0; j < MaxLines; j++) { if (L[j] == h) break; if (L[j] != 0) continue; L[j] = h; LT[j] = Time[i+2]; break; } } h = MathMin(Open[i+2], Close[i+2]); if ((MathMin(Open[i+3], Close[i+3]) < h) && (Close[i] < h)) { for(j = 0; j < MaxLines; j++) { if (S[j] == h) break; if (S[j] != 0) continue; S[j] = h; ST[j] = Time[i+2]; break; } } for(j = 0; j < MaxLines; j++) if (MathMin(Open[i], Close[i]) <= L[j]) L[j] = 0; for(j = 0; j < MaxLines; j++) if (MathMax(Open[i], Close[i]) >= S[j]) S[j] = 0; } for(j = 0; j < MaxLines; j++) { string n = "L"+j; if (L[j] == 0) { ObjectDelete(n); continue; } ObjectCreate(n, OBJ_TREND, 0, LT[j], L[j], Time[0], L[j]); ObjectSet(n, OBJPROP_COLOR, Lime); } for(j = 0; j < MaxLines; j++) { n = "S"+j; if (S[j] == 0) { ObjectDelete(n); continue; } ObjectCreate(n, OBJ_TREND, 0, ST[j], S[j], Time[0], S[j]); ObjectSet(n, OBJPROP_COLOR, Red); } return(0); }