Need help with an AFL syntax

akhill

Well-Known Member
#1
We all know that Bollinger bands are plotted and the AFL for them is

_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();


Now, I need the Bollinger bands to be plotted with only "High" values of a candle, another set of Bollinger bands to be plotted with only "Low" values of a candle.

Can anyone alter the above syntax with the required modifications ? I have looked all over the Amibroker site, but couldnot find a reference to what I needed.

P.S: I was never a technical guy and this coding is greek and latin for me. So please don't laugh at my question :thumb::thumb:
 

a1b1trader

Well-Known Member
#2
We all know that Bollinger bands are plotted and the AFL for them is

_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();

Now, I need the Bollinger bands to be plotted with only "High" values of a candle, another set of Bollinger bands to be plotted with only "Low" values of a candle.

Can anyone alter the above syntax with the required modifications ? I have looked all over the Amibroker site, but couldnot find a reference to what I needed.

P.S: I was never a technical guy and this coding is greek and latin for me. So please don't laugh at my question :thumb::thumb:
If I understood your query rightly, then, yes you can do it.
No need of an afl.
The BB chart is plotted, by default, against close values of a candle.
Use parameter menu of the chart.
Right click on a BB chart
Click parameter
Click price field and choose accordingly.
 

akhill

Well-Known Member
#3
If I understood your query rightly, then, yes you can do it.
No need of an afl.
The BB chart is plotted, by default, against close values of a candle.
Use parameter menu of the chart.
Right click on a BB chart
Click parameter
Click price field and choose accordingly.
but I need it in the afl format because I want to use that code in another afl, which I am using to design a system based on BBands of high and low. hope u got it.
 

pratapvb

Well-Known Member
#4
but I need it in the afl format because I want to use that code in another afl, which I am using to design a system based on BBands of high and low. hope u got it.
then instead of 'P' as bbandtop / bbandbot param use H for high and L for low
 

akhill

Well-Known Member
#6
another one guys.. sorry for repeated questions

if I want EMA(7) to cross EMA(15) and move above, i.e. ema7 cuts ema15 from below in its upper move, how do I write the syntax

is it Cross(EMA(p,7), EMA(p,15)) or Cross(EMA(p,15),EMA(p,7)) ???
 

akhill

Well-Known Member
#8
Another (simple)question again... :):):)

Now, I am looking for Keltner Bands.

The AFL is in this format.

_SECTION_BEGIN("Keltner Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style", styleLine | styleNoLabel);

CenterLine = MA( P, Periods );
KTop = CenterLine + Width * ATR( Periods );
KBot = CenterLine - Width * ATR( Periods );

//Plot( KTop, "KBTop" + _PARAM_VALUES(), Color, Style );
//Plot( KBot, "KBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();


Earlier, with Bollinger bands,

if I want to use the bollingerband function, and I type BBandTop(H,20,2) , the "BBandTop" turns blue, thus indicating a function.

the same way, if I use KBTop(...) or KTop(....) , the function "KBTop" is not turning blue, thereby indicating that it is not a valid function. Is there anything wrong I am doing ?

or is there any other syntax to call the keltner bands function ? please throw light. I really regret for my repeated silly questions. If I am not clear, I can post some screenshots regarding my doubts.
 

pratapvb

Well-Known Member
#9
Another (simple)question again... :):):)

Now, I am looking for Keltner Bands.

The AFL is in this format.

_SECTION_BEGIN("Keltner Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style", styleLine | styleNoLabel);

CenterLine = MA( P, Periods );
KTop = CenterLine + Width * ATR( Periods );
KBot = CenterLine - Width * ATR( Periods );

//Plot( KTop, "KBTop" + _PARAM_VALUES(), Color, Style );
//Plot( KBot, "KBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();


Earlier, with Bollinger bands,

if I want to use the bollingerband function, and I type BBandTop(H,20,2) , the "BBandTop" turns blue, thus indicating a function.

the same way, if I use KBTop(...) or KTop(....) , the function "KBTop" is not turning blue, thereby indicating that it is not a valid function. Is there anything wrong I am doing ?

or is there any other syntax to call the keltner bands function ? please throw light. I really regret for my repeated silly questions. If I am not clear, I can post some screenshots regarding my doubts.
ktop and btop are variables here

CenterLine = MA( P, Periods );
KTop = CenterLine + Width * ATR( Periods );
KBot = CenterLine - Width * ATR( Periods );

it uses MA fucntion to get the centerline
and then +/-width times ATR to get keltner bands

MA and ATR are the functions here
 

akhill

Well-Known Member
#10
Pratap,



Lets say i want to use the value of ktop in a formula, such as x = 10 times ktop. How do i define it ? If i type x = 10*ktop , its not working.
 

Similar threads