Buy/Short signal based on different condition at different time

In the below AFL (intraday scan), I am using Buy3 and Buy4 as Buy condition.The logical explanation is as below.

Buy1 = suptrndL ; // supertrand changing direction
Buy2 = EMA1 AND EMA2 AND EMA3 ; // EMA5, 13, 21 crossing EMA50 within 3 consecutive candlels
Buy3 = Buy1 AND Buy2 ;
Buy4 = cci5min8prd < -120 AND CCI30min34prd > 100 ; CCI condition from multi time frame
Buy = Buy3 AND Buy4 ;

I understand that this will generate signal only when both Buy3 and Buy4 conditions are met at the same candle and that possibility is very rare. Instead I want the condition Buy3 to be satisfied first (at any three consecutive candles) and then when Buy4 condition is met a Buy signal has to be generated. Similarly for Short condition too. Sorry for grammatical error and coding mistakes. Thanks in advance.

// SuperTrend-Indicator

_SECTION_BEGIN("ReEntry");
SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0)));
GfxSetBkMode(0); 
GfxSetOverlayMode(1);

CS = (C-O)/(H-L)*100 ;  //candle strngth
PR = (H-L)/O*100  ;   // Price range to determine reversal strength


SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}}   {{DATE}}  Open  %g, Hi   %g, Lo   %g, Close   %g  (%.1f%%),   Vol  " +WriteVal( V, 1.0 ) +"   (%.1f%%) , CS  %g,   PR  %g  {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )), SelectedValue( ROC( V, 1 )), CS, PR ));
Plot(C,"\nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);


 //Initial Parameters 
TGTPercentage = 1; // 1% profit target from buy price 
SLPercentage = 1; // trade risk in percent equals to SL% of stock price 
PositionRisk = 1; // how much (in percent of equity) we risk in single position 
PctSize = 100 * PositionRisk / SLPercentage;  
SetPositionSize( PctSize, spsPercentOfEquity ) ;// Position Size = (0.25% of capital / 1 % of entry price) 

SetTradeDelays( 1,1,1,1 ); 
SetOption( "InitialEquity", 100000); /* starting capital */ 
SetOption("CommissionMode",2); 
SetOption("CommissionAmount",55); 
SetOption("AccountMargin",100);

N = 1; //Per Symbol Trade Limit

StartTime = 091500; // order starts after this time
StopTime = 130000; // order flowing stops after this time
Sqofftime = 151000; // intraday positions auto square off time
sqoff = TimeNum() >=sqofftime;
SqoffPrice = ValueWhen(TimeNum() >=sqofftime,C);


TimeCondition = TimeNum()>= Starttime AND TimeNum()<=stoptime ; 
dn = DateNum();
newDay = dn != Ref( dn,-1);


///////////////   SuperTrend   ////////////////////////////////////
atrPeriod=Param("atrPeriod",7,1,30,1);
atrMult=Param("atr-Multiplier",3,1,9,1);

avgTR=ATR(atrPeriod) * atrMult;
startATR=ATR(2) * atrMult;

midP = (H+L)/2;

for(ia=1; ia > 29; ia++)
{
	supT[ia]=Null;
}
for( i = 30; i < BarCount; i++ )
{
	if(i==30)
	{
		if (midP[i] < midP[i-1])
		{
			supT[i]=midP[i] + startATR[i];
			td=-1;
		}
		else
		{
			supT[i]=midP[i] - startATR[i];
			td=1;
		}
	}
	if(i > 30)
	{
		if(td == -1)
		{
			if(midP[i] > supT[i-1])
			{
				supT[i]=midP[i] - avgTR[i-1];
				td=1;
				supTup[i]=supT[i];
				supTDown[i]=Null;
			}
			else
			{
				supT[i]=Min(supT[i-1],midP[i] + avgTR[i-1]);
				supTdown[i]=supT[i];
				supTUp[i]=Null;
			}
			continue;
		}
		if(td == 1 )
		{
			if(midP[i] < supT[i-1])
			{
				supT[i]=midP[i] + avgTR[i-1];
				td=-1;
				supTdown[i]=supT[i];
				supTUp[i]=Null;
			}
			else
			{
				supT[i]=Max(supT[i-1],midP[i] - avgTR[i-1]);
				supTup[i]=supT[i];
				supTDown[i]=Null;
			}
		}
	}
	
}


Plot(supTup,"SuperTrendUp", colorGreen, styleThick);
Plot(supTdown,"SuperTrendDown", colorRed, styleThick);

//////////////////////////////////////////

tf1 = in5Minute; 
TimeFrameSet( tf1 ); // switch to 5 minute time frame 
cci5min8prd = CCI(8);
TimeFrameRestore(); // restore time frame to original 

tf2 = 2*in15Minute; 
TimeFrameSet( tf2 ); // switch to 30 minute time frame 
CCI30min34prd = CCI(34); 
TimeFrameRestore(); // restore time frame to original 

/// Expanding to original interval 
expandmode = expandLast; 
cci5min8prd = TimeFrameExpand( cci5min8prd, tf1, expandmode ); 
CCI30min34prd = TimeFrameExpand( CCI30min34prd, tf1, expandmode ); 

////////////////////  EMA  ///////////////////////

EMA5 = EMA(C,5);
EMA13 = EMA(C,13);
EMA21 = EMA(C,21); 
EMA50 = EMA(C,50); 

Plot(EMA5,"EMA5",colorRed);
Plot(EMA13,"EMA13",colorGreen);
Plot(EMA21,"EMA21",colorWhite);
Plot(EMA50,"EMA50",colorBlue,styleThick);
//////////////////////////////////////////////////////

suptrndL = Sum(Cross(supTup,supTdown), 3) == 1 ;

EMA1 = Sum(Cross(EMA5, EMA50), 3) == 1;
EMA2 = Sum(Cross(EMA13, EMA50), 3) == 1;
EMA3 = Sum(Cross(EMA21, EMA50), 3) == 1;

Buy1 = suptrndL ;
Buy2 = EMA1 AND EMA2 AND EMA3 ;
Buy3 = Buy1 AND Buy2 ;
Buy4 = cci5min8prd < -120 AND CCI30min34prd > 100 ;
Buy = Buy3 AND Buy4 AND TimeCondition ;
BuyPrice = ValueWhen(Buy,Close); //Enter at Close of the candle//

LongTarget = BuyPrice + ((TGTPercentage * BuyPrice)/100);
LongStop = BuyPrice - ((SLPercentage * BuyPrice)/100);
Sell = Cross(H,LongTarget) OR Cross(LongStop,L) OR sqoff; //Exit if Target/Stop/Square off Time reached
SellPrice = IIf(Cross(H,LongTarget), LongTarget, IIf(Cross(LongStop,L), LongStop, SqoffPrice)); 

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);


EMA4 = Sum(Cross(EMA50, EMA5), 3) == 1;
EMA5 = Sum(Cross(EMA50, EMA13), 3) == 1;
EMA6 = Sum(Cross(EMA50, EMA21), 3) == 1;

suptrndS = Sum(Cross(supTdown,supTup), 3 ) == 1;

Short1 = suptrndS ;
Short2 = EMA4 AND EMA5 AND EMA6 ;
Short3 = Short1 AND Short2 ;
Short4 = cci5min8prd > 120 AND CCI30min34prd < -100 ;
Short = Short3 AND short4 AND TimeCondition ;
ShortPrice = ValueWhen(Short, Close); 

ShortTarget = ShortPrice - ((TGTPercentage * ShortPrice)/100);
ShortStop = ShortPrice + ((SLPercentage * ShortPrice)/100);
Cover = Cross(ShortTarget, L) OR Cross(H, ShortStop) OR sqoff;
CoverPrice= IIf(Cross(ShortTarget, L),ShortTarget,IIf(Cross(H, ShortStop), ShortStop, SqoffPrice));


Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);

Filter = Buy or Sell; 

_SECTION_END();

Have you already solved your problem yet, Sir? Hope you have already. I really wanted to know the generic code structure for satisfying multiple conditions one after the other.