Showing posts with label AFL. Show all posts

We often need to find tickers having  similar key worlds like 'holding', 'infra' etc in our Amibroker databases.
For this a very simple AFL code can be used.
Write your keyword (keyword INFRA being the default) in the 'Parameters' field  of the Automatic Analysis window strictly in capital letters  else you shall not get any results.


keyword=ParamStr("Keyword in Capitals","INFRA");//use Capital Letters only 
//enter the string/keyword  which you want to search in tickers


if(StrFind(Name(),keyword))

Filter=1;
AddColumn(C,"c",1.2);
AddColumn(Status("StockNum"),"no",1);


AFL displaying tickers with 'OIL' keyword
  

A couple of days back, I had written an AFL required by a boarder of a forum I frequent which marked highest/lowest close on a chart by placing a hollow colored rectangle near the close price and printed highest/lowest close value on the stock chart.

We are often required  to ascertain the highest/lowest value for a  a period and this AFL caters this need. We get highest/lowest price bars without actually straining our brain especially in a candlestick chart.
One can change the period as per his requirement while 7 being the default value.



Desired AFL is as follows:


prd=Param("Period",7,5,5000,1);
Hv=LastValue(HHV(C,prd));Lv=LastValue(LLV(C,prd));
t1=H*1.01;t2=L*.998;
bi=BarIndex(); Lb=LastValue(bi);

Hbi=LastValue(ValueWhen(C==Hv,bi));

ph=LastValue(ValueWhen(bi==Hbi,H))*1.01;

Lbi=LastValue(ValueWhen(C==LV,bi));
PlotShapes(IIf(bi==hbi ,shapeHollowSquare,shapeNone),colorTurquoise,0,t1);
PlotShapes(IIf(bi==lbi ,shapeHollowSquare,shapeNone),colorDarkYellow,0,t2);

dch=LastValue(ValueWhen(bi==Hbi,C));
zz=dch*1.01;
dcl=LastValue(ValueWhen(bi==lbi,C));
yy=dcl*.99;

GfxSetBkColor(colorWhite);
GfxSetTextColor(colorDarkGreen);
GfxTextOut("Highest "+prd+" Day Close:"+dch,250,50);

GfxSetTextColor(colorRed);
GfxTextOut("Lowest "+prd+" Day Close:"+dcl,250,150);


Powered by Blogger.