Australian (ASX) Stock Market Forum

AmiBroker and Fundamental Scan

Joined
27 November 2017
Posts
1,200
Reactions
1,884
I am looking at creating a scan in AmiBroker using Fundamental Data provided by Norgate and having no real idea about FA I was hoping that we could pool our knowledge together and create a basic scan that can be incorporated into our own system.

So far I have the following information extracted out of Norgate and displayed in AmiBroker.

Code:
Filter = 1;

AddColumn( Close, "Close");
AddColumn( GetFnData("SharesOut"), " SharesOut", 1, colorDefault, colorDefault, 90); // Number of shares outstanding
AddColumn( GetFnData("SharesFloat"), "SharesFloat ", 1, colorDefault, colorDefault, 90); // Number of shares outstanding that are freely available for trading ("Free Float")
AddColumn( GetFnData("Beta"), "Beta "); // A measure of a stock's price volatility relative to the market
AddColumn( GetFnData("EPS"), "EPS "); // EPS excluding extraordinary items - trailing 12 month
AddColumn( GetFnData("EPSEstCurrentYear"), "EPSEstCurrentYear "); // Current Consensus for EPS
AddColumn( GetFnData("BookValuePerShare"), "BookValuePerShare "); // Book value per share - most recent quarter
AddColumn( GetFnData("ProfitMargin"), "ProfitMargin "); // Net Profit Margin % - trailing 12 month
AddColumn( GetFnData("OperatingMargin"), "OperatingMargin "); // Operating margin - trailing 12 month
AddColumn( GetFnData("OneYearTargetPrice"), "OneYearTargetPrice "); // Current Consensus Target Price
AddColumn( GetFnData("ReturnOnAssets"), "ReturnOnAssets "); // Return on average assets - trailing 12 month
AddColumn( GetFnData("ReturnOnEquity"), "ReturnOnEquity "); // Return on average equity - trailing 12 month
AddColumn( GetFnData("QtrlyRevenueGrowth"), "QtrlyRevenueGrowth "); // Revenue Change % - most recent quarter 1 year ago
AddColumn( GetFnData("SalesPerShare"), "SalesPerShare "); // Revenue per share - trailing 12 month
AddColumn( GetFnData("EBITDAPerShare"), "EBITDAPerShare "); // EBITD per share - trailing 12 month
AddColumn( GetFnData("QtrlyEarningsGrowth"), "QtrlyEarningsGrowth "); // EPS Change % - most recent quarter vs corresponding 1 year ago
AddColumn( GetFnData("DividendPerShare"), "DividendPerShare "); // Trailing 12 month sum of all split-adjusted ordinary dividends
AddColumn( GetFnData("ForwardDividendPerShare"), "ForwardDividendPerShare "); // Current Consensus for Dividend Per Share
AddColumn( GetFnData("LastSplitDate"), "LastSplitDate "); // The ex-date of the last share split or reverse split (consolidation)
AddColumn( GetFnData("LastSplitRatio"), "LastSplitRatio "); // The ratio of new shares to old in the last split
AddColumn( GetFnData("DividendPayDate"), "DividendPayDate "); // Payment date for the current dividend
AddColumn( GetFnData("ExDividendDate"), "ExDividendDate "); // Ex-dividend date for the current dividend
AddColumn( GetFnData("DelistingDate"), "DelistingDate "); // The last day that the security was available for trading before delisting

Small snip of the above exploration

upload_2020-9-6_9-23-27.png

Now the million dollar question is "What to Do With This Information"

I am thinking about creating some filters for the following

1. Return of Equity > 14
2. Shares Out < 1 billion
3. Forward Dividend > 4%
4. ?????

Hopefully some of you are interested in the above and can provide your thoughts, and if you are not AmiBroker savvy I am still interested in what you have to say so please fire away and lets see what we can put together.

Thanks

Trav
 

Attachments

  • upload_2020-9-6_9-16-0.png
    upload_2020-9-6_9-16-0.png
    45.6 KB · Views: 19
  • upload_2020-9-6_9-16-19.png
    upload_2020-9-6_9-16-19.png
    4.7 KB · Views: 19
And the above tables in AFL format ready to be utilised

Code:
// Fundamentals that reference the current price //
mktcap = NorgateFundamentals("mktcap"); // Market capitalization, includes all classes of securities/listings
beta = NorgateFundamentals("beta"); // Beta, compared to major market index
peexclxor = NorgateFundamentals("peexclxor"); // Price-to-Earnings Ratio (P/E) excluding extraordinary items, trailing 12 months
ttmpr2rev = NorgateFundamentals("ttmpr2rev"); // Price to sales, trailing 12 month
pr2tanbk = NorgateFundamentals("pr2tanbk"); // Price to Tangible Book, most recent quarter
ttmprcfps = NorgateFundamentals("ttmprcfps"); // Price to Cash Flow per Share, trailing 12 month
ttmprfcfps = NorgateFundamentals("ttmprfcfps"); // Price to Free Cash Flow per Share, trailing 12 months
price2bk = NorgateFundamentals("price2bk"); // Price to Book, most recent quarter
pebexclxor = NorgateFundamentals("pebexclxor"); // P/E Basic excluding extraordinary items, trailing 12 months
ttmpehigh = NorgateFundamentals("ttmpehigh"); // P/E excluding extraordinary items high, trailing 12 months
ttmpelow = NorgateFundamentals("ttmpelow"); //     P/E excluding extraordinary items low, trailing 12 months
peinclxor = NorgateFundamentals("peinclxor"); // P/E including extraordinary items, trailing 12 months
divyield_curttm = NorgateFundamentals("divyield_curttm"); // Current Dividend Yield, trailing 12 months, calculated by Norgate Data
ev2fcf_curttm = NorgateFundamentals("ev2fcf_curttm"); // Current Enterpsise value/Free Cash Flow, trailing 12 months
apeexclxor = NorgateFundamentals("apeexclxor"); // P/E excluding extraordinary items, most recent fiscal year
apenorm = NorgateFundamentals("apenorm"); // P/E Normalized, most recent fiscal year
apr2rev = NorgateFundamentals("apr2rev"); // Price to sales, most recent fiscal year
apr2tanbk = NorgateFundamentals("apr2tanbk"); // Price to Tangible Book, most recent fiscal year
aprfcfps = NorgateFundamentals("aprfcfps"); // Price to Free Cash Flow per Share, most recent fiscal year
aprice2bk = NorgateFundamentals("aprice2bk"); // Price to Book, most recent fiscal year
ev2fcf_cura = NorgateFundamentals("ev2fcf_cura"); // Current Enterprise Value/Free Cash Flow, most recent fiscal year

//Trailing 12 month Fundamentals//
vdes_ttm = NorgateFundamentals("vdes_ttm"); // Earnings per Share (EPS), Normalized, Excluding Extraordinary Items, Avg. Diluted Shares Outstanding
ttmepsxclx = NorgateFundamentals("ttmepsxclx"); // EPS excluding extraordinary items
ttmbepsxcl = NorgateFundamentals("ttmbepsxcl"); //     EPS Basic excluding extraordinary items
ttmepsincx = NorgateFundamentals("ttmepsincx"); // EPS including extraordinary items
ttmrevps = NorgateFundamentals("ttmrevps"); // Revenue per share
ttmcfshr = NorgateFundamentals("ttmcfshr"); // Cash Flow per Share
ttmdivshr = NorgateFundamentals("ttmdivshr"); // Ordinary Dividends per Share (unadjusted), calculated by Norgate Data
ttmdivshradj = NorgateFundamentals("ttmdivshradj"); // Ordinary Dividends per Share (adjusted), calculated by Norgate Data
ttmebitd = NorgateFundamentals("ttmebitd"); // Earnings Before Interest, Taxes, Depreciation (EBITD)
ttmebitdps = NorgateFundamentals("ttmebitdps"); // EBITD per Share
ttmfcfshr = NorgateFundamentals("ttmfcfshr"); // Free Cash Flow per Share
ttmpayrat = NorgateFundamentals("ttmpayrat"); // Payout ratio
ttmintcov = NorgateFundamentals("ttmintcov"); // Net Interest coverage
ttmfcf = NorgateFundamentals("ttmfcf"); // Free Cash Flow
ttmrev = NorgateFundamentals("ttmrev"); // Revenue
ttmebt = NorgateFundamentals("ttmebt"); // Earnings before taxes
ttmniac = NorgateFundamentals("ttmniac"); // Net Income accruing to common shares for dividends and retained earnings
ttmgrosmgn = NorgateFundamentals("ttmgrosmgn"); // Gross Margin
ttmnpmgn = NorgateFundamentals("ttmnpmgn"); // Net Profit Margin %
ttmopmgn = NorgateFundamentals("ttmopmgn"); //     Operating margin
ttmptmgn = NorgateFundamentals("ttmptmgn"); // Pretax margin
focf2rev_ttm = NorgateFundamentals("focf2rev_ttm"); // Free Operating Cash Flow/Revenue
ttmroapct = NorgateFundamentals("ttmroapct"); // Return on average assets
ttmroepct = NorgateFundamentals("ttmroepct"); // Return on average equity
ttmroipct = NorgateFundamentals("ttmroipct"); // Return on investment
ttmastturn = NorgateFundamentals("ttmastturn"); // Asset turnover
ttminvturn = NorgateFundamentals("ttminvturn"); // Inventory turnover
ttmniperem = NorgateFundamentals("ttmniperem"); // Net Income/employee
ttmrecturn = NorgateFundamentals("ttmrecturn"); // Receivables turnover
ttmrevpere = NorgateFundamentals("ttmrevpere"); // Revenue/employee
ttmepschg = NorgateFundamentals("ttmepschg"); // EPS Change %, TTM over TTM
ttmrevchg = NorgateFundamentals("ttmrevchg"); // Revenue Change %, TTM over TTM
ebitda_ttmy5cagr = NorgateFundamentals("ebitda_ttmy5cagr"); //     Earnings Before Interest, Taxes, Depreciation & Amortization, 5 Year TTM CAGR

//Most recent quarter/interim reporting period//
qbvps = NorgateFundamentals("qbvps"); // Book value (total equity) per Share
qtanbvps = NorgateFundamentals("qtanbvps"); // Book value (tangible) per Share
qcshps = NorgateFundamentals("qcshps"); // Cash per Share
netdebt_i = NorgateFundamentals("netdebt_i"); // Net Debt
qcurratio = NorgateFundamentals("qcurratio"); // Current ratio
qquickrati = NorgateFundamentals("qquickrati"); // Quick ratio
qltd2eq = NorgateFundamentals("qltd2eq"); //     Long Term debt/equity ratio
qtotd2eq = NorgateFundamentals("qtotd2eq"); // Total debt/total equity ratio
revchngyr = NorgateFundamentals("revchngyr"); // Revenue Change %, most recent quarter vs 1 year ago
epschngyr = NorgateFundamentals("epschngyr"); // EPS Change %, most recent quarter 1 year ago

//Most recent fiscal year//
arevps = NorgateFundamentals("arevps"); // Revenue per Share
abvps = NorgateFundamentals("abvps"); // Book value (total equity) per Share
atanbvps = NorgateFundamentals("atanbvps"); // Book value (tangible) per Share
acshps = NorgateFundamentals("acshps"); // Cash per Share
acfshr = NorgateFundamentals("acfshr"); // Cash Flow per Share
adivshr = NorgateFundamentals("adivshr"); // Ordinary Dividend per Share
aepsxclxor = NorgateFundamentals("aepsxclxor"); //     EPS excluding extraordinary items
aepsnorm = NorgateFundamentals("aepsnorm"); // EPS Normalized
abepsxclxo = NorgateFundamentals("abepsxclxo"); // EPS Basic excluding extraordinary items
aepsinclxo = NorgateFundamentals("aepsinclxo"); // EPS including extraordinary items
netdebt_a = NorgateFundamentals("netdebt_a"); // Net Debt
acurratio = NorgateFundamentals("acurratio"); // Current ratio
aquickrati = NorgateFundamentals("aquickrati"); // Quick ratio
altd2eq = NorgateFundamentals("altd2eq"); // LT debt/equity
atotd2eq = NorgateFundamentals("atotd2eq"); // Total debt/total equity
apayratio = NorgateFundamentals("apayratio"); // Payout ratio
aintcov = NorgateFundamentals("aintcov"); // Net Interest coverage
a1fcf = NorgateFundamentals("a1fcf"); // Free Cash Flow
arev = NorgateFundamentals("arev"); // Revenue
aebitd = NorgateFundamentals("aebitd"); // EBITD
aebt = NorgateFundamentals("aebt"); // Earnings before taxes
aniac = NorgateFundamentals("aniac"); // Net Income available to common
aebtnorm = NorgateFundamentals("aebtnorm"); // Earnings before taxes Normalized
aniacnorm = NorgateFundamentals("aniacnorm"); // Net Income Available to Common, Normalized
agrosmgn = NorgateFundamentals("agrosmgn"); // Gross Margin
anpmgnpct = NorgateFundamentals("anpmgnpct"); // Net Profit Margin %
aopmgnpct = NorgateFundamentals("aopmgnpct"); // Operating margin
aptmgnpct = NorgateFundamentals("aptmgnpct"); // Pretax margin
aroapct = NorgateFundamentals("aroapct"); // Return on average assets
aroepct = NorgateFundamentals("aroepct"); // Return on average equity
aroipct = NorgateFundamentals("aroipct"); // Return on investment
aastturn = NorgateFundamentals("aastturn"); // Asset turnover
ainvturn = NorgateFundamentals("ainvturn"); // Inventory turnover
aniperemp = NorgateFundamentals("aniperemp"); // Net Income/employee
arecturn = NorgateFundamentals("arecturn"); // Receivables turnover
arevperemp = NorgateFundamentals("arevperemp"); // Revenue/employee
revgrpct = NorgateFundamentals("revgrpct"); // Revenue growth rate, 3 year CAGR
divgrpct = NorgateFundamentals("divgrpct"); // Ordinary Dividend growth rate, 3 year CAGR
adiv5yavg = NorgateFundamentals("adiv5yavg"); // Ordinary Dividend Per Share, 5 year average
yld5yavg = NorgateFundamentals("yld5yavg"); // Ordinary Dividend Yield, 5 Year Average
ebitda_ayr5cagr = NorgateFundamentals("ebitda_ayr5cagr"); // Earnings Before Interest, Taxes, Depreciation & Amortization, 5 Year CAGR
epsgrpct = NorgateFundamentals("epsgrpct"); // EPS growth rate, 3 year CAGR
opmgn5yr = NorgateFundamentals("opmgn5yr"); // Operating Margin, 5 year average
ptmgn5yr = NorgateFundamentals("ptmgn5yr"); // Pretax Margin, 5 year average
focf2rev_aavg5 = NorgateFundamentals("focf2rev_aavg5"); // Free Operating Cash Flow/Revenue, 5 Year Average
grosmgn5yr = NorgateFundamentals("grosmgn5yr"); // Gross Margin, 5 year average
margin5yr = NorgateFundamentals("margin5yr"); // Net Profit Margin, 5 year average
aroa5yavg = NorgateFundamentals("aroa5yavg"); // Return on average assets, 5 year average
aroe5yavg = NorgateFundamentals("aroe5yavg"); // Return on average equity, 5 year average
revtrendgr = NorgateFundamentals("revtrendgr"); // Revenue growth rate, 5 year CAGR
epstrendgr = NorgateFundamentals("epstrendgr"); // EPS growth rate, 5 year CAGR
revps5ygr = NorgateFundamentals("revps5ygr"); // Revenue per Share growth rate, 5 yr CAGR
bvtrendgr = NorgateFundamentals("bvtrendgr"); // Book value per Share growth rate, 5 year CAGR
tanbv_ayr5cagr = NorgateFundamentals("tanbv_ayr5cagr"); // Tangible Book Value (Total Equity) growth rate, 5 Year CAGR
csptrendgr = NorgateFundamentals("csptrendgr"); // Capital Spending growth rate, 5 year CAGR
focf_ayr5cagr = NorgateFundamentals("focf_ayr5cagr"); // Free Operating Cash Flow growth rate, 5 Year CAGR
stld_ayr5cagr = NorgateFundamentals("stld_ayr5cagr"); // Total Debt growth rate, 5 Year CAGR
npmtrendgr = NorgateFundamentals("npmtrendgr"); // Net Profit Margin growth rate, 5 year CAGR

//Broker Consensus Forecasts/Projections//
projepsq = NorgateFundamentals("projepsq"); // Current Consensus for Quarterly EPS
projepsqh = NorgateFundamentals("projepsqh"); //     High Estimate
projepsql = NorgateFundamentals("projepsql"); // Low Estimate
projepsqnumofest = NorgateFundamentals("projepsqnumofest"); // Number of Estimates
epsactualq = NorgateFundamentals("epsactualq"); // Previous Actual Quarterly EPS
epspreviousq = NorgateFundamentals("epspreviousq"); // The EPS estimate that corresponds to the Previous Actual Quarter EPS
epssurpriseq = NorgateFundamentals("epssurpriseq"); // Previous Quarter Surprise
epssurpriseqprc = NorgateFundamentals("epssurpriseqprc"); // Previous Quarter Surprise as a Percentage
projsalesq = NorgateFundamentals("projsalesq"); // Current Consensus for Quarterly Revenue
projsalesqh = NorgateFundamentals("projsalesqh"); // High Estimate
projsalesql = NorgateFundamentals("projsalesql"); // Low Estimate
projsalesqnumofest = NorgateFundamentals("projsalesqnumofest"); // Number of Estimates
targetprice = NorgateFundamentals("targetprice"); // Current 12 month Consensus Target Price
projeps = NorgateFundamentals("projeps"); // Current Consensus for Annual EPS
projepsh = NorgateFundamentals("projepsh"); //     High Estimate
projepsl = NorgateFundamentals("projepsl"); // Low Estimate
projepsnumofest = NorgateFundamentals("projepsnumofest"); // Number of Estimates
epsactual = NorgateFundamentals("epsactual"); // Previous Actual Annual EPS
epsprevious = NorgateFundamentals("epsprevious"); // The EPS estimate that corresponds to the Previous Actual Annual EPS
epssurprise = NorgateFundamentals("epssurprise"); // Previous Annual Surprise
epssurpriseprc = NorgateFundamentals("epssurpriseprc"); // Previous Annual Surprise as a Percentage
projsalesps = NorgateFundamentals("projsalesps"); // Current Consensus for Annual Revenue Per Share
projsalesh = NorgateFundamentals("projsalesh"); // High Estimate
projsalesl = NorgateFundamentals("projsalesl"); // Low Estimate
projsalesnumofest = NorgateFundamentals("projsalesnumofest"); // Number of Estimates
price2projsales = NorgateFundamentals("price2projsales"); // Current Consensus for Price to Annual Sales Ratio
projpe = NorgateFundamentals("projpe"); // Current Consensus for Price to Annual EPS Ratio
projprofit = NorgateFundamentals("projprofit"); // Current Consensus for Profit
projprofith = NorgateFundamentals("projprofith"); // High Estimate
projprofitl = NorgateFundamentals("projprofitl"); // Low Estimate
projprofitnumofest = NorgateFundamentals("projprofitnumofest"); // Number of Estimates
projdps = NorgateFundamentals("projdps"); // Current Consensus for Annual Total Dividend Per Share
projdpsh = NorgateFundamentals("projdpsh"); // High Estimate
projdpsl = NorgateFundamentals("projdpsl"); // Low Estimate
projdpsnumofest = NorgateFundamentals("projdpsnumofest"); // Number of Estimates
projltgrowthrate = NorgateFundamentals("projltgrowthrate"); // Current Consensus for long term growth rate of EPS
 
I like the idea. But never having been a fundamentals person I wouldn't know where to begin.

I notice the Norgate website mentions that some information is updated long after market close, other information is only updated half-yearly or annually. How much of this information is relevant to you considering your average hold time? It makes logical sense that a strong company will fall less when the whole market has a slump though. But how to use that available information to set parameters for what a "strong company" is, I have no clue. But I have previously wondered if there would be an edge in subscribing to a service such as stock doctor and only taking trades that they suggest are fundamentally strong.

Perhaps the best way is the slow way? Make a list of all your best trades, and all your worst trades. Look at the Norgate fundamental data for each at time of purchase and manually try to see if there are any common attributes?
 
How much of this information is relevant to you considering your average hold time?

Good point @Lone Wolf but I think that most of us have a couple of portfolios being trading and/or SMSF hence my interest in looking at a few longer term purchases.

I was thinking that I might have to split the stocks into pools that have different filters;

- Number of shares on issue might be only relevant to the lower priced stocks that have a habit of capital raising like a FAR which has ~ 9.97B shares
- Stocks that currently don't pay a dividend should have a place in the search as when they finish the growth phase they might pay dividends
- Stocks that do pay a dividend and have been around a long time might have a number of shares on issue like CBA 1.77B shares

Maybe I need to look at each index (as grouped below) and come up with filters relevant to each.

upload_2020-9-6_12-26-46.png

Perhaps the best way is the slow way? Make a list of all your best trades, and all your worst trades. Look at the Norgate fundamental data for each at time of purchase and manually try to see if there are any common attributes?

Unfortunately this will not work for me as my trades are based on purely technical's which have little to none relevance to the Fundamental data available, and as hinted at early my small hold times really do limit the impact of the fundamental performance of the company.

@Lone Wolf thanks for your input and I will continue to have a look around and come up with some simple ideas to throw around
 
There have been many books and papers written about which fundamentals work best. The large reference by James O'Shaughnessy "What Works on Wall Street" would be a good place to start your research on fundamentals. If I remember correctly he also finds that combining price momentum with a fundamental screen improves returns of a portfolio. Of course you are in Australia and I don't know if his U.S. based research is applicable to Aussie markets

Trav for your Exploration I think a couple of columns with dates might benefits from "formatDateTime" like,
AddColumn( GetFnData("DividendPayDate"), "DividendPayDate", formatDateTime); // Payment date for the current dividend
AddColumn( GetFnData("ExDividendDate"), "ExDividendDate", formatDateTime ); // Ex-dividend date for the current dividend
 
Hi Trav,

Reminded me of one of those free seminars where they sell you for $x,xxx when I first tried to learn about the stock market in general 2 years ago. This guy (another newbie was also questioning his course on ASF back then, who I won't name in case it encourages people to buy his course - I see his email list has been taken down now) gave a talk about his system where he claims he gets a 80-90% win rate (I am aware win rate isn't everything, but that is what he was selling) with his students getting 10-15% ROI.

Anyway, at the seminar he talks about mixing both fundamental/TA to get the results. The free talk was on the fundamental criteria and to learn how to 'time' the market you had to pay for the $x,xxx course. Luckily I was a uni student then and had no monies, but as I was new I was considering to join at the time.

I don't have the full list with me, but I found some notes on a piece of paper I wrote then. May be worth trying to see if more AFL savvy people can code it up:

1. ROE > 10% p.a.
2. ROA > 5% p.a.
3. ROI > 5% p.a.
4. EPS > 0% in the past year + forecast next year

Happy to hear other ideas from other people too.

Then you'd do a filter in Amibroker being like

Cond 1 = ROE>10%
Cond 2 - ROA > 5% etc

I agree with lone wolf about knowing how long your trades would be though.

ADDIT, I also found another note I had on having filter for market cap >300M 'for added safety'. Not sure whether this is a thing? I think Nick Radge trades based on liquidity only.
 
The large reference by James O'Shaughnessy "What Works on Wall Street" would be a good place to start your research on fundamentals.

Trav for your Exploration I think a couple of columns with dates might benefits from "formatDateTime"
d
@Tuco Ramirez thanks for your response and I will check out the book.

Also the tip on the "formatDateTime" is perfect as I did notice the date format was out and didn't have a solution so thanks again.
 
ASF Team,

I really haven't progressed to far with this as I have been going in circles while looking at relative strength. I want to initially rank Sectors against an index like the S&P/ASX 200 Index (XJO)

part 1 - rank sector v index
part 2 - rank stock v sector ( still to come )

Amibroker has some great examples of Relative Strength of a stock against your preferred index eg. XJO but I have had to do a little more research in this area and I have come up with the following which I would love some feedback on, then I will look at using this code to detect momentum of a sector (rank)

I have ended up looking at 4 x weekly time frames which is probably too many but as this is very early in development and it is easy to cut out what is not required, once I (we) have what is needed.

So lets look at what I have done and hopefully it hasn't all been a waste of time. :cautious:

ASX Sectors used

GICS (Global Industry Classification Standard)

Consumer Discretionary
Consumer Staples
Energy
Financials
Health Care
Industrials
Information Technology
Materials
Real Estate
Communication Services
Utilities

Then the Rate Of Change of each sector is compared over the 4 time frames to the XJO index

upload_2020-9-7_17-51-43.png

and the code below produces an explore like the snippet below.
upload_2020-9-7_18-17-53.png

Obviously once we have the data then we can manipulate (rank) anyway we want.

Well that's enough for me in this post as if you have the same attention span that I have you would have stopped reading at ASF Team and gone straight for the code....:laugh::laugh::laugh:
Code:
SectorXJO =  Foreign("$XJO.au","C"); // ASX 200

SectorXDJ =  Foreign("$XDJ.au","C"); // Consumer Discretionary
SectorXSJ =  Foreign("$XSJ.au","C"); // Consumer Staples
SectorXEJ =  Foreign("$XEJ.au","C"); // Energy
SectorXFJ =  Foreign("$XFJ.au","C"); // Financials
SectorXHJ =  Foreign("$XHJ.au","C"); // Health Care
SectorXNJ =  Foreign("$XNJ.au","C"); // Industrials
SectorXIJ =  Foreign("$XIJ.au","C"); // Information Technology
SectorXMJ =  Foreign("$XMJ.au","C"); // Materials
SectorXRJ =  Foreign("$XRJ.au","C"); // Real Estate
SectorXTJ =  Foreign("$XTJ.au","C"); // Communication Services
SectorXUJ =  Foreign("$XUJ.au","C"); // Utilities


XDJ_XJO_4RelS = (ROC(SectorXDJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XDJ_XJO_13RelS = (ROC(SectorXDJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XDJ_XJO_26RelS = (ROC(SectorXDJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XDJ_XJO_52RelS = (ROC(SectorXDJ, 52) / ROC(SectorXJO,52));    // 52wk Relative Strengh - Sector v Index

XSJ_XJO_4RelS = (ROC(SectorXSJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XSJ_XJO_13RelS = (ROC(SectorXSJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XSJ_XJO_26RelS = (ROC(SectorXSJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XSJ_XJO_52RelS = (ROC(SectorXSJ, 52) / ROC(SectorXJO,52));    // 52wk Relative Strengh - Sector v Index

XEJ_XJO_4RelS = (ROC(SectorXEJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XEJ_XJO_13RelS = (ROC(SectorXEJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XEJ_XJO_26RelS = (ROC(SectorXEJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XEJ_XJO_52RelS = (ROC(SectorXEJ, 52) / ROC(SectorXJO,52));    // 52wk Relative Strengh - Sector v Index

XFJ_XJO_4RelS = (ROC(SectorXFJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XFJ_XJO_13RelS = (ROC(SectorXFJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XFJ_XJO_26RelS = (ROC(SectorXFJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XFJ_XJO_52RelS = (ROC(SectorXFJ, 13) / ROC(SectorXJO,13));    // 52wk Relative Strengh - Sector v Index

XHJ_XJO_4RelS = (ROC(SectorXHJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XHJ_XJO_13RelS = (ROC(SectorXHJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XHJ_XJO_26RelS = (ROC(SectorXHJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XHJ_XJO_52RelS = (ROC(SectorXHJ, 52) / ROC(SectorXJO,52));    // 52wk Relative Strengh - Sector v Index

XNJ_XJO_4RelS = (ROC(SectorXNJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XNJ_XJO_13RelS = (ROC(SectorXNJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XNJ_XJO_26RelS = (ROC(SectorXNJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XNJ_XJO_52RelS = (ROC(SectorXNJ, 52) / ROC(SectorXJO,52));    // 52wk Relative Strengh - Sector v Index

XIJ_XJO_4RelS = (ROC(SectorXIJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XIJ_XJO_13RelS = (ROC(SectorXIJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XIJ_XJO_26RelS = (ROC(SectorXIJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XIJ_XJO_52RelS = (ROC(SectorXIJ, 52) / ROC(SectorXJO,52));    // 52wk Relative Strengh - Sector v Index

XMJ_XJO_4RelS = (ROC(SectorXMJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XMJ_XJO_13RelS = (ROC(SectorXMJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XMJ_XJO_26RelS = (ROC(SectorXMJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XMJ_XJO_52RelS = (ROC(SectorXMJ, 52) / ROC(SectorXJO,52));    // 52wk Relative Strengh - Sector v Index

XRJ_XJO_4RelS = (ROC(SectorXRJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XRJ_XJO_13RelS = (ROC(SectorXRJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XRJ_XJO_26RelS = (ROC(SectorXRJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XRJ_XJO_52RelS = (ROC(SectorXRJ, 52) / ROC(SectorXJO,52));    // 52wk Relative Strengh - Sector v Index

XTJ_XJO_4RelS = (ROC(SectorXTJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XTJ_XJO_13RelS = (ROC(SectorXTJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XTJ_XJO_26RelS = (ROC(SectorXTJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XTJ_XJO_52RelS = (ROC(SectorXTJ, 52) / ROC(SectorXJO,52));    // 52wk Relative Strengh - Sector v Index

XUJ_XJO_4RelS = (ROC(SectorXUJ, 4) / ROC(SectorXJO,4));        // 4wk Relative Strengh - Sector v Index
XUJ_XJO_13RelS = (ROC(SectorXUJ, 13) / ROC(SectorXJO,13));    // 13wk Relative Strengh - Sector v Index
XUJ_XJO_26RelS = (ROC(SectorXUJ, 26) / ROC(SectorXJO,26));    // 26k Relative Strengh - Sector v Index
XUJ_XJO_52RelS = (ROC(SectorXUJ, 52) / ROC(SectorXJO,52));    // 52wk Relative Strengh - Sector v Index

if( Status( "Action" ) == actionExplore );

Filter = 1;

AddColumn(XDJ_XJO_4RelS,"4wk XDJ RelS", 1.2, colorWhite, colorDarkOliveGreen);        // Consumer Discretionary
AddColumn(XDJ_XJO_13RelS,"13wk XDJ RelS", 1.2, colorWhite, colorDarkOliveGreen);    // Consumer Discretionary
AddColumn(XDJ_XJO_26RelS,"26wk XDJ RelS", 1.2, colorWhite, colorDarkOliveGreen);    // Consumer Discretionary
AddColumn(XDJ_XJO_52RelS,"52wk XDJ RelS", 1.2, colorWhite, colorDarkOliveGreen);    // Consumer Discretionary

AddColumn(XSJ_XJO_4RelS,"4wk XSJ RelS", 1.2, colorWhite, colorDarkRed);         // Consumer Staples
AddColumn(XSJ_XJO_13RelS,"13wk XSJ RelS", 1.2, colorWhite, colorDarkRed);         // Consumer Staples
AddColumn(XSJ_XJO_26RelS,"26wk XSJ RelS", 1.2, colorWhite, colorDarkRed);         // Consumer Staples
AddColumn(XSJ_XJO_52RelS,"52wk XSJ RelS", 1.2, colorWhite, colorDarkRed);         // Consumer Staples

AddColumn(XEJ_XJO_4RelS,"4wk XEJ RelS", 1.2, colorWhite, colorDarkBlue);         // Energy
AddColumn(XEJ_XJO_13RelS,"13wk XEJ RelS", 1.2, colorWhite, colorDarkBlue);        // Energy
AddColumn(XEJ_XJO_26RelS,"26wk XEJ RelS", 1.2, colorWhite, colorDarkBlue);        // Energy
AddColumn(XEJ_XJO_52RelS,"52wk XEJ RelS", 1.2, colorWhite, colorDarkBlue);        // Energy

AddColumn(XFJ_XJO_4RelS,"4wk XFJ RelS", 1.2, colorWhite, colorBrown);            // Financials
AddColumn(XFJ_XJO_13RelS,"13wk XFJ RelS", 1.2, colorWhite, colorBrown);            // Financials
AddColumn(XFJ_XJO_26RelS,"26wk XFJ RelS", 1.2, colorWhite, colorBrown);            // Financials
AddColumn(XFJ_XJO_52RelS,"52wk XFJ RelS", 1.2, colorWhite, colorBrown);            // Financials

AddColumn(XHJ_XJO_4RelS,"4wk XHJ RelS", 1.2, colorWhite, colorDarkYellow);        // Health Care
AddColumn(XHJ_XJO_13RelS,"13wk XHJ RelS", 1.2, colorWhite, colorDarkYellow);    // Health Care
AddColumn(XHJ_XJO_26RelS,"26wk XHJ RelS", 1.2, colorWhite, colorDarkYellow);    // Health Care
AddColumn(XHJ_XJO_52RelS,"52wk XHJ RelS", 1.2, colorWhite, colorDarkYellow);    // Health Care

AddColumn(XNJ_XJO_4RelS,"4wk XNJ RelS", 1.2, colorWhite, colorDarkGrey);        // Industrials
AddColumn(XNJ_XJO_13RelS,"13wk XNJ RelS", 1.2, colorWhite, colorDarkGrey);        // Industrials
AddColumn(XNJ_XJO_26RelS,"26wk XNJ RelS", 1.2, colorWhite, colorDarkGrey);        // Industrials
AddColumn(XNJ_XJO_52RelS,"52wk XNJ RelS", 1.2, colorWhite, colorDarkGrey);        // Industrials

AddColumn(XIJ_XJO_4RelS,"4wk XIJ RelS", 1.2, colorWhite, colorCustom1);            // Information Technology
AddColumn(XIJ_XJO_13RelS,"13wk XIJ RelS", 1.2, colorWhite, colorCustom1);        // Information Technology
AddColumn(XIJ_XJO_26RelS,"26wk XIJ RelS", 1.2, colorWhite, colorCustom1);        // Information Technology
AddColumn(XIJ_XJO_52RelS,"52wk XIJ RelS", 1.2, colorWhite, colorCustom1);        // Information Technology

AddColumn(XMJ_XJO_4RelS,"4wk XMJ RelS", 1.2, colorWhite, colorDarkGreen);        // Materials
AddColumn(XMJ_XJO_13RelS,"13wk XMJ RelS", 1.2, colorWhite, colorDarkGreen);        // Materials
AddColumn(XMJ_XJO_26RelS,"26wk XMJ RelS", 1.2, colorWhite, colorDarkGreen);        // Materials
AddColumn(XMJ_XJO_52RelS,"52wk XMJ RelS", 1.2, colorWhite, colorDarkGreen);        // Materials

AddColumn(XRJ_XJO_4RelS,"4wk XRJ RelS", 1.2, colorWhite, colorViolet);            // Real Estate
AddColumn(XRJ_XJO_13RelS,"13wk XRJ RelS", 1.2, colorWhite, colorViolet);        // Real Estate
AddColumn(XRJ_XJO_26RelS,"26wk XRJ RelS", 1.2, colorWhite, colorViolet);        // Real Estate
AddColumn(XRJ_XJO_52RelS,"52wk XRJ RelS", 1.2, colorWhite, colorViolet);        // Real Estate

AddColumn(XTJ_XJO_4RelS,"4wk XTJ RelS", 1.2, colorWhite, colorOrange);            // Communication Services
AddColumn(XTJ_XJO_13RelS,"13wk XTJ RelS", 1.2, colorWhite, colorOrange);        // Communication Services
AddColumn(XTJ_XJO_26RelS,"26wk XTJ RelS", 1.2, colorWhite, colorOrange);        // Communication Services
AddColumn(XTJ_XJO_52RelS,"52wk XTJ RelS", 1.2, colorWhite, colorOrange);        // Communication Services

AddColumn(XUJ_XJO_4RelS,"4wk XUJ RelS", 1.2, colorWhite, colorSeaGreen);        // Utilities
AddColumn(XUJ_XJO_13RelS,"13wk XUJ RelS", 1.2, colorWhite, colorSeaGreen);        // Utilities
AddColumn(XUJ_XJO_26RelS,"26wk XUJ RelS", 1.2, colorWhite, colorSeaGreen);        // Utilities
AddColumn(XUJ_XJO_52RelS,"52wk XUJ RelS", 1.2, colorWhite, colorSeaGreen);        // Utilities
 
Using XMJ as an example I plotted your "4wk Relative Strength - Sector v Index" to see what it looks like.

The top chart has your 4wk relative strength in white, along with the 4wk ROC of the XMJ and XJO. The bottom chart is the relative strength of the XJO and XMJ using the first visible bar on the chart as the reference point.

upload_2020-9-10_11-26-14.png
You can see that the last movement of the XMJ_XJO_4RelS was down, despite the XJO falling while the XMJ ticked up. There are also spikes that don't look like they should be there. I can't quite pinpoint the reason, but I'd presume it's because the 4wk ROC isn't just reacting to the latest data, but also to old data falling outside the lookback window.

upload_2020-9-10_11-26-46.png
In the chart above you can see a section between Mar - Apr where the XMJ_XJO_4RelS stayed above 0 despite both XJO and XMJ falling sharply. Due to the XMJ_XJO_4RelS being a comparison between the two ROC's and they fell at the same rate.

None of this is bad as such. Just thought you might like to check that it's telling you what you expect.

Just for fun, Here is a chart of all sectors for the same period as that top chart.
upload_2020-9-10_11-35-47.png

Code so you can check that what I'm showing is correct:
Top half of chart:
Code:
// Plot of Trav's sector filter

SectorXJO =  Foreign("$XJO","C"); // ASX 200
SectorXDJ =  Foreign("$XDJ","C"); // Consumer Discretionary
SectorXSJ =  Foreign("$XSJ","C"); // Consumer Staples
SectorXEJ =  Foreign("$XEJ","C"); // Energy
SectorXFJ =  Foreign("$XFJ","C"); // Financials
SectorXHJ =  Foreign("$XHJ","C"); // Health Care
SectorXNJ =  Foreign("$XNJ","C"); // Industrials
SectorXIJ =  Foreign("$XIJ","C"); // Information Technology
SectorXMJ =  Foreign("$XMJ","C"); // Materials
SectorXRJ =  Foreign("$XRJ","C"); // Real Estate
SectorXTJ =  Foreign("$XTJ","C"); // Communication Services
SectorXUJ =  Foreign("$XUJ","C"); // Utilities

// Plot 0 level
PlotGrid( 0, colorYellow );

// Required for labels
fontsize = Param("Label font size", 10, 4, 30, 1 );
x = LastValue( BarIndex() ) + 1;
y = LastValue( ROC(SectorXMJ, 4) );

Plot(ROC(SectorXMJ, 4), "XMJ_ROC_4", 35); // 4wk ROC of XMJ
PlotTextSetFont( "XMJ", "Arial", fontsize, x, LastValue( ROC(SectorXMJ, 4) ), GetChartBkColor(), 35, -fontsize/2 ); // Label
Plot(ROC(SectorXJO,4), "XJO_ROC_4", 33); // 4wk ROC of XJO
PlotTextSetFont( "XJO", "Arial", fontsize, x, LastValue( ROC(SectorXJO, 4) ), GetChartBkColor(), 33, -fontsize/2 ); // Label

XMJ_XJO_4RelS = (ROC(SectorXMJ, 4) / ROC(SectorXJO,4)); // 4wk Relative Strengh - Sector v Index
Plot(XMJ_XJO_4RelS, "XMJ_XJO_4RelS", 55);
PlotTextSetFont( "XMJ_XJO_4RelS", "Arial", fontsize, x, LastValue(XMJ_XJO_4RelS), GetChartBkColor(), 55, -fontsize/2 ); // Label

Bottom half of chart:
Code:
_N( TickerList = ParamStr( "Tickers", "$XMJ" ) );
fontsize = Param("Label font size", 10, 4, 30, 1 );
fvb = Status( "firstvisiblebar" );

for( i = 0; ( symbol = StrExtract( Name() + "," + TickerList, i ) ) != ""; i++ )
{
    SetForeign( symbol, 1, 0 );
    fc = C;

    if( ! IsNull( fc[ 0 ] ) )
    {
        relP = 100 * ( fc - fc[ fvb ] ) / fc[ fvb ];
        Plot( relP , "\n" + symbol + " - " + FullName(), color = colorLightOrange + ( ( 2 * i ) % 15 ), styleLine );

        x = LastValue( BarIndex() ) + 1;
        y = LastValue( relP );

        PlotTextSetFont( symbol + " - " + FullName(), "Arial", fontsize, x, y, GetChartBkColor(), color, -fontsize/2 );
    }
}

PlotGrid( 0, colorYellow );
_N( Title = "{{NAME}} - Relative Performance [%]: {{VALUES}}" );

All Sectors:
Code:
_N( TickerList = ParamStr( "Tickers", "$XDJ,$XEJ,$XFJ,$XHJ,$XIJ,$XMJ,$XNJ,$XRJ,$XSJ,$XTJ,$XUJ,$XXJ" ) );
fontsize = Param("Label font size", 10, 4, 30, 1 );
fvb = Status( "firstvisiblebar" );

for( i = 0; ( symbol = StrExtract( Name() + "," + TickerList, i ) ) != ""; i++ )
{
    SetForeign( symbol, 1, 0 );
    fc = C;

    if( ! IsNull( fc[ 0 ] ) )
    {
        relP = 100 * ( fc - fc[ fvb ] ) / fc[ fvb ];
        Plot( relP , "\n" + symbol + " - " + FullName(), color = colorLightOrange + ( ( 2 * i ) % 15 ), styleLine );

        x = LastValue( BarIndex() ) + 1;
        y = LastValue( relP );

        PlotTextSetFont( symbol + " - " + FullName(), "Arial", fontsize, x, y, GetChartBkColor(), color, -fontsize/2 );
    }
}

PlotGrid( 0, colorYellow );
_N( Title = "{{NAME}} - Relative Performance [%]: {{VALUES}}" );
 
On the constituents of the sectors. I know the idea is generally that all ships rise with the tide. But it's worth remembering that the sector index may not reflect what you trade. Taking the XMJ for example, the highest weighted share accounts for 33% of the index and the to 10 shares make up 80% of it. Of the top 10 by market cap, 8 of them have a share price over $10. So if your system was filtered for stocks under $10, the movement of the XMJ is mostly dictated by stocks that aren't part of your trading universe.

The alternative would be to create your own index containing only stocks in your universe. However, the lower market cap stocks that appear in the index today might not have been in there 5 years ago so wouldn't be good for backtesting. Norgate doesn't supply historical constituents for market sectors as far as I can see.

But I guess this is largely irrelevant. If you use the full sectors and your implementation adds a positive edge to the system, then what else matters?
 
@Lone Wolf some good work there mate, and very interesting seeing the differences, which has confused me a bit, so I will have to have a look in more detail when I get back next week.

Also definitely something for me to think about on how / if to use the information once I progress a bit further with the fundamentals.
 
@Lone Wolf I would like to say again some bloody good work work there mate !

I have had a chance to have a look at the differences and as you said the way the ROC look back occurs creates a difference when you only chart the First Visible Bar as a reference point

I can't quite pinpoint the reason, but I'd presume it's because the 4wk ROC isn't just reacting to the latest data, but also to old data falling outside the lookback window.

I also like the way that you use the TickerList and looping as this does take away a lot of the repetitiveness I had so great work again, and I will have a look at incorporating this in future versions for the ASF team

I have also looked at the following calculation and it appears to be the issue which when plotted in the top chart it shows the Relative Strength correctly ( well I hope it does )

original

XMJ_XJO_4RelS = (ROC(SectorXMJ, 4, 1) / ROC(SectorXJO, 4)); // 4wk Relative Strengh - Sector v Index

modified

XMJ_XJO_4RelS = (ROC(SectorXMJ / SectorXJO, 4)); // 4wk Relative Strengh - Sector v Index

which gives the following in the top chart

1600518054167.png

I also want to thank you for the below post as well, which highlights some issues with this approach of comparing sectors to index etc. Definitely food for thought and when I get to a point of testing we might do away with the above approach but I think that it is part of learning journey.

On the constituents of the sectors. I know the idea is generally that all ships rise with the tide. But it's worth remembering that the sector index may not reflect what you trade. Taking the XMJ for example, the highest weighted share accounts for 33% of the index and the to 10 shares make up 80% of it. Of the top 10 by market cap, 8 of them have a share price over $10. So if your system was filtered for stocks under $10, the movement of the XMJ is mostly dictated by stocks that aren't part of your trading universe.

Cheers
 
I have taken a little detour from the ranking sector issue ( but the following will help as well when I get it sorted as each piece of the puzzle will be joined at the end )

So now I am looking at ranking some fundamental data and would like your opinion of the following

I am using 4 x common data points in this example

1. Price To Sales Ratio​
2. P/E Ratio​
3. Price To Book Ratio​
4. Price To Cash Flow Ratio​

and I was wondering what weighting if any would you put on any particular data point?

In the below exploration example I have been able to rank each data point so only the lowest 50 in each category are kept then sorted as shown. I am thinking that once the ranking is completed and sorted in the preferred order then you would look at each company in order from top to bottom.

1600559044114.png

In this example I started with the XAO (501 Stocks) and ranked as described above which left me with 60 Stocks, add in the sector strength, and other valuable information then you would have a manageable list.

Thoughts?
 
OK for those interested have a look at the following and offer your opinions up

Weekly / All Ordinaries

1600572166640.png

Code:
/*
Fundamental Screener Using Norgate Data

Stocks in selected watchlist are scanned and ranks generated for 4 x parameters

1. Price To Sales Ratio
2. P/E Ratio
3. Price To Book Ratio
4. Price To Cash Flow Ratio

The lowest 50 in each category selected

Relative strenth of

1. Stock v's Sector
2. Sector v's XJO over 4wk period

calculated and sorted in exploration

*/


#include_once <..\Norgate Data\Norgate Data Functions.afl>;

wlnumber  = GetOption( "FilterIncludeWatchlist" );
SymbolList = CategoryGetSymbols( categoryWatchlist, wlnumber );
NumberOfTickers = StrCount( SymbolList, "," ) + 1;

Ranking = 50; // Lowest 50 Values

if( Status( "stocknum" ) == 0 )
{
    StaticVarRemove( "PriceToSales*" );

    for( i = 0; ( Symbol = StrExtract( SymbolList, i ) ) != ""; i++ )
    {
        SetForeign( Symbol );
        PTS = NorgateFundamentals("ttmpr2rev"); // Price to Sales Ratio
        PE = NorgateFundamentals("peexclxor"); // Price to Earnings Ratio
        PB = NorgateFundamentals("price2bk"); // Price to Book Ratio
        PCF = NorgateFundamentals("ttmprcfps"); // Price to Cash Flow Ration
        RestorePriceArrays();
        StaticVarSet( "PriceToSales" + Symbol, PTS );
        StaticVarSet( "P/E_Ratio" + Symbol, PE );
        StaticVarSet( "Price_Book" + Symbol, PB );
        StaticVarSet( "Price_To_Cash" + Symbol, PCF );
    }

    StaticVarGenerateRanks(  "PTSrank", "PriceToSales", 0, 1224 );
    StaticVarGenerateRanks(  "PErank", "P/E_Ratio", 0, 1224 );
    StaticVarGenerateRanks(  "PBrank", "Price_Book", 0, 1224 );
    StaticVarGenerateRanks(  "PTCFrank", "Price_To_Cash", 0, 1224 );
}

Symbol = Name();

PTSValues = StaticVarGet( "PriceToSales"  + Symbol);
PTSRankValues = StaticVarGet( "PTSrankPriceToSales" + Name() );
PTSPercentileRank = 100 * ( NumberOfTickers - PTSRankValues ) / ( NumberOfTickers - 1 );

PEValues = StaticVarGet( "P/E_Ratio"  + Symbol);
PERankValues = StaticVarGet( "PErankP/E_Ratio" + Name() );
PEPercentileRank = 100 * ( NumberOfTickers - PERankValues ) / ( NumberOfTickers - 1 );

PBValues = StaticVarGet( "Price_Book"  + Symbol);
PBRankValues = StaticVarGet( "PBrankPrice_Book" + Name() );
PBPercentileRank = 100 * ( NumberOfTickers - PBRankValues ) / ( NumberOfTickers - 1 );

PTCValues = StaticVarGet( "Price_To_Cash"  + Symbol);
PTCRankValues = StaticVarGet( "PTCFrankPrice_To_Cash" + Name() );
PTCPercentileRank = 100 * ( NumberOfTickers - PTCRankValues ) / ( NumberOfTickers - 1 );

// now use cutoff to manipulate the "Score"
PTS_Score = IIf( PTSPercentileRank < Ranking, PTSValues, 0 );
PE_Score = IIf( PEPercentileRank < Ranking, PEValues, 0 );
PB_Score = IIf( PBPercentileRank < Ranking, PBValues, 0 );
PTC_Score = IIf( PTCPercentileRank < Ranking, PTCValues, 0 );

// Liquidity Cutoff
Liquidity                 = C * V;
LiqMinValue             = 200000;
Liqfactor                 = Liquidity > LiqMinValue;

// Sector Relative Strength

NorgateIndex = ParamStr( "Index Code", "$XJO.au" );
IndexImported = Foreign( NorgateIndex, "C" );

IndexSymbolCorresponding = NorgateIndustryIndexCorresponding("$XJO.au",1,"PR");
SectorIndexImported      = Foreign(IndexSymbolCorresponding + ".au", "C");

XJO_4RelS = (ROC(Foreign( indexsymbolcorresponding, "C" ) / IndexImported, 4));        // 4wk Relative Strength - Sector v Index
//XJO_13RelS = (ROC(Foreign( indexsymbolcorresponding, "C" ) / IndexImported, 13));    // 13wk Relative Strength - Sector v Index
//XJO_26RelS = (ROC(Foreign( indexsymbolcorresponding, "C" ) / IndexImported, 26));    // 26k Relative Strength - Sector v Index
//XJO_52RelS = (ROC(Foreign( indexsymbolcorresponding, "C" ) / IndexImported, 52));    // 52wk Relative Strength - Sector v Index

// Exploration //

Filter = XJO_4RelS>0 AND PTS_Score>0 AND PE_Score>0 AND PB_Score>0 AND PTC_Score>0 AND Liqfactor;

SetSortColumns( -3, -4, -5, -6, -7, -8 );

AddColumn( RelStrength(indexsymbolcorresponding), "Stock v Index RelS");

AddColumn(XJO_4RelS,"4wk Sector RelS", 1.2, colorDefault, colorDefault);

AddColumn( PTS_Score, "PriceToSales", 1.2, colorDefault, colorDefault, 110 );
AddColumn( PB_Score, "Price_Book", 1.2, colorDefault, colorDefault, 110 );
AddColumn( PTC_Score, "Price_To_Cash", 1.2, colorDefault, colorDefault, 120 );
AddColumn( PE_Score, "P/E_Ratio", 1.2, colorDefault, colorDefault, 100 );

AddColumn( NorgateFundamentals("mktcap"), "Market Cap $", 1, colorDefault, colorDefault, 100); // Market capitalization, includes all classes of securities/listings
AddColumn( NorgateFundamentals("ttmrev"), "Revenue $", 1, colorDefault, colorDefault,80);
AddColumn( NorgateFundamentals("vdes_ttm"), "EPS $", 1.2, colorDefault, colorDefault,60 ); // Earnings per Share (EPS), Normalized, Excluding Extraordinary Items, Avg. Diluted Shares Outstanding
AddColumn( NorgateFundamentals("beta"), "Beta", 1.2, colorDefault, colorDefault,60); // Beta, compared to major market index
AddColumn( NorgateFundamentals("ttmdivshr"), "Div $", 1.2, colorDefault, colorDefault,60); // Ordinary Dividends per Share (unadjusted), calculated by Norgate Data
AddColumn( NorgateFundamentals("divyield_curttm"), "Div Yield %", 1.2, colorDefault, colorDefault, 110  ); // Current Dividend Yield, trailing 12 months, calculated by Norgate Data
AddColumn( ROC(C,52), "1 Year Return %", 1.2, colorDefault, colorDefault);

AddTextColumn( indexsymbolcorresponding, "Norgate Sector");

//AddColumn(XJO_13RelS,"13wk RelS", 1.2, colorDefault, colorDefault);    // 
//AddColumn(XJO_26RelS,"26wk RelS", 1.2, colorDefault, colorDefault);    // 
//AddColumn(XJO_52RelS,"52wk RelS", 1.2, colorDefault, colorDefault);    //
 
I also like the way that you use the TickerList and looping as this does take away a lot of the repetitiveness I had so great work again, and I will have a look at incorporating this in future versions for the ASF team

Thanks Trav. But before our angry friend comes back, I should say that the code I posted is just a slightly modified copy of what's on the Amibroker knowledge base.
 
I was Just chatting with another member and I found an error in the above code.

this line is incorrect as it actually compare the stock to the sector not index as described

AddColumn( RelStrength(indexsymbolcorresponding), "Stock v Index RelS");​

The below lines show the difference

AddColumn( RelStrength(indexsymbolcorresponding), "Stock v Sector RelS", 1.3, colorDefault, colorDefault, 145); // Compares stock to relevant Sector​
AddColumn( RelStrength("$XJO.au"), "Stock v Index RelS", 1.3, colorDefault, colorDefault, 140); // Compares stock to Index​
 
Hi Trav,

Reminded me of one of those free seminars where they sell you for $x,xxx when I first tried to learn about the stock market in general 2 years ago. This guy (another newbie was also questioning his course on ASF back then, who I won't name in case it encourages people to buy his course - I see his email list has been taken down now) gave a talk about his system where he claims he gets a 80-90% win rate (I am aware win rate isn't everything, but that is what he was selling) with his students getting 10-15% ROI.

Anyway, at the seminar he talks about mixing both fundamental/TA to get the results. The free talk was on the fundamental criteria and to learn how to 'time' the market you had to pay for the $x,xxx course. Luckily I was a uni student then and had no monies, but as I was new I was considering to join at the time.

I don't have the full list with me, but I found some notes on a piece of paper I wrote then. May be worth trying to see if more AFL savvy people can code it up:

1. ROE > 10% p.a.
2. ROA > 5% p.a.
3. ROI > 5% p.a.
4. EPS > 0% in the past year + forecast next year

Happy to hear other ideas from other people too.

Then you'd do a filter in Amibroker being like

Cond 1 = ROE>10%
Cond 2 - ROA > 5% etc

I agree with lone wolf about knowing how long your trades would be though.

ADDIT, I also found another note I had on having filter for market cap >300M 'for added safety'. Not sure whether this is a thing? I think Nick Radge trades based on liquidity only.
try ROE > 20%; Debt to Equity < 0% (companies with cash in the bank survive); low yield < 2% low payouts mean the company reinvests its profits and therefore grows; Mkt cap > 300million for liquidity. I haven't managed to code it on Amibroker yet but a friend ran it on Stockdoctor with ASX300 stocks only and for the past year it returned 20% better than the market. I was impressed with the results and the companies it threw up.
 
try ROE > 20%; Debt to Equity < 0% (companies with cash in the bank survive); low yield < 2% low payouts mean the company reinvests its profits and therefore grows; Mkt cap > 300million for liquidity. I haven't managed to code it on Amibroker yet but a friend ran it on Stockdoctor with ASX300 stocks only and for the past year it returned 20% better than the market. I was impressed with the results and the companies it threw up.
 
Top