Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

AFL Library

This is read-only version of AFL library entry. Ability to add user formulas and comment is only available from members-only area.

Details:

Formula name: Bollinger band normalization
Author/Uploader: Vic Huebner - atlantic [at] engineer.com
Date/Time added: 2002-06-03 14:44:50
Origin: Bollinger on Bollinger Bands - McGraw Hill
Keywords: Bollinger,normalize,volatility
Level: medium
Flags: indicator

DISCLAIMER: Most formulas present in AFL on-line library are submitted by the users and are provided here on an "as is" and "as available" basis. AmiBroker.com makes no representations or warranties of any kind to the contents or the operation of material presented here. We do not maintain nor provide technical support for 3rd party formulas. If you believe that formula has an error - contact the AUTHOR directly, not us. If you believe that you have copyright on that work (i.e. you have written this particular code yourself) please send us proper DMCA takedown notice. Please note that mathematical ideas/concepts can not be copyrighted, only actual AFL code if you wrote it yourself.

Description:

The position of various indicators within Bollinger bands are used as the start of a trading system. Trends and oscillations can be easily seen. Most of the usual indicators can be back-tested for profitability.

Formula:

//In "Bollinger on Bollinger Bands", John Bollinger described a method of
normalizing indicators on any stock regardless of volatility. The method simply
computes the percentage position within Bollinger bands. Touching the lower band
is zero, while touching the upper band is 100%.
//In the graph, indicator Lines are drawn at the 0, 50, AND 100% positions.
Bollinger bands are shown in white, the indicator is shown in red, and the
relative range position is shown in yellow. The multipliers are used to display
all items in a single window.
//Graph0 depicts the indicator of current interest. Simply uncomment to view a
different indicator.
MaxGraph=8;
Graph0=100000*(C+O+H+L)/Sum(C,20); //Bollinger believes all 4 items are better
//Graph0=50000*(BBandTop(C,40,2)-BBandBot(C,40,2))*C/BBandTop(C,40,2);
//Volatility change - Reversal indicator?

//Graph0=100*MFI(14); //MoneyFlowIndex - G. Quong & A. Soudek
//Graph0=100*RSI(14);
//Graph0=1000*MACD(12,26);
//Graph0=1000*Signal(12,26,9);
//Graph0=1000*V*Signal(12,26,9)/(Sum(V,12)/12); //VolWeighted MACD - B.
Dormeier
//Graph0=100*ROC(EMA(C,7),21); //Smoothed RateOfChange - 
//Graph0=-500*ADX(14); 
//Graph0=.0001*AccDist(); //Acc-distribution - Larry Williams
//Graph0=10000*EMA((2*C-H-L)*Sum(V,12)/((H-L)*V*12),10); //Intraday intensity -
David Bostian
//Graph0=100*(C-Ref(C,-1)*V*12)/Sum(V,12); //Force index - Dr. Elder

//Compute the Bollinger bands (40 bars & 2.0 SD).
Graph1=BBandTop(Graph0,40,2);
Graph2=BBandBot(Graph0,40,2);

//Compute the relative position within the bands.
Graph3=10000*(Graph0-Graph2)/(Graph1-Graph2);
//A Zig-Zag line is used to better view the trend changes. Smaller ZigChange
values mean busier charts and more frequent trading. Other parameters also
should be optimized for best results.
ZigChange=Optimize("Zig",50,40,100,10);
Graph4=Zig(Graph3+1000,ZigChange);
Graph5=0;
Graph6=5000;
Graph7=10000;
Graph1Color=Graph2Color=2;
Graph0Style=Graph1Style=Graph2Style=Graph4Style=Graph5Style=Graph6Style=Graph7Style=1;
Graph3Style=4;
Graph3Color=7;

//Buy signals are generated for stocks over $4.00 when the Zig line as well as
the price is increasing. This is a very simplistic trading system that could be
greatly improved.
Buy=(Graph4>Ref(Graph4,-1)) AND (C>4) AND (EMA(C,20)>=Ref(EMA(C,20),-1));
//Sell signals are generated when the Zig Line is decreasing or price drops.
Sell=(Graph4<(Ref(Graph4,-1))) OR (EMA(C,3)<(Ref(EMA(C,3),-1)*.98));
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy); 
//It is assumed that transactions are made the next day after a buy/sell
signal.
BuyPrice=ValueWhen(Ref(Buy,-1),Open,0);
SellPrice=ValueWhen(Ref(Sell,-1),Open,0);

Comments:

Ted Chmilar
tchmilar [at] shaw.ca
2002-10-03 10:21:34
I am impressed with the performance of this code but am concerned that it uses ZIG for sell/buy. The ZIG function looks into the future and therefore should not be used to determine buy/sell conditions. Would appreciate your comments on this.
nadav attias
nadavat [at] walla.co.il
2003-10-13 09:46:02
Hi, I'm also impressed by this formula, but am afraid of using it live due to the future look-up of ZIG.
I also tried to remove half of the condition clause in the following lines:

buySignal1 = (Graph4>Ref(Graph4,-1)) ;//AND (C>4) AND (EMA(C,20)>=Ref(EMA(C,20),-1));

sellSignal1 = (Graph4<(Ref(Graph4,-1)));/// OR (EMA(C,3)<(Ref(EMA(C,3),-1)*.98));

and I got outstanding results. Are they really accurate ? I don't know. Please your opinion...
Vic Huebner
atlantic [at] engineer.com
2003-10-27 07:54:37
Hi Nadav, Thanks for your interest. I've actually been using essentially the same algorithm - it seems better suited to a choppy environment. I use RSI for finding the stocks and MFI as a secondary check (Bollinger RSI & MFI are on the same page aong with cost-volume). The buy signal works better than the sell signal.

Buy=(Ref(Graph4,-1)<Ref(Graph4,-2)) AND (Ref(Graph4,-1)<(Graph4));
//Sell signals are generated when the Zig Line is decreasing.
Sell=(Graph4<(Ref(Graph4,-1)));
nadav attias
nadavat [at] walla.co.il
2003-10-28 05:26:30
Hello Vic,
You haven't addressed the issue of trying to predict the future. This is something we should avoid. There is no way to backtest this formula because the Zig adjusts the signals according to the quotes. The formula could never be steady or fixed. Isn't there a way to get rid of the Zig ?
Vic Huebner
atlantic [at] engineer
2003-10-31 15:45:12
The Zig-zag is helpful for me because it evens out the noise. So what's wrong with trying to predict the future? Isn't that what we're really trying to do?
Vic,
lee [at] bcgfx.com
2003-12-14 09:39:27
The problem of the ZIG/ZAG in the code may have an answer. In Stocks$Commodities isuue(Nov. 2003) there is a new ZigZag that is NON- REVISABLE.......it may fit well with your idea.

lee
ntk
ntk98_2000 [at] yahoo.co.uk
2005-11-20 11:47:14
could not access the Nov 2003 reg NON-Reviseable ZIG graph. Could you elaborate a little more or just paste the AMI formula here. Thanks
Bob L
bobbyvl [at] yahoo.com
2006-05-02 22:16:13
Be careful with this system. It needs 2 days of trading prices and then it goes back to tell you there was a signal.


About | Privacy | Terms of Use | Contact information
Copyright © 2001 AMIBROKER.COM