how can i avoid repetations in grid style ea?

 

I planned an EA trading with grid.i explained grid like this:

bool buypoints()
{
double m[201];
for(int k=0;k<=200;k++)
{m[k]=NormalizeDouble(((uppervalue*1000-steppips*(k+1))/1000),Digits());//uppervalue and steppips are external values for usd/jpy.

if(m[k]==Ask) return(1);

}
}

if (buypoints()&&some conditions...)buy

if (sellpoints()&&some conditions...)sell..........

lets say uppervalue is 110.000 and steppips is 200,it returns true and buy at 109.800,109.600,109,400 and so on.

i want to limit the buys at same levels by 3.for example if i have 3 buy trades at level 109.800,i want no more trade at that level.

i m new in programming and trying to do my best.thanks for  answers.

 
Devastater: I planned an EA trading with grid.i explained grid like this:
Same as
          Martingale, guaranteed to blow your account eventually.