Amibroker AFL code for Bollinger Band Gap

MarketSecrets - Learn To Trade Like a Pro

Amibroker AFL code for Bollinger Band Gap:

Script:

//——————————————————————————
// Formula Name: Bollinger Band Gap
// For more scripts, visit: www.marketsecrets.in
//——————————————————————————
// BbandGap – How to Make Money Shorting Stocks in Up and Down Markets
//——————————————————————————


fClose = Ref(C,-1);
fHigh = Ref(H,-1);
fLow = Ref(L,-1);
fAdvDrop = fClose – Ref(C,-2);
fAtr = Ref(ATR(8),-1);
diffHl = fHigh-fLow;
fStoch = Ref(StochD(14),-1);
fBBandTop=Ref(BBandTop(C,20,2),-1);
fOpenCond = fClose – 0.5 * fAtr;
fOpen = Ref(O,0);
fStopLoss = fHigh + 0.5 * fAtr;

bbTopSell =
// The stock must first puncture and close outside (above) the upper Bollinger Band
IIf( fClose > fBBandTop AND
// The closer the closing price is to the high of the day, the better.
fClose > (fLow + 0.75 * diffHL ) AND
// And the bigger the day’s advance, the better
fAdvDrop > (1.5 * fAtr) AND
// On the following day, the stock must ‘gap’ down below the prior day’s close.
// This ‘gap down’ is crucial as it serves as the most important criteria of
// the entire strategy.
fOpen < fOpenCond AND
// Overbought condition added
fStoch > 80, 1, 0 );

/* Exploration Columns for Sorting */

NumColumns = 10;

Column0 = fOpen;
Column1 = fOpenCond;
Column2 = fStopLoss;

Column0Name = “Open”;
Column1Name = “OpenCond”;
Column2Name = “StopLoss”;

Column0Format = 1.2;
Column1Format = 1.2;
Column2Format = 1.2;

Filter = bbTopSell == 1;

Buy = 0;
Sell = bbTopSell>0;

Download File

error: Content is protected !!