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);
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);
Comments
Post a Comment