Last active
May 28, 2019 09:59
-
-
Save DTM-SC/fe1a3aa3659fcc6fa7689ca999ac17b6 to your computer and use it in GitHub Desktop.
Fundamental AFL by DTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This AFL is to identify the Fundamental details of any stock and plot them with few parameterised Averages | |
This is useful for investers who want to identify stocks based on fundamental data and combine them with some moving averages value to invest at the right time for long term investment | |
We have added exploration too for your benefit, please ensure your data provider provides you the fundamental data for this AFL to work | |
*/ | |
_SECTION_BEGIN("Average 1"); | |
//Average_switch = ParamToggle("Candle On/off", "Off|On"); | |
P = ParamField("Field"); | |
Type = ParamList("Type", "Exponential,Weighted,Linear Regression,Double Exponential,Tripple Exponential,Wilders,Simple"); | |
Periods = Param("Periods", 9, 2, 200 ); | |
Displacement = Param("Displacement", 1, -50, 50 ); | |
mAvg = 0; | |
if( Type == "Exponential" ) mAvg = EMA( P, Periods ); | |
if( Type == "Weighted" ) mAvg = WMA( P, Periods ); | |
if( Type == "Linear Regression" ) mAvg = LinearReg( P, Periods ); | |
if( Type == "Double Exponential" ) mAvg = DEMA( P, Periods ); | |
if( Type == "Tripple Exponential" ) mAvg = TEMA( P, Periods ); | |
if( Type == "Wilders" ) mAvg = Wilders( P, Periods ); | |
if( Type == "Simple" ) mAvg = MA( P, Periods ); | |
Plot( mAvg, _DEFAULT_NAME(), ParamColor("Color", colorYellow),ParamStyle("Style",styleLine |styleThick|styleNoTitle ,maskAll),Displacement ); | |
_SECTION_END(); | |
_SECTION_BEGIN("Average 2"); | |
P = ParamField("Field"); | |
Type = ParamList("Type", "Exponential,Weighted,Linear Regression,Double Exponential,Tripple Exponential,Wilders,Simple"); | |
Periods = Param("Periods", 26 ,2, 200 ); | |
Displacement = Param("Displacement", 1, -50, 50 ); | |
mAvg = 0; | |
if( Type == "Exponential" ) mAvg = EMA( P, Periods ); | |
if( Type == "Weighted" ) mAvg = WMA( P, Periods ); | |
if( Type == "Linear Regression" ) mAvg = LinearReg( P, Periods ); | |
if( Type == "Double Exponential" ) mAvg = DEMA( P, Periods ); | |
if( Type == "Tripple Exponential" ) mAvg = TEMA( P, Periods ); | |
if( Type == "Wilders" ) mAvg = Wilders( P, Periods ); | |
if( Type == "Simple" ) mAvg = MA( P, Periods ); | |
Plot( mAvg, _DEFAULT_NAME(), ParamColor("Color", colorLightBlue),ParamStyle("Style",styleLine |styleThick|styleNoTitle ,maskAll),Displacement ); | |
_SECTION_END(); | |
_SECTION_BEGIN("Average 3"); | |
P = ParamField("Field"); | |
Type = ParamList("Type", "Exponential,Weighted,Linear Regression,Double Exponential,Tripple Exponential,Wilders,Simple"); | |
Periods = Param("Periods", 50, 2, 200 ); | |
Displacement = Param("Displacement", 1, -50, 50 ); | |
mAvg = 0; | |
if( Type == "Exponential" ) mAvg = EMA( P, Periods ); | |
if( Type == "Weighted" ) mAvg = WMA( P, Periods ); | |
if( Type == "Linear Regression" ) mAvg = LinearReg( P, Periods ); | |
if( Type == "Double Exponential" ) mAvg = DEMA( P, Periods ); | |
if( Type == "Tripple Exponential" ) mAvg = TEMA( P, Periods ); | |
if( Type == "Wilders" ) mAvg = Wilders( P, Periods ); | |
if( Type == "Simple" ) mAvg = MA( P, Periods ); | |
Plot( mAvg, _DEFAULT_NAME(), ParamColor("Color", colorBlue),ParamStyle("Style",styleLine |styleThick|styleNoTitle ,maskAll),Displacement ); | |
_SECTION_END(); | |
_SECTION_BEGIN("Average 4"); | |
P = ParamField("Field"); | |
Type = ParamList("Type", "Exponential,Weighted,Linear Regression,Double Exponential,Tripple Exponential,Wilders,Simple"); | |
Periods = Param("Periods", 100, 2, 200 ); | |
Displacement = Param("Displacement", 1, -50, 50 ); | |
mAvg = 0; | |
if( Type == "Exponential" ) mAvg = EMA( P, Periods ); | |
if( Type == "Weighted" ) mAvg = WMA( P, Periods ); | |
if( Type == "Linear Regression" ) mAvg = LinearReg( P, Periods ); | |
if( Type == "Double Exponential" ) mAvg = DEMA( P, Periods ); | |
if( Type == "Tripple Exponential" ) mAvg = TEMA( P, Periods ); | |
if( Type == "Wilders" ) mAvg = Wilders( P, Periods ); | |
if( Type == "Simple" ) mAvg = MA( P, Periods ); | |
Plot( mAvg, _DEFAULT_NAME(), ParamColor("Color", colorPaleGreen),ParamStyle("Style",styleLine |styleThick|styleNoTitle ,maskAll),Displacement ); | |
_SECTION_END(); | |
_SECTION_BEGIN("Average 5"); | |
P = ParamField("Field"); | |
Type = ParamList("Type", "Exponential,Weighted,Linear Regression,Double Exponential,Tripple Exponential,Wilders,Simple"); | |
Periods = Param("Periods", 200 ,2, 200 ); | |
Displacement = Param("Displacement", 1, -50, 50 ); | |
mAvg = 0; | |
if( Type == "Exponential" ) mAvg = EMA( P, Periods ); | |
if( Type == "Weighted" ) mAvg = WMA( P, Periods ); | |
if( Type == "Linear Regression" ) mAvg = LinearReg( P, Periods ); | |
if( Type == "Double Exponential" ) mAvg = DEMA( P, Periods ); | |
if( Type == "Tripple Exponential" ) mAvg = TEMA( P, Periods ); | |
if( Type == "Wilders" ) mAvg = Wilders( P, Periods ); | |
if( Type == "Simple" ) mAvg = MA( P, Periods ); | |
Plot( mAvg, _DEFAULT_NAME(), ParamColor("Color", colorTeal),ParamStyle("Style",styleLine |styleThick|styleNoTitle ,maskAll),Displacement ); | |
_SECTION_END(); | |
_SECTION_BEGIN("DTM Fundamental data"); | |
Face_Value = GetFnData("BookValuePerShare"); // Face Value | |
Lot = GetFnData("sharesshortprevmonth"); // Market Lot | |
Total_Shares = GetFnData("SharesOut")/ 1000000; //// Total Shares | |
EPS = GetFnData("EPS"); //// EPS | |
NAV = GetFnData("PEGRatio"); // NAV | |
Market_Capital = GetFnData("SharesOut")*Ref(C,-1)/ 1000000; // Market Capital | |
Authorized_Capital = GetFnData("ForwardDividendPerShare"); // Authorized Capital | |
Paid_Up_Cap = GetFnData("ReturnOnAssets"); // Paid-Up Capital | |
Reserve_Surplus = GetFnData ("ForwardEPS"); // Res & Sur | |
Director_Hold = GetFnData("InsiderHoldPercent"); // Director Holdings | |
Govt_Hold = GetFnData("SharesShort"); // Government Holdings | |
Institute_Hold = GetFnData("InstitutionHoldPercent"); // Institute Holdings | |
Foriegn_Hold = GetFnData("OperatingCashFlow"); // Foreign Holdings | |
Public_Hold = GetFnData("sharesfloat"); // Public Shares | |
Listing_Year = GetFnData("Beta"); // Listing Year | |
Dividend_Date = DateTimeToStr(GetFnData("DividendPayDate")); | |
Operating_Margin = GetFnData("OperatingMargin"); | |
//// Second Part : TEXT //// | |
SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey))); | |
Plot(C,"Price",IIf(C>O,ParamColor("Wick UP Color", colorLime),IIf(C<=O,ParamColor("Wick Down Color", colorOrange),colorLightGrey)),styleCandle | styleNoTitle); | |
Title = StrFormat("\\c02 {{NAME}} | {{DATE}} | Open : %g | High : %g | Low : %g | Close : %g | Change = %.1f%% | Volume = " +WriteVal( V, 1.0 ) +" {{VALUES}}",O, H, L, C, SelectedValue( ROC( C, 1 )) ) | |
+"\n" | |
+"\n"+EncodeColor(colorWhite)+"Full Name : " +FullName() | |
+"\n"+EncodeColor(colorWhite)+"Category : " +GroupID(1) + " " | |
+"\n"+EncodeColor(colorWhite)+"Sector : " +IndustryID(1) + " " | |
+"\n" | |
+"\n"+EncodeColor(colorWhite)+"Face Value : " +Face_Value + " " | |
+"\n"+EncodeColor(colorWhite)+"Market Lot : " +Lot + " " | |
+"\n"+EncodeColor(colorWhite)+"Total Shares (mn) : " +Total_Shares + " " | |
+"\n" | |
+"\n"+EncodeColor(colorWhite)+"EPS : " +EPS + " " | |
+"\n"+EncodeColor(colorWhite)+"NAV : " +NAV + " " | |
+"\n" | |
+"\n"+EncodeColor(colorWhite)+"Market Capital (mn) : " +Market_Capital + " " | |
+"\n"+EncodeColor(colorWhite)+"Authorized Capital (mn) : " +Authorized_Capital + " " | |
+"\n"+EncodeColor(colorWhite)+"Paid-up Capital (mn) : " +Paid_Up_Cap + " " | |
+"\n"+EncodeColor(colorWhite)+"Res & Sur (mn) : " +Reserve_Surplus + " " | |
+"\n" | |
+"\n"+EncodeColor(colorWhite)+"Director Holding: " +Director_Hold +"%" + " " | |
+"\n"+EncodeColor(colorWhite)+"Govt Holding : " +Govt_Hold +"%" + " " | |
+"\n"+EncodeColor(colorWhite)+"Institute Holding: " +Institute_Hold +"%" + " " | |
+"\n"+EncodeColor(colorWhite)+"Foreign Holding: " +Foriegn_Hold +"%" + " " | |
+"\n"+EncodeColor(colorWhite)+"Float/Public Share: " + Public_Hold +"%" + " " | |
+"\n" | |
+"\n"+EncodeColor(colorWhite)+"Listing Year : " +Listing_Year + " " | |
+"\n"+EncodeColor(colorWhite)+"Last Dividend : " + Dividend_Date + " " | |
+"\n"+EncodeColor(colorWhite)+"Opp Margin : " + Operating_Margin + " "; | |
///////////////EXPLORATION /////////////////// | |
LastBar = Cum( 1 ) == LastValue( Cum( 1 ) ); | |
Filter = LastBar; | |
AddColumn (Face_Value,"Face Value",format = 1.0); | |
AddColumn (Lot,"Market Lot",format = 1.0); | |
AddColumn (Total_Shares,"Total Shares (mn)",format = 1.5); | |
AddColumn (EPS,"EPS",format = 1.2); | |
AddColumn (NAV,"NAV",format = 1.2); | |
AddColumn (Market_Capital,"Market Cap (mn)",format = 1.0); | |
AddColumn (Authorized_Capital,"Auth Cap",format = 1.0); | |
AddColumn (Paid_Up_Cap,"Paid-up Cap",format = 1.0); | |
AddColumn (Reserve_Surplus,"Res & Sur",format = 1.0); | |
AddColumn (Public_Hold,"Public Hold%",format = 1.2); | |
AddColumn (Director_Hold,"Director Hold%",format = 1.2); | |
AddColumn (institute_Hold,"Institute Hold%",format = 1.0); | |
AddColumn (Govt_Hold, "Govt Hold%",format = 1.0); | |
AddColumn (foriegn_Hold,"Foreign Hold%",format = 1.0); | |
AddColumn (Operating_Margin,"Opp Margin",format = 1); | |
_SECTION_END(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment