Amibroker - Changing Bollinger Band parameters - code? - Aussie Stock Forums

Thread: Amibroker - Changing Bollinger Band parameters - code?

1. Amibroker - Changing Bollinger Band parameters - code?

Hi everyone,

Sorry for such a basic question, but I have read the Amibroker manual, and searched pages and pages on Google and can't find the answer.

Basically, I want to change the parameters on the Bollinger Band to a 100 day moving average with the upper band set to 3 standard deviations and the lower band set at 1 standard deviation.

Below is the code for the standard Amibroker settings, what exactly do I need to change?

P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );

Thanks for any help,

Steve

2. Re: Amibroker - Changing Bollinger Band parameters - code?

Originally Posted by Steve C
Hi everyone,

Sorry for such a basic question, but I have read the Amibroker manual, and searched pages and pages on Google and can't find the answer.

Basically, I want to change the parameters on the Bollinger Band to a 100 day moving average with the upper band set to 3 standard deviations and the lower band set at 1 standard deviation.

Below is the code for the standard Amibroker settings, what exactly do I need to change?

P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );

Thanks for any help,

Steve
Hi Mate,

I'm a newbie to AB too.

Try this -

P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width_Top = Param("Upper Width", 2, 0, 10, 0.05 );
Width_Bot = Param("Lower Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width_Top ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width_Bot ), "BBBot" + _PARAM_VALUES(), Color, Style );

3. Re: Amibroker - Changing Bollinger Band parameters - code?

Originally Posted by Steve C
Hi everyone,

Sorry for such a basic question, but I have read the Amibroker manual, and searched pages and pages on Google and can't find the answer.

Basically, I want to change the parameters on the Bollinger Band to a 100 day moving average with the upper band set to 3 standard deviations and the lower band set at 1 standard deviation.

Below is the code for the standard Amibroker settings, what exactly do I need to change?

P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );

Thanks for any help,

Steve
PHP Code:
``` P = ParamField("Price field",-1); Periods = Param("Periods", 100, 2, 300, 1 ); SDUpr = Param("StdDev Upr", 3, 0, 10, 0.05 ); SDLwr = Param("StdDev Lwr", 1, 0, 10, 0.05 ); Color = ParamColor("Color", colorCycle ); Style = ParamStyle("Style"); Plot( BBandTop( P, Periods, SDUpr ), "BBTop" + _PARAM_VALUES(), Color, Style );  Plot( BBandBot( P, Periods, SDLwr),   "BBBot" + _PARAM_VALUES(), Color, Style );  ```

4. Re: Amibroker - Changing Bollinger Band parameters - code?

// BBForASF.afl
//
// Set a Bollinger Band to 100 day moving average
// with top band 3 std dev and bottle band 1 std dev.
//
// Using the 100 day lookback for the average
// to be the number of days in the std dev.

MALength = 100;
UpperBandDist = 3;
LowerBandDist = 1;

MidBand = MA( C, MALength );
StdDevWidth = StDev( C, MALength );

UpperBand = MidBand + UpperBandDist * StdDevWidth;
LowerBand = MidBand - LowerBandDist * StdDevWidth;

Plot( C, "Price", colorBlack, styleCandle );
Plot( MidBand, "Mid", colorBlue, styleLine );
Plot( UpperBand, "Upper", colorGreen, styleLine );
Plot( LowerBand, "Lower", colorRed, styleLine );

// end

---------------

Add Param statements to allow changing the plot manually
Add Optimize statements to allow changing the plots in backtest / optimize

Best,
Howard

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Aussie Stock Forums