Australian (ASX) Stock Market Forum

Amibroker - Changing Bollinger Band parameters - code?

Joined
12 April 2012
Posts
182
Reactions
1
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 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 );
 
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:
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 );
 
// 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
 
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 );



Can the middle line be added with the same values and settings in the previous code?
 
Top