Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Bollinger band using STD Dev and MA for Amibroker (AFL)

Rating:
4 / 5 (Votes 3)
Tags:
trading system, amibroker, bands

Bollinger Band using Standard Deviation and MA. Buy Sell when reaches the low or high of the band

Similar Indicators / Formulas

Extreme Keltner using ATR
Submitted by jenkisan over 12 years ago
Heikin Ashi HaDiffCO
Submitted by kaiji almost 15 years ago
Candle alert based on 200 EMA
Submitted by JPMamgain over 12 years ago
Bollinger Trading system
Submitted by anandnst over 12 years ago
Scan Buy Sell & BB
Submitted by morgen over 14 years ago

Indicator / Formula

Copy & Paste Friendly
_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, "Current Price: ", IIf( O < C, colorBrightGreen, colorRed ), styleCandle );
_SECTION_END();


_SECTION_BEGIN("Middle Band");

P = ParamField("Price Field", -1);
Period = Param("Period", 20, 2, 300, 1);

MiddleBand = MA(P, Period);

Plot(MiddleBand,"", ParamColor("Color", colorYellow), ParamStyle("Style")|styleNoRescale);
_SECTION_END();

_SECTION_BEGIN("Uppar Band");

P = ParamField("Price Field", -1);
Period = Param("Period", 20, 2, 300, 1);

UpparBand = MA(P, Period) + StDev(P, Period)*2;

Plot(UpparBand, "", ParamColor("Color", colorGreen), ParamStyle("Style")|styleNoRescale);

_SECTION_END();

_SECTION_BEGIN("Lower Band");

P = ParamField("Price Field", -1);
Period = Param("Period", 20, 2, 300, 1);

LowerBand = MA(P, Period) - StDev(P, Period)*2;

Plot(LowerBand, "", ParamColor("Color", colorRed), ParamStyle("Style")|styleNoRescale);

_SECTION_END();

_SECTION_BEGIN("Buy Sell calculation");

PositionSize = 5000;
Buy =  Ref(L < LowerBand, -2) AND Ref(C > LowerBand, -1);
Short = Ref(H > UpparBand, -2)  AND Ref(C < UpparBand, -1);

Buyst=ValueWhen(Buy,O,1);
Shortst=ValueWhen(Short,O,1);
 
Sell=  Cross(Buyst*0.995,C) ;
Cover=  Cross(C,Shortst*1.005);
 
Buy=ExRem(Buy,Short) OR ExRem(Buy,Sell) ;
Short=ExRem(Short,Buy) OR ExRem(Short,Cover);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
SellPrice = ValueWhen( Sell, C, 1 );

BuyPrice = ValueWhen( Buy, C, 1 );

FirstVisibleBar = Status( "FirstVisibleBar" );
Lastvisiblebar = Status("LastVisibleBar");
for( b = Firstvisiblebar; b <= Lastvisiblebar AND b < BarCount; b++)
{
if( Buy[b] ) PlotText("\n Buy\N "+NumToStr(BuyPrice[b],1.2),b,BuyPrice[b],colorBrightGreen);
else if( Sell[b] ) PlotText(" \nSell \N"+NumToStr(SellPrice[b],1.2),b,SellPrice[b],colorRed);
}

PlotShapes(shapeUpArrow*Buy, colorGreen, 0, L, Offset=-45);
PlotShapes(shapeDownArrow*Sell, colorRed, 0, H, Offset=-45);


_SECTION_END();

3 comments

1. jayakumar1975

hello surindersingh,

line 65

if( Buy[b] ) PlotText(" \nBuy \N “+NumToStr(BuyPrice[b],1.2),b,BuyPrice[b],colorBrightGreen);
else if( Sell[b] ) PlotText(” \nSell \N"+NumToStr(SellPrice[b],1.2),b,SellPrice[b],colorRed);

some incorrect space sequence.

Waiting for your early reply.

Thanks with advance

jayakumar

2. mohammada123456

correction :

if( Buy[b] ) PlotText("\n Buy\n "+NumToStr(BuyPrice[b],1.2),b,BuyPrice[b],colorBrightGreen);
else if( Sell[b] ) PlotText(" \nSell \n"+NumToStr(SellPrice[b],1.2),b,SellPrice[b],colorRed);

good luck
“زنده باد ایران من”

3. viraldalal

@admin / mohammada

I require few parameters setup

for any AFls we use

just like drop on any afl and if iselect parameters will control afl.

Like if i say in parameters (intraday )

than it will close trades by 3.15 and show my open positions to be closed on backtesting reports.

Like wise 3 more condition and to help the matter I have written afls also but you just need to integrate.

Thanks,

Viral
dalalviral@yahoo.com

Leave Comment

Please login here to leave a comment.

Back