Beta (Slope) for Amibroker (AFL)
kiedal over 12 years ago Amibroker (AFL)
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.
how come i missed this !!!
Nice work kiedal