Bladeof300
Member
All the "0" in the script are values that need to be referenced for each stock, but I dont know how to retrieve the information automatically via the code. This code is designed to identify under valued stocks.
Can someone help me automate this process?
The most important ones are the FCF inputs could automatically populate and "Shares_Outstanding". If those are correct the code should function
Can someone help me automate this process?
The most important ones are the FCF inputs could automatically populate and "Shares_Outstanding". If those are correct the code should function
Code:
#DCF_Discounted_Cash_Flow
#__________________________________________
#Cash Flow for each year recorded(currently only 5 years of inputs included)
input year1FCF = 0;
input year2FCF = 0;
input year3FCF = 0;
input year4FCF = 0;
input year5FCF = 0;
#input year6FCF = 0;
#input year7FCF = 0;
#input year8FCF = 0;
#input year9FCF = 0;
#input year10FCF = 0;
input Perpetual_Growth_Rate = .025; #Growth Rate of the Economy
input Discout_Growth_Rate = .08;
#FCF = FreeCashFlow
def CF1 = (year2FCF - year1FCF) / year1FCF;
def CF2 = (year3FCF - year2FCF) / year2FCF;
def CF3 = (year4FCF - year3FCF) / year3FCF;
def CF4 = (year5FCF - year4FCF) / year4FCF;
#def CF5 = (year6FCF - year5FCF)/ year5FCF;
#def CF6 = (year7FCF - year6FCF)/ year6FCF;
#def CF7 = (year8FCF - year7FCF)/ year7FCF;
#def CF8 = (year9FCF - year8FCF)/ year8FCF;
#def CF9 = (year10FCF - year9FCF)/ year9FCF;
#def CF10 = (year11FCF - year10FCF)/ year10FCF;
Input GrowthAVG_Number = 4; # number of calculations included
Def Avg_GrowthRate = (CF1 + CF2 + CF3 + CF4) / GrowthAVG_Number;
Def FutureCashFlow = (year5FCF * (1 + Avg_GrowthRate));
Def Terminal_Value = FutureCashFlow * (1 + Perpetual_Growth_Rate) / (Discout_Growth_Rate - Perpetual_Growth_Rate );
Def SumofFCF = FutureCashFlow; #would normally be multiple furture projected years of cash flow
Input Cash_or_Cash_Equivelants = 0;
Input Total_Debt = 0;
Def Equity_Value = SumofFcf - Total_Debt;
Input Shares_Outstanding = 0;
Def Price_Per_Share = Equity_Value/Shares_Outstanding;
Def current_Price = Close;
Def Difference = (Price_Per_Share - current_Price)/current_price;
AddLabel(yes, "% Difference from current price: " + Difference, Color.WHITE);
AddLabel(yes, "Value_Per_Share: " + Price_Per_Share, If price_per_Share <= close then color.light_green else Color.light_red);