Please create this afl

#1
Can anyone please help me to create the
meta stock %b code convert to Ami Broker(AFL).

Meta-stock (%b) code :
(C-BBandBot(C,20,S,2))/(BBandTop(C,20,S,2)-BBandBot(C,20,S,2));
 
#3
something like this

GraphXSpace=7;

C1 = C - BBandBot( Close, 20, 2 ) ;
C2 = BBandTop (Close,20,2) - C1 ;

R = C1 / C2;

uptrend = r >= Ref(r,-1);
downtrend = r < Ref(r,-1);

Plot( R , " LINE ", IIf(( uptrend ), colorGreen, colorRed ));
Plot( 2, "", IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
 
#4
update
- with parameters
- with smoothing factor

_SECTION_BEGIN("_bollinger modification");

GraphXSpace=7;

periods = Optimize("periods ",Param("periods ",20,1,48,1),1,48,1);
width = Optimize("width ",Param("width ",2,0.1,10,0.1),0.1,10,0.1);

C1 = C - BBandBot( Close, periods, width) ;
C2 = BBandTop (Close,periods,width) - BBandBot( Close, periods, width);


R = C1 / C2;
RS = (AMA( C1, 0.5 ) / AMA( C2, 0.5 )); //smooth

uptrend = r >= Ref(r,-1);
downtrend = r < Ref(r,-1);

uptrendS = rs >= Ref(rs,-1);
downtrendS = rs < Ref(rs,-1);

BS = ParamToggle("smooth","No|Yes",1);
BN = ParamToggle("normal","No|Yes",1);

if (BS) Plot( RS , " smooth ", IIf(( uptrendS ), colorGreen, colorRed ));
if (BS) Plot ( 2, "", IIf( uptrendS , colorGreen, IIf( downtrendS , colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

if (BN) Plot( R , " normal ", IIf(( uptrend ), colorGreen, colorRed ));
if (BN) Plot ( 4, "", IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

_SECTION_END();
 
Last edited:
#6
included bollinger-bands

_SECTION_BEGIN("_bollinger modification");

GraphXSpace=7;

periods = Optimize("periods ",Param("periods ",20,1,48,1),1,48,1);
width = Optimize("width ",Param("width ",2,0.1,10,0.1),0.1,10,0.1);

C1 = C - BBandBot( Close, periods, width) ;
C2 = BBandTop (Close,periods,width) - BBandBot( Close, periods, width);

R = C1 / C2;
RS = (AMA( C1, 0.5 ) / AMA( C2, 0.5 )); //smooth

uptrend = r >= Ref(r,-1);
downtrend = r < Ref(r,-1);

uptrendS = rs >= Ref(rs,-1);
downtrendS = rs < Ref(rs,-1);

BS = ParamToggle("smooth","No|Yes",1);
BN = ParamToggle("normal","No|Yes",0);

if (BS) Plot( RS , " smooth ", IIf(( uptrendS ), colorGreen, colorRed ));
if (BS) Plot ( 1, "", IIf( uptrendS , colorGreen, IIf( downtrendS , colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

if (BN) Plot( R , " normal ", IIf(( uptrend ), colorGreen, colorRed ));
if (BN) Plot ( 2, "", IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorLavender )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

_SECTION_END();

_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoLabel;
Plot( bbt = BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( bbb = BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, colorWhite, 0.9 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();

and a picture

 

johnnypareek

Well-Known Member
#10
Hi,

Gr8 work. Please note that U have given optimize in afl which is useless if buy/sell condition is not there. So, if u put some buy/sell condition, it will became a gem.

johnny at yahoo.com
 

Similar threads