Skip to main content

Average buy price indicator for Amibroker (AFL)

jasmith almost 13 years ago Amibroker (AFL)

  • Rating:
    4 / 5 (Votes 3)
  • Tags:
    amibroker

Calculates average buy price for all current share holders at any point of time. The calculated value marks a robust resistance levels for the stock. When the price touches the average buy value, all of shareholders combined (float shares) have zero profit on average.

Requires setting “Outstanding shares” and “Float shares” values for the ticker in the Information window in AmiBroker. Add this formula at the end of your Price.afl (which is responsible for the price chart).

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Average Buy");
SetBarsRequired(sbrAll ,sbrAll );
floatShares = GetFnData( "SharesFloat" );
BasePrice = 0;
Turnover = _Price * Volume;
NotTradedShares = floatShares - Volume;

for ( ii = 0; ii < BarCount; ii++ )
{
    if ( ii == 0 )
        BasePrice[ii] = _Price[ii];
    else
        BasePrice[ii] = ( ( BasePrice[ii-1] * NotTradedShares[ii] ) + Turnover[ii] ) / floatShares ;
}
Plot( BasePrice, "Avg Buy", ParamColor( "Color", colorGreen ), ParamStyle("Style", styleDashed | styleNoLabel  ) | styleNoRescale ); 
_SECTION_END();

1 comments

Leave Comment

Please login here to leave a comment.