Amibroker - AFL Examples

Where is the link to download zip file?
Hello,

I have attached a Zip file containing few basic AFL for Amibroker users. Some are explorations and others are indicators which will plot the indicator on the chart sheet.

I am not sure these AFL are in Amibroker library. What i usually do is study all the AFL i can lay my hands on and modify it(if necessary) to suit my trading methods and personality.

I would suggest Amibroker users to study the help file in Amibroker to learn more about AFL codes. Ultimately after some serious effort and hardwork you will be able to find one or two indicators to trade profitably.

Intially when i started using Amibroker i had used around 40 chart pages to plot all indicators to analyse them. That is if you put 2 indicators in a chart sheet i had more than 80 indicators. Some will work in trending market, some will work well only in bearish or consolidation market. Ulitimately after lot of effort you will come across 2-3 indicators that will work in all market conditions if used individually or combined.

Now i have finally settled down 1-2chart pages and maximum 3 indicators for generating buy or sell signals. I had used NSE data from 1995 to check it out by visualising manually on various scrips of different price ranges and in different market conditions. I did not use back test. I prefer visualisation method. It is strenous in the begining but patterns that emerge are highly reliable and profitable.

The trading signals generated with money management is working very well.

What i am trying to convey is it is very much possible to find two or three indicators to trade profitably in all types of market conditions whether it is a bullish, bearish or consolidation market. And the surprise part is that these indicators will be the least complex and right under our noses and would have been ignored by lot of people including ourselves.

Regards

Saji
 
no zip file is available..in most part of this thread,,might have been removed...i fail to understand..without the required zip files , how the name of this thread justifies..would any one from traderji.explain plzzzz...Bijoy..Bhilai
 
Last edited:
This is very good thread.

i am new to AFL can some one can hel me to use this:


TRADING SYSTEM USING THREE AVERAGES
The system features three moving averages:
fast(green) is 100min EMA, middle(red) is 400min EMA and slow(blue) 1000 min EMA.

Entry points are determined by the middle moving average(red) crossing the long moving average(blue)
and exit points by the fast moving average(green) crossing the middle moving average(red):

Go long when:
middle moving average(red) crosses to above slow moving average(blue) from below;
AND fast moving average(green) is above middle moving average(red).

Close long when
fast moving average(green) crosses to below middle moving average(red) from above.

Go short when:
middle moving average(red) crosses to below slow moving average(blue) from above;
AND fast moving average is below middle moving average.

Close short when
fast moving average(green) crosses to above middle moving average(red) from below.


pls help me to code.
rgards,
janardhan
 

HULK

Active Member
janardhan

for you RED is Fast Blue is Mid and Bright Green for Long

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}
_SECTION_END();

_SECTION_BEGIN("MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 100, 2, 2000, 1 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("Mid MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 400, 2, 3000, 1 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("Long MA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 1000, 2, 4000, 1 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale );
_SECTION_END();
 
janardhan

for you red is fast blue is mid and bright green for long

_section_begin("price");
setchartoptions(0,chartshowarrows|chartshowdates);
_n(title = strformat("{{name}} - {{interval}} {{date}} open %g, hi %g, lo %g, close %g (%.1f%%) vol " +writeval( v, 1.0 ) +" {{values}}", o, h, l, c, selectedvalue( roc( c, 1 )) ));
plot( c, "close", paramcolor("color", colorblack ), stylenotitle | paramstyle("style") | getpricestyle() );
if( paramtoggle("tooltip shows", "all values|only prices" ) )
{
tooltip=strformat("open: %g\nhigh: %g\nlow: %g\nclose: %g (%.1f%%)\nvolume: "+numtostr( v, 1 ), o, h, l, c, selectedvalue( roc( c, 1 )));
}
_section_end();

_section_begin("ma");
p = paramfield("price field",-1);
periods = param("periods", 100, 2, 2000, 1 );
plot( ma( p, periods ), _default_name(), paramcolor( "color", colorcycle ), paramstyle("style") | stylenorescale );
_section_end();

_section_begin("mid ma");
p = paramfield("price field",-1);
periods = param("periods", 400, 2, 3000, 1 );
plot( ma( p, periods ), _default_name(), paramcolor( "color", colorcycle ), paramstyle("style") | stylenorescale );
_section_end();

_section_begin("long ma");
p = paramfield("price field",-1);
periods = param("periods", 1000, 2, 4000, 1 );
plot( ma( p, periods ), _default_name(), paramcolor( "color", colorcycle ), paramstyle("style") | stylenorescale );
_section_end();
one secret about ta is keeping it simple. I love this indicator.
For the records "can a scan/exploration be run on this? I.e go long/short & exit long/short positions?
 
_SECTION_BEGIN("_Pivot+today_Open");

//---------------------------------------------------------------------------
// Pivot Pointer
//---------------------------------------------------------------------------
// Now a days each and every trader wants pivot levels for thier day
// trading.But the main feature in this afl is you can get all types of
// pivot point in a single afl, Some of the traders use Woodie pivot,
// caramilla pivot, Fibonacci pivot and most of them used Classical
// pivot, i think this afl will solve all your needs.
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// Please write your comments to [email protected]
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// This section gets whether they want pivot level for intraday or thier eod
//---------------------------------------------------------------------------

_N(ioreod =ParamList("Pivot Levels for ", "Intraday|EOD"));

if (ioreod=="Intraday")
{
yh = TimeFrameGetPrice( "H", inDaily, -1 );
yl = TimeFrameGetPrice( "L", inDaily, -1 );
yc = TimeFrameGetPrice( "C", inDaily, -1 );
}
else
{
yh = TimeFrameGetPrice( "H", inDaily, 0 );
yl = TimeFrameGetPrice( "L", inDaily, 0 );
yc = TimeFrameGetPrice( "C", inDaily, 0 );
}

//---------------------------------------------------------------------------
// To calculate the Pivot Levels
//---------------------------------------------------------------------------

to = TimeFrameGetPrice( "O", inDaily, 0 );
pivot = (yh + yl + yc + to) / 4;
range = yh - yl;
_N(pist =ParamList("Select Pivot Type ", "Classical Pivot|Woodie Pivot|Caramilla Pivot|Fibonacci Pivot"));

if (pist =="Classical Pivot" )
{
r1 = (2 * pivot) - yl ;
s1 = (2 * pivot) - yh ;
r2 = pivot - s1 + r1;
s2 = pivot - (r1 - s1) ;
r3 = 2 * (pivot - yl) + yh ;
s3 = yl - (2 * (yh - pivot));
r4 = 3 * (pivot - yl) + yh ;
s4 = yl - (3 * (yh - pivot));
}

else if(pist =="Woodie Pivot" )
{
pivot = (yh + yl + yc + to) / 4;
r1 = (2 * pivot) - yl;
r2 = pivot + range;
r3 = yh + 2 * (pivot - yl);
r4 = r3 + range;
s1 = (2 * pivot) - yh;
s2 = pivot - range;
s3 = yl - 2 * (yh - pivot);
s4 = S3 - range;
}

else if(pist =="Caramilla Pivot" )
{
r4 = yc + range * 1.1/2;
r3 = yc + range * 1.1/4;
r2 = yc + range * 1.1/6;
r1 = yc + range * 1.1/12;
s1 = yc - range * 1.1/12;
s2 = yc - range * 1.1/6;
s3 = yc - range * 1.1/4;
s4 = yc - range * 1.1/2;
}

else
{
r4 = pivot + 1.618 * (yh - yl);
r3 = pivot + 1.382 * (yh - yl);
r2 = pivot + 0.618 * (yh - yl);
r1 = pivot + 0.382 * (yh - yl);
s1 = pivot - 0.382 * (yh - yl);
s2 = pivot - 0.618 * (yh - yl);
s3 = pivot - 1.382 * (yh - yl);
s4 = pivot - 1.618 * (yh - yl);
}

//---------------------------------------------------------------------------
// To Plot Pivot Levels in the screen
//---------------------------------------------------------------------------

_N(dsr =ParamList("Draw Intraday Pivot Levels ", "None|Both|Support|Resistance"));

if (dsr =="Support" OR dsr == "Both")
{
Plot(pivot, "\n Pivot - ",colorGreen,1);
Plot(r1, "Resistance 1 - ",colorDarkRed,1);
Plot(r2, "Resistance 2 - ",colorDarkRed,1);
Plot(r3, "Resistance 3 - ",colorDarkRed,1);
Plot((pivot+r1)/2, "Mid Value of R1 & Pivot ",colorLightBlue,1);
Plot((r3+r2)/2, "Mid Value of R2 & R3 - ",colorLightBlue,1);
Plot((r1+r2)/2, "Mid Value of R1 & R2 - ",colorLightBlue,1);
}

if( dsr == "Resistance" OR dsr == "Both")
{
Plot(pivot, "\n Pivot - ",colorGreen,1);
Plot(s3, "Support 2 - ",colorDarkGreen,1);
Plot(s2, "Support 2 - ",colorDarkGreen,1);
Plot(s1, "Support 1 - ",colorDarkGreen,1);
Plot((s3+s2)/2, "Mid Value of S2 & S3 ",colorWhite,1);
Plot((s1+s2)/2, "Mid Value of S1 & S2 - ",colorWhite,1);
Plot((pivot+s1)/2, "Mid Value of S1 & Pivot ",colorWhite,1);
}

//---------------------------------------------------------------------------
// Printing the pivot level in interpretation window
//---------------------------------------------------------------------------

//printf(Name()+ "\n\nResistance - 3 | %g\nResistance - 2 | %g\nResistance - 1 | %g\n" + "Pivot | %g\nSupport - 1 | %g\nSupport - 2 | %g\nSupport - 3 | %g", r3,r2,r1,pivot,s1,s2,s3);

printf(Name()+ "\n\nResistance - 4 | %g\nResistance - 3 | %g\nResistance - 2 | %g\nResistance - 1 | %g\n" + " PIVOT %g\nSupport - 1 | %g\nSupport - 2 | %g\nSupport - 3 | %g\nSupport - 4 | %g", r4,r3,r2,r1,pivot,s1,s2,s3,s4);


//---------------------------------------------------------------------------
// This section is for Exploration
//---------------------------------------------------------------------------

Filter = 1;
AddColumn(r3,"Resistance 3");
AddColumn(r2,"Resistance 2");
AddColumn(r1,"Resistance 1");
AddColumn(Pivot,"Pivot");
AddColumn(s1,"Support 1");
AddColumn(s2,"Support 2");
AddColumn(s3,"Support 3");

//---------------------------------------------------------------------------
// Add Pivot levels along with the title
//---------------------------------------------------------------------------

_N(Title = EncodeColor(colorBrown)+ StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g(%.1f%%)\n"+
EncodeColor(4)+"Resistance 3 -=- %g ::::: Resistance 2 -=- %g ::::: Resistance 1 -=- %g :::::"+
EncodeColor(colorGreen)+" Pivot -=- %g"+
EncodeColor(29)+"\nSupport 1 -=- %g ::::: Support 2 -=- %g ::::: Support 3 -=- %g\n ",
O, H, L, C,SelectedValue( ROC( C, 1 ) ),r3,r2,r1,pivot,s1,s2,s3));

//---------------------------------------------------------------------------
// End of Pivot Point
//---------------------------------------------------------------------------

_SECTION_END();
Dear Sir,
I would be grateful if you could insert the formating code so that I would be able to display text in the 'Interpretation' window as One, Two or Three decimal places by using the 'Parameters' drop down window, Thanks

Ian
 

Similar threads