Hi coders, I need your help to advise me how to get my targeted number of count (mxGrn = 6) of large green bars (using ATR as a benchmark) that the close prices must be > the current day (D1)'s opening price.
Below loop is my wrong codes as I cannot get the Shift (cntGrnSf) when the count is met ! Furthermore, for the count (cntGrn), the "break" function always stops at count = 1 and it will not continue to loop further till mxGrn = 6.
My mission : Let the count (cntGrn) loop continues to loop until the target is met (mxGrn = 6), then stops, at the same time, the loop output will give the Shift (cntGrnSf) accordingly.
I cannot figure out where I went wrong with the codes above and I need your help to modify the above codes so that it can work accordingly, thanks.
Below loop is my wrong codes as I cannot get the Shift (cntGrnSf) when the count is met ! Furthermore, for the count (cntGrn), the "break" function always stops at count = 1 and it will not continue to loop further till mxGrn = 6.
Inserted Code
double Op0D1=iOpen(Symbol(),1440,0); int mxGrn=6; int cntGrn=0, cntGrnSf=0; for(int i=1; i<=100; i++) {double Op0=iOpen(Symbol(),15,i), Cs0=iClose(Symbol(),15,i), ATR0=iATR(Symbol(),15,5,i); if(Cs0>Op0D1 && Cs0-Op0>ATR0) {cntGrn++; if(cntGrn==mxGrn) cntGrnSf=i; break;}} {Alert(" Grn Cnt / Sf : "+IntegerToString(cntGrn)+" / "+IntegerToString(cntGrnSf));}
My mission : Let the count (cntGrn) loop continues to loop until the target is met (mxGrn = 6), then stops, at the same time, the loop output will give the Shift (cntGrnSf) accordingly.
I cannot figure out where I went wrong with the codes above and I need your help to modify the above codes so that it can work accordingly, thanks.