Skip to main content

Beta (Slope) for Amibroker (AFL)

kiedal over 12 years ago Amibroker (AFL)

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

Beta calculation based on Excel’s SLOPE function

Indicator / Formula

Copy & Paste Friendly
function aBetaLnRegCoeff (Index, Stock, Period) {
   IndexRtn = (Index-Ref(Index,-1))/Ref(Index,-1)*100;
   StockRtn = (Stock-Ref(Stock,-1))/Ref(Stock,-1)*100;
   IndexRtnAvg = Sum(IndexRtn,Period) / Period;
   StockRtnAvg = Sum(StockRtn,Period) / Period;
   IndexDev = IndexRtn - IndexRtnAvg;
   StockDev = StockRtn - StockRtnAvg;
   return (Sum(IndexDev*StockDev,Period) / Sum(IndexDev*IndexDev,Period));
}

Beta = aBetaLnRegCoeff (Foreign("INDU", "C"), C, 50);
Plot(Beta, "Beta", ParamColor("Beta color", colorBlue), ParamStyle("Beta style"));

1 comments

Leave Comment

Please login here to leave a comment.