Gap Finder

#1
At first I want to write AFL code for find a gap that is greater than say 100points for index, but as I am newbie for AFL code. So I try to find gap finder in internet and found the code by Adheer Pai It is really amazing. Highly appreciate.

But I want to add two more function to the code, where the code could be found from below link:

1. In the graph mode, I want to specify a day, then it is count from previous 250 days to the day I point to and show corresponding line only.
2. I want to make a “explore” so that I could show all the magnitude of the gap, so I can do some filtering by myself, say gap > 100points.

Would expert please help? Thanks

Gap Finder
 
#2
Hi, some time ago I wrote a effective AFL to visualize gaps.
maybe it could be of some use...you can set the gap difference and other criteria in parameters

_SECTION_BEGIN("_plot gap");

Difference=Param("difference",0,0,3,0.05);

//Diff=((Ref(C,-1)/100)*Difference);
DiffH=((Ref(H,-1)/100)*Difference);
DiffL=((Ref(L,-1)/100)*Difference);


GapU=O>Ref(H,-1)+DiffH;
GapUL=(O>Ref(H,-1)+DiffH) AND L<=Ref(L,-1);
GapUC=(O>Ref(H,-1)+DiffH) AND L<=Ref(C,-1);
GAPUH=(O>Ref(H,-1)+DiffH) AND L<=Ref(H,-1);
GAPUM=(O>Ref(H,-1)+DiffH) AND (L<=((Ref(H,-1)+Ref(L,-1))/2));

GapD=O<Ref(L,-1)-DiffL;
GapDL=(O<Ref(L,-1)-DiffL) AND H>=Ref(L,-1);
GapDC=(O<Ref(L,-1)-DiffL) AND H>=Ref(C,-1);
GAPDH=(O<Ref(L,-1)-DiffL) AND H>=Ref(H,-1);
GAPDM=(O<Ref(L,-1)-DiffL) AND (H>=((Ref(H,-1)+Ref(L,-1))/2));

Gap_U= ParamToggle("gap up (blue)","No|Yes",1);
Gap_UH= ParamToggle("gap up narrowed to previous high (green)","No|Yes",1);
Gap_UC= ParamToggle("gap up narrowed to previous close (orange)","No|Yes",1);
Gap_UL= ParamToggle("gap up narrowed to previous low (red) ","No|Yes",1);
Gap_UM= ParamToggle("gap up narrowed to previous middle (black)","No|Yes",1);

Gap_D= ParamToggle("gap down (blue) ","No|Yes",1);
Gap_DL= ParamToggle("gap down narrowed to previous low (red)","No|Yes",1);
Gap_DC= ParamToggle("gap down narrowed to previous close (orange)","No|Yes",1);
Gap_DH= ParamToggle("gap down narrowed to previous high (green)","No|Yes",1);
Gap_DM= ParamToggle("gap down narrowed to previous middle (black) ","No|Yes",1);

if (Gap_U) PlotShapes(IIf(GapU, shapeSmallCircle, shapeNone),colorBlue, 0,L, Offset=-45);
if (Gap_UL) PlotShapes(IIf(GapUL, shapeSmallCircle, shapeNone),colorRed, 0,L, Offset=-55);
if (Gap_UC) PlotShapes(IIf(GapUC, shapeSmallCircle, shapeNone),colorOrange, 0,L, Offset=-65);
if (Gap_UH) PlotShapes(IIf(GapUH, shapeSmallCircle, shapeNone),colorGreen, 0,L, Offset=-75);
if (Gap_UM) PlotShapes(IIf(GapUM, shapeSmallCircle, shapeNone),colorBlack, 0,L, Offset=-85);

if (Gap_D) PlotShapes(IIf(GapD, shapeSmallCircle, shapeNone),colorBlue, 0,H, Offset=45);
if (Gap_DL) PlotShapes(IIf(GapDL, shapeSmallCircle, shapeNone),colorRed, 0,H, Offset=55);
if (Gap_DC) PlotShapes(IIf(GapDC, shapeSmallCircle, shapeNone),colorOrange, 0,H, Offset=65);
if (Gap_DH) PlotShapes(IIf(GapDH, shapeSmallCircle, shapeNone),colorGreen, 0,H, Offset=75);
if (Gap_DM) PlotShapes(IIf(GapDM, shapeSmallCircle, shapeNone),colorBlack, 0,H, Offset=85);

_SECTION_END();


Take Care,
BirdsEye
 

Similar threads

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?