How to change following settings in AmiBroker?

tomjerry

Well-Known Member
#11
To open parameter dialog click on the chart and press CTRL + P to open it (or do right click on the chart and choose 'Parameters'. Then you can change param settings (defined by Param functions in the code).
I checked by Right Click and Parameters, there are lots of settings so I am confused and left everything as it is. If i will try to change settings and something will went wrong then everything will be messed up!!
 
#12
I checked by Right Click and Parameters, there are lots of settings so I am confused and left everything as it is. If i will try to change settings and something will went wrong then everything will be messed up!!

There is a reset button at the bottom of the parameters dialog. Nothing can get messed up. Don't worry.

The color of standard SAR code is white. Since your background color is white too it's not a miracle that you can not see SAR. ;)
I have added custom SAR to the code so you won't have that problem



Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));

Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("EMA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 50, 2, 200, 1 );
//changed by detwo
Plot( EMA( P, Periods ), "\nEMA-"+periods, ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("EMA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 100, 2, 300, 1 );
//changed by detwo
Plot( EMA( P, Periods ), "EMA-"+periods, ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("EMA3");
P = ParamField("Price field",-1);
Periods = Param("Periods", 200, 2, 400, 1 );
//changed by detwo
Plot( EMA( P, Periods ), "EMA-"+periods, ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("BBands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style") | styleNoRescale | styleNoRescale;
//changed by detwo
BBMA  = MA( P, Periods );
//changed by detwo
Plot( BBandTop( P, Periods, Width ), "Bollinger Band " + periods + "," + width + " -- Top, Bottom & Average("+ periods + ")", Color, Style ); 
Plot( BBandBot( P, Periods, Width ), "", Color, Style ); 
//changed by detwo
Plot( BBMA, "", Color, Style ); 
_SECTION_END();

_SECTION_BEGIN("Parabolic SAR");
acc  = Param("Acceleration", 0.02, 0, 1, 0.001 );
accm = Param("Max. acceleration", 0.2, 0, 1, 0.001 );
SAR0 = SAR( acc, accm );
Col  = IIf(C>SAR0, colorRed, colorLime);
Plot( SAR0, _DEFAULT_NAME(), Col, ParamStyle("Style", styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ) );
_SECTION_END();

_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorLavender ), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 2 );
_SECTION_END();

_SECTION_BEGIN("Price Interpretation");
movshort = ParamField("Short Time MA", 8 );
movmed = ParamField("Mid Time MA", 9 );
movlong = ParamField("Long Time MA", 10 );
btop = ParamField("BBTop", 11 );
bbot = ParamField("BBBottom", 12 );
if( Status("action") == actionCommentary )
{
width = btop - bbot;
lslop = LinRegSlope( C, 30 ) + 100;
lslo = LLV( lslop, 90 );
lshi = HHV( lslop, 90 );
lswidth = lshi - lslo;
trend = 100*( lslop - lslo )/lswidth;

mawidth = MA( width, 100 );
relwidth = 100*(width - mawidth)/mawidth;

_N( tname = Name()+"("+FullName()+")" );

printf("Price and moving averages:\n");
printf( tname + " has closed " + WriteIf( C > movshort, "above" , "below" ) + " its Short time moving average. ");

printf("\nShort time moving average is currently " + WriteIf( movshort > movmed, "above", "below") + " mid-time, AND " + WriteIf( movshort > movlong, "above", "below" ) + " long time moving averages.");

printf("\nThe relationship between price and moving averages is: "+
WriteIf( C > movshort AND movshort > movmed, "bullish",
WriteIf( C < movshort AND movshort < movmed, "bearish", "neutral" ) ) + " in short-term, and "+
WriteIf( movshort > movmed AND movmed > movlong , "bullish",
WriteIf( movshort < movmed AND movmed < movlong, "bearish", "neutral" ) ) + " in mid-long term. ");

printf("\n\nBollinger Bands:\n");
printf(tname+ " has closed " + 
WriteIf( C < bbot, "below the lower band by " +
WriteVal( 100 *( bbot-C )/ width, 1.1 ) + "%%. " +
WriteIf( trend < 30, " This combined with the steep downtrend can suggest that the downward trend in prices has a good chance of continuing.  However, a short-term pull-back inside the bands is likely.",
WriteIf( trend > 30 AND trend < 70, "Although prices have broken the lower band and a downside breakout is possible, the most likely scenario for "+tname+" is to continue within current trading range.", "" ) ), "" ) +

WriteIf( C > btop, "above the upper band by " +
WriteVal( 100 *( C- btop )/ width, 1.1 ) + "%%. " +
WriteIf( trend > 70, " This combined with the steep uptrend suggests that the upward trend in prices has a good chance of continuing.  However, a short-term pull-back inside the bands is likely.",
WriteIf( trend > 30 AND trend < 70, "Although prices have broken the upper band and a upside breakout is possible, the most likely scenario for "+tname+" is to continue within current trading range.", "" ) ), "" ) +

WriteIf( C < btop AND ( ( btop - C ) / width ) < 0.5, 
"below upper band by " +
WriteVal( 100 *( btop - C )/ width, 1.1 ) + "%%. ", 
WriteIf( C < btop AND C > bbot , "above bottom band by " +
WriteVal( 100 *( C - bbot )/ width, 1.1 ) + "%%. ", "" ) ));

printf("\n"+
WriteIf( ( trend > 30 AND trend < 70 AND ( C > btop OR C < bbot ) ) AND abs(relwidth) > 40,
		 "This picture becomes somewhat unclear due to the fact that Bollinger Bands are  currently",
		 "Bollinger Bands are " )+	  
WriteVal( abs( relwidth ), 1.1 ) + "%% " +
WriteIf( relwidth > 0, "wider" , "narrower" ) +
" than normal.");

printf("\n");

printf(
WriteIf( abs( relwidth ) < 40, "The current width of the bands (alone) does not suggest anything conclusive about the future volatility or movement of prices.","")+
WriteIf( relwidth < -40, "The narrow width of the bands suggests low volatility as compared to " + tname + "'s normal range.  Therefore, the probability of volatility increasing with a sharp price move has increased for the near-term. "+
"The bands have been in this narrow range for " + WriteVal(BarsSince(Cross(-40,relwidth)),1.0) + " bars. The probability of a significant price move increases the longer the bands remain in this narrow range." ,"")+
WriteIf( relwidth > 40, "The large width of the bands suggest high volatility as compared to " + tname + "'s normal range.  Therefore, the probability of volatility decreasing and prices entering (or remaining in) a trading range has increased for the near-term. "+
"The bands have been in this wide range for  " + WriteVal(BarsSince(Cross(relwidth,40)),1.0) + " bars.The probability of prices consolidating into a less volatile trading range increases the longer the bands remain in this wide range." ,""));

printf("\n\nThis commentary is not a recommendation to buy or sell. Use at your own risk.");
}
_SECTION_END();
 
#13
After inserting and saving code open parameters dialog and click 'Reset all' to get bollinger band 20,2. It is still saved 15,2 of the standard drag&dropped AFL in your AB.
 

tomjerry

Well-Known Member
#14
Ok, Reset All clicked and now its showing ok.

Actually I need Bollinger Band's All Three values separately instead of combined in one value.

I mean I do not need this: Bollinger Band 20,2 -- Top, Bottom & Average(20)

But I need following three values separately and it should show each value of real bollinger band's Top value, Bottom Value and Average Value.

BBTop(Close,20)
BBBot(Close,20)
BBAvg(Close,20)

With Standard Deviation 2.0.

Above all three values should show independent/separately.

Can you please modify following Bolinger Band code so that i can replace this code.

Code:
_SECTION_BEGIN("BBands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style") | styleNoRescale | styleNoRescale;
//changed by detwo
BBMA  = MA( P, Periods );
//changed by detwo
Plot( BBandTop( P, Periods, Width ), "Bollinger Band " + periods + "," + width + " -- Top, Bottom & Average("+ periods + ")", Color, Style ); 
Plot( BBandBot( P, Periods, Width ), "", Color, Style ); 
//changed by detwo
Plot( BBMA, "", Color, Style ); 
_SECTION_END();
 
Last edited:
#15
Another thing is that, where to look for P SAR in following picture? Point A or B or C? I tried but didn't found.

OK, now I understand. Go to 'Chart' section of the side bar on the left side of Amibroker and there go to the 'Indicators' folder. There is a standard Parabolic SAR indicator. But you don't need it since there is a SAr indicator included in my changed code now.
 

tomjerry

Well-Known Member
#17
Ok this will be my last good deed for today. For further things look at the examples and try it yourself. Do you want all three below each other or side by side?
anywhere on top, if possible then below each other.

Thanks detwo, you did excellent help for me :clap:
 
#20
Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));

Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();

_SECTION_BEGIN("EMA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 50, 2, 200, 1 );
//changed by detwo
Plot( EMA( P, Periods ), "\nEMA-"+periods, ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("EMA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 100, 2, 300, 1 );
//changed by detwo
Plot( EMA( P, Periods ), "EMA-"+periods, ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("EMA3");
P = ParamField("Price field",-1);
Periods = Param("Periods", 200, 2, 400, 1 );
//changed by detwo
Plot( EMA( P, Periods ), "EMA-"+periods, ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale ); 
_SECTION_END();

_SECTION_BEGIN("Parabolic SAR");
acc  = Param("Acceleration", 0.02, 0, 1, 0.001 );
accm = Param("Max. acceleration", 0.2, 0, 1, 0.001 );
SAR0 = SAR( acc, accm );
Col  = IIf(C>SAR0, colorRed, colorLime);
Plot( SAR0, _DEFAULT_NAME(), Col, ParamStyle("Style", styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ) );
_SECTION_END();

_SECTION_BEGIN("BBands");
P = ParamField("Price field",3);
Periods = Param("Periods", 20, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
ColorBB = ParamColor("Color BB", colorLightGrey );
ColorMA = ParamColor("Color MA", colorLightGrey );
Style = ParamStyle("Style") | styleNoRescale | styleNoRescale;
//changed by detwo
BBMA  = MA( P, Periods );
Plot( BBandTop( P, Periods, Width ), "\nBBTop" + _PARAM_VALUES(), ColorBB, Style ); 
Plot( BBandBot( P, Periods, Width ), "\nBBBot" + _PARAM_VALUES(), ColorBB, Style ); 
Plot( BBMA, "\nBBAvg(" + _PARAM_VALUES(), ColorMA, Style ); 
_SECTION_END();

_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorLavender ), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 2 );
_SECTION_END();

_SECTION_BEGIN("Price Interpretation");
movshort = ParamField("Short Time MA", 8 );
movmed = ParamField("Mid Time MA", 9 );
movlong = ParamField("Long Time MA", 10 );
btop = ParamField("BBTop", 11 );
bbot = ParamField("BBBottom", 12 );
if( Status("action") == actionCommentary )
{
width = btop - bbot;
lslop = LinRegSlope( C, 30 ) + 100;
lslo = LLV( lslop, 90 );
lshi = HHV( lslop, 90 );
lswidth = lshi - lslo;
trend = 100*( lslop - lslo )/lswidth;

mawidth = MA( width, 100 );
relwidth = 100*(width - mawidth)/mawidth;

_N( tname = Name()+"("+FullName()+")" );

printf("Price and moving averages:\n");
printf( tname + " has closed " + WriteIf( C > movshort, "above" , "below" ) + " its Short time moving average. ");

printf("\nShort time moving average is currently " + WriteIf( movshort > movmed, "above", "below") + " mid-time, AND " + WriteIf( movshort > movlong, "above", "below" ) + " long time moving averages.");

printf("\nThe relationship between price and moving averages is: "+
WriteIf( C > movshort AND movshort > movmed, "bullish",
WriteIf( C < movshort AND movshort < movmed, "bearish", "neutral" ) ) + " in short-term, and "+
WriteIf( movshort > movmed AND movmed > movlong , "bullish",
WriteIf( movshort < movmed AND movmed < movlong, "bearish", "neutral" ) ) + " in mid-long term. ");

printf("\n\nBollinger Bands:\n");
printf(tname+ " has closed " + 
WriteIf( C < bbot, "below the lower band by " +
WriteVal( 100 *( bbot-C )/ width, 1.1 ) + "%%. " +
WriteIf( trend < 30, " This combined with the steep downtrend can suggest that the downward trend in prices has a good chance of continuing.  However, a short-term pull-back inside the bands is likely.",
WriteIf( trend > 30 AND trend < 70, "Although prices have broken the lower band and a downside breakout is possible, the most likely scenario for "+tname+" is to continue within current trading range.", "" ) ), "" ) +

WriteIf( C > btop, "above the upper band by " +
WriteVal( 100 *( C- btop )/ width, 1.1 ) + "%%. " +
WriteIf( trend > 70, " This combined with the steep uptrend suggests that the upward trend in prices has a good chance of continuing.  However, a short-term pull-back inside the bands is likely.",
WriteIf( trend > 30 AND trend < 70, "Although prices have broken the upper band and a upside breakout is possible, the most likely scenario for "+tname+" is to continue within current trading range.", "" ) ), "" ) +

WriteIf( C < btop AND ( ( btop - C ) / width ) < 0.5, 
"below upper band by " +
WriteVal( 100 *( btop - C )/ width, 1.1 ) + "%%. ", 
WriteIf( C < btop AND C > bbot , "above bottom band by " +
WriteVal( 100 *( C - bbot )/ width, 1.1 ) + "%%. ", "" ) ));

printf("\n"+
WriteIf( ( trend > 30 AND trend < 70 AND ( C > btop OR C < bbot ) ) AND abs(relwidth) > 40,
		 "This picture becomes somewhat unclear due to the fact that Bollinger Bands are  currently",
		 "Bollinger Bands are " )+	  
WriteVal( abs( relwidth ), 1.1 ) + "%% " +
WriteIf( relwidth > 0, "wider" , "narrower" ) +
" than normal.");

printf("\n");

printf(
WriteIf( abs( relwidth ) < 40, "The current width of the bands (alone) does not suggest anything conclusive about the future volatility or movement of prices.","")+
WriteIf( relwidth < -40, "The narrow width of the bands suggests low volatility as compared to " + tname + "'s normal range.  Therefore, the probability of volatility increasing with a sharp price move has increased for the near-term. "+
"The bands have been in this narrow range for " + WriteVal(BarsSince(Cross(-40,relwidth)),1.0) + " bars. The probability of a significant price move increases the longer the bands remain in this narrow range." ,"")+
WriteIf( relwidth > 40, "The large width of the bands suggest high volatility as compared to " + tname + "'s normal range.  Therefore, the probability of volatility decreasing and prices entering (or remaining in) a trading range has increased for the near-term. "+
"The bands have been in this wide range for  " + WriteVal(BarsSince(Cross(relwidth,40)),1.0) + " bars.The probability of prices consolidating into a less volatile trading range increases the longer the bands remain in this wide range." ,""));

printf("\n\nThis commentary is not a recommendation to buy or sell. Use at your own risk.");
}
_SECTION_END();