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

[amibroker] Re: Bollinger bands color change - expand - narrowing afl



PureBytes Links

Trading Reference Links

--- In amibroker@xxxxxxxxxxxxxxx, "tummalaajaybabu"
<tummalaajaybabu@xxx> wrote:
>
> Hi all 
> 
> Bollinger bands color change - generally the bands are in one color.
> But i'm trying to write afl for the bands is - Assume Default color is
> red. When the uptrend is born the upper band turns up in that case -
> what happend in default color is the same red color is appearing when
> the trend is at an end the band turns down again the same red color is
> continue.
> 
> I wish to change to the colors - when the upper band turns up the red
> color is changed to green (or any) for quick visual interpretation the
> trend is beginning. When the trend is at an end the bands change color
> from green to red. like that bottom band also. 
> 
> _SECTION_BEGIN("Bollinger Bands");
> P = ParamField("Price field",-1);
> Periods = Param("Periods", 20, 2, 100, 1 );
> Width = Param("Width", 2, 0, 10, 0.05 );
> Color = ParamColor("Color", colorCycle );
> Style = ParamStyle("Style");
> color = IIf( BBandTop (P)> Ref (BBandTop(P), -1), colorCustom12,
> colorRed );
> /*color = IIf( BBandBot(p) < Ref (BBandBot(P), -1), colorGreen,
> colorRed );*/
> Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color,
> styleThick ); 
> Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color,
> styleThick ); 
> 
> This is the formula i have tried. But i'm facing one problem. When the
> upper band turns up the color is chaning. At the same time the lower
> band also turning up but the color is not changing (if the color
> changed abruptly it will appearing in red color at an uptrend in the
> middle of the line again it will change to green in the middle). So, i
> have put (/*) mark in bbandbot syntax line. But no change. I have mark
> the syntax line with (/*) but the the bottom band is also color
> changing? I write color condition to bband top only but i'm getting
> the same colors at bottom band too?
> 
> Can any one look into the afl and suggest me what to do?
> 
> Thank you....
> 
> Ajay
>


hi, I am a novice in AFL language but you can try this :



_SECTION_BEGIN("ColoredBBands");
P = ParamField("Price field",-1);
Style = ParamStyle("Style") | styleNoRescale | styleNoLabel | styleDashed;

BBT=BBandTop(P,10,2);
BBB=BBandBot(P,10,2);

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

bbbcolor = IIf( BBB < Ref (BBB, -1), colorGreen,colorRed );

Plot( BBT, "BBTop" + _PARAM_VALUES(), bbtcolor, Style ); 
Plot( BBB, "BBBot" + _PARAM_VALUES(), bbbcolor, Style ); 

_SECTION_END();


Hope that would solve your problem.




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
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/