Raunak ,
Just if you missed
"Bollinger Bands are envelopes which surround the price bars on a chart. Bollinger Bands are plotted two standard deviations away from a simple short-term moving average. This is the primary difference between Bollinger Bands and envelopes. Envelopes are plotted a fixed percentage above and below a moving average. Because standard deviation is a measure of volatility, the Bollinger Bands adjust themselves to the market conditions. They widen during volatile market periods and contract during less volatile periods. Bollinger Bands become moving standard deviation bands. Bollinger Bands are displayed with a third line. This is the simple (short-term) moving average line. The time period for this moving average can vary. The default for short-term moving average in AmiBroker is 15 days."
AFL could be very simple as
_SECTION_BEGIN("Moving Average ENVELOPE");
ENVELOPE_WIDTH = 6 ; //IN PERCENT (UPPER+LOWER)
MA_period =15;
SMA = MA(C, MA_period) ;
SMA_LB =(1-(ENVELOPE_WIDTH/200))*(SMA) ;
SMA_UB=(1+(ENVELOPE_WIDTH/200))*(SMA) ;
//Plot(MA( Close,RANGE_BUY), "SMA_BUY", colorBlue ,styleThick );
Plot (SMA_5 ,"SMA_5", colorBlack ,styleLine );
Plot (SMA_LB , "SMA_LB", colorGreen ,styleLine );
Plot (SMA_UB, "SMA_UB", colorRed ,styleLine );
_SECTION_END();
-----
But I feel BB is better .
rgds
rajesh