double temp_hi[1000],temp_lo[1000]; int temp_start[1000],temp_hits[1000],temp_strength[1000],temp_count=0; bool temp_turn[1000],temp_merge[1000]; int merge1[1000],merge2[1000],merge_count=0;
// iterate through zones from oldest to youngest (ignore recent 5 bars), // finding those that have survived through to the present___ for(shift=MathMin(Bars-1,BackLimit); shift>5; shift--) { double atr= iATR(NULL,0,7,shift); double fu = atr/2 * zone_fuzzfactor; bool isWeak; bool touchOk= false; bool isBust = false;
if(FastUpPts[shift]>0.001) { // a zigzag high point isWeak=true; if(SlowUpPts[shift]>0.001) isWeak=false;
for(i=shift-1; i>=0; i--) { if((turned==false && FastUpPts[i]>=loval && FastUpPts[i]<=hival) || (turned==true && FastDnPts[i]<=hival && FastDnPts[i]>=loval)) { // Potential touch, just make sure its been 10+candles since the prev one touchOk=true; for(j=i+1; j<i+11; j++) { if((turned==false && FastUpPts[j]>=loval && FastUpPts[j]<=hival) || (turned==true && FastDnPts[j]<=hival && FastDnPts[j]>=loval)) { touchOk=false; break; } }
if(touchOk==true) { // we have a touch_ If its been busted once, remove bustcount // as we know this level is still valid & has just switched sides bustcount=0; testcount++; } }
if((turned==false && High[i]>hival) || (turned==true && Low[i]<loval)) { // this level has been busted at least once bustcount++;
if(bustcount>1 || isWeak==true) { // busted twice or more isBust=true; break; }
for(i=shift-1; i>=0; i--) { if((turned==true && FastUpPts[i]>=loval && FastUpPts[i]<=hival) || (turned==false && FastDnPts[i]<=hival && FastDnPts[i]>=loval)) { // Potential touch, just make sure its been 10+candles since the prev one touchOk=true; for(j=i+1; j<i+11; j++) { if((turned==true && FastUpPts[j]>=loval && FastUpPts[j]<=hival) || (turned==false && FastDnPts[j]<=hival && FastDnPts[j]>=loval)) { touchOk=false; break; } }
if(touchOk==true) { // we have a touch_ If its been busted once, remove bustcount // as we know this level is still valid & has just switched sides bustcount=0; testcount++; } }
if((turned==true && High[i]>hival) || (turned==false && Low[i]<loval)) { // this level has been busted at least once bustcount++;
if(bustcount>1 || isWeak==true) { // busted twice or more isBust=true; break; }
switch(tf) { case PERIOD_M1: tfs="M1"; break; case PERIOD_M5: tfs="M5"; break; case PERIOD_M15: tfs="M15"; break; case PERIOD_M30: tfs="M30"; break; case PERIOD_H1: tfs="H1"; break; case PERIOD_H4: tfs="H4"; break; case PERIOD_D1: tfs="D1"; break; case PERIOD_W1: tfs="W1"; break; case PERIOD_MN1: tfs="MN"; }