// Downloaded From https://www.WiseStockTrader.com
//This code will search for bars which gap and then close inside the previous 
//bar. No copyright blah blah. Created by saiter, 2010.

_SECTION_BEGIN("Gaps");
//Switches
sUp = ParamToggle("Show Gap ups?", "NO|YES", 1);
sDown = ParamToggle("Show Gap downs?", "NO|YES", 1);
f0 = ParamList("Search for:", "Gap down|Gap up", 0);

//Create the arrays
gd=Null;
gu=Null;

//Search for the bars

for(i=1;i<BarCount;i++)
{
	if(O[i]<L[i-1] AND C[i]>L[i-1] AND C[i]<H[i-1])
		gd[i]=1;
	else gd[i]=0;
	if(O[i]>H[i-1] AND C[i]<H[i-1] AND C[i]>L[i-1])
		gu[i]=1;
	else gu[i]=0;
}

//Plot stuff
Plot(C,"Close", colorBlack, styleBar);
if(sDown)
	PlotShapes(IIf(gd, shapeSmallCircle, shapeNone), colorRed, 0, L, -15);
if(sUp)
	PlotShapes(IIf(gu, shapeSmallCircle, shapeNone), colorGreen, 0, H, 15);

//Filters
NumColumns=1;
if(f0=="Gap down")
	Filter=gd;
if(f0=="Gap up")
	Filter=gu;
_SECTION_END();