[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] A simple improvement to colored Bollinger Bands



PureBytes Links

Trading Reference Links

Ajay,

I could not figure out a way to put the colors inside the bands, but I combined with another piece of code I had which changes the background color based on price is above or below MA. Also period of MA is controlled by a Parameter setting.  This should be close to what you want.

 

Enjoy,

Don Lindberg

 

---------------------------------------Code Begins Below ----------------------------------------

 

_SECTION_BEGIN("Price");

SetChartOptions(0,chartShowArrows|chartShowDates);

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

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

_SECTION_END();

 

 

_SECTION_BEGIN("Colored Bolinger Bands");

 

pr=Param( "Period",20,0,100,1);

P = ParamField("Price field",-1);

 Style = ParamStyle("Style") | styleNoRescale | styleNoLabel |styleDashed;

 

 BBT=BBandTop(P,pr,2);

 BBB=BBandBot(P,pr,2);

 

topcond = (Cross(BBT,C)OR C>BBT)AND Ref(C, -1)> BBT;

botcond = ( Cross(C,BBB))AND Ref(C, -1 < BBB);

 

bbtcolor = IIf( BBT> Ref (BBT, -1), colorDarkGreen,colorRed );

bbbcolor = IIf( BBB > Ref (BBB, -1), colorDarkGreen,colorRed );

 

 Plot( BBT, "BBTop" + _PARAM_VALUES(), bbtcolor, styleLine|styleThick);

 Plot( BBB, "BBBot" + _PARAM_VALUES(), bbbcolor, styleLine|styleThick );

 

PlotOHLC( BBT,BBT,BBB,BBB, "", ColorRGB(254,238,175),styleCloud );

 

Buy=botcond;

Sell=topcond ;

//Buy=ExRem(Buy,Sell);

//Sell=ExRem(Sell,Buy);

 

            PlotShapes(shapeUpArrow * Buy, colorGreen, 0, L, - 10);

            PlotShapes(shapeDownArrow * Sell, colorRed, 0, H, - 10);

 

 

_SECTION_END();

_SECTION_BEGIN("BkGrgd Color Bars");

// background vis a vis MA(c,200);

p = Param("period", 20, 1, 200, 1);

Cond1 = Close > MA(C,p);

Cond2 = Close < MA(C,p);

//Plot(C,"", colorBlack, 64);

Plot( WMA(C,p),"", IIf(Cond1, colorBlack,IIf(Cond2,colorRed,colorGreen)),1);

Cond1 = Close > MA(C,p);

Cond2 = Close < MA(C,p);

Plot(Param("Height",100,1,100,1),"",IIf(Cond1,

ColorRGB(213,255,214),IIf(Cond2,ColorRGB(255,217,217),colorGold)

),styleArea|styleOwnScale|styleNoTitle|styleNoLabel|styleNoRescale,0,100);

Plot( WMA(C,p),"", colorBlue,1);

SetChartBkColor(colorLightYellow);

SetChartOptions(1,0,1);

GraphGridZOrder = 0 ;

_SECTION_END();

 

-------------------------------------- Code Ends ------------------------------------------


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of ajay babu
Sent: Monday, June 18, 2007 8:46 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] A simple improvement to colored Bollinger Bands

 

Hi

Good idea. I have another idea but it works or not i don't have any idea. It is upto you. You have used same color between the bands irrespective of the price up or down.

Can you make it that one when the price is above 20 SMA color between the bands one color (let's say light green) and price is below 20 SMA color between the bands (light red) another color.

Thank you...

Ajay



Don Lindberg <dlindber@xxxxxxxxxxnet> wrote:

For those of you who found the Colored Bollinger Bands useful, I have made a slight change to make it a bit more eye appealing, by coloring area between Bands.

 

Below find the code. 

 

Enjoy,

Don Lindberg

-------------------- Cut Here -------------------------------------

//! Colored Bollinger Bands with Price

 

_SECTION_BEGIN("Price");

SetChartOptions(0,chartShowArrows|chartShowDates);

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

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

_SECTION_END();

 

_SECTION_BEGIN("Colored Bollinger Bands");

 

pr=Param( "Period",20,0,100,1);

P = ParamField("Price field",-1);

Style = ParamStyle("Style") | styleNoRescale | styleNoLabel |styleDashed;

 

 BBT=BBandTop(P,pr,2);

 BBB=BBandBot(P,pr,2);

 

topcond = (Cross(BBT,C)OR C>BBT)AND Ref(C, -1)> BBT;

botcond = ( Cross(C,BBB))AND Ref(C, -1 < BBB);

 

bbtcolor = IIf( BBT> Ref (BBT, -1), colorDarkGreen,colorRed );

bbbcolor = IIf( BBB > Ref (BBB, -1), colorDarkGreen,colorRed );

 

 Plot( BBT, "BBTop" + _PARAM_VALUES(), bbtcolor, styleLine|styleThick);

 Plot( BBB, "BBBot" + _PARAM_VALUES(), bbbcolor, styleLine|styleThick );

 

PlotOHLC( BBT,BBT,BBB,BBB, "", colorRose,styleCloud );

 

Buy=botcond;

Sell=topcond ;

// If you feel there are too many arrows you can un-comment the next two lines.

//Buy=ExRem(Buy,Sell);

//Sell=ExRem(Sell,Buy);

 

PlotShapes(shapeUpArrow * Buy, colorGreen, 0, L, - 10);

PlotShapes(shapeDownArrow * Sell, colorRed, 0, H, - 10);

 

 _SECTION_END();

 

-------------------- Cut Here -------------------------------------

 

 

 


Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.

__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___