Open trade only within the 1st 7 candles after alligator indicator confirms trend?

 

Hi Guys,


I wanted to hear some suggestions on how I might go about programming this I idea I have. I've created an EA that opens trades using stochastics as entry signal and alligator as trend indicator.. My logic trades based on candle data, and I want to limit my trade window to only the first 1 to 7 bars after the stochastic and alligator confirm a trend. How do I do this? Below is what I have so far. Thanks in advanced!


string Gator()
{
string GatorTrend;

double lip=iAlligator(NULL, 0, 26, 8, 16, 5, 10, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORLIPS, 1);
double teeth=iAlligator(NULL, 0, 26, 8, 16, 5, 10, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 1);
double jaw=iAlligator(NULL, 0, 26, 8, 16, 5, 10, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, 1);

double lip2=iAlligator(NULL, 0, 26, 8, 16, 5, 10, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORLIPS, 2);
double teeth2=iAlligator(NULL, 0, 26, 8, 16, 5, 10, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, 2);
double jaw2=iAlligator(NULL, 0, 26, 8, 16, 5, 10, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, 2);



GatorTrend = "NA";
if((lip > teeth) && (teeth > jaw)&&((lip2 < teeth2) || (teeth2 < jaw2))) GatorTrend = "UP";
if((lip < teeth) && (teeth < jaw)&&((lip2 > teeth2) || (teeth2 > jaw2))) GatorTrend = "DOWN";

return(GatorTrend);
}