Adding a moving average to existing indicator |
Post Reply | Page <12345> |
Author | |
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 30 Aug 2009 at 5:57pm |
Thanks Jazza,
I wasn't convinced the A/D index using 200 stocks was giving me effective signals as to market direction, so over the weekend I reasoned that using the top 50 stocks should give a better indication of where most of the buying is. This new indicator does appear to have produced very good signals for the past several months. No good though if you look further back than this because the stocks in the index change over time, so best to keep it updated.
[description="Advance - Decline Issues. Represents the number of stocks rising versus the number of stocks falling in the index, Max"] n := input("Period",5,1);{ Index Composition for ASX20 } S001:= "AMP"; S002:="ANZ"; S003:="BHP"; S004:="BXB"; S005:="CBA";S006:= "CSL"; S007:="FGL"; S008:="MQG"; S009:="NAB"; S010:="NCM";S011:= "ORG"; S012:="QBE"; S013:="RIO"; S014:="SUN"; S015:="TLS";S016:= "WBC"; S017:="WDC"; S018:="WES"; S019:="WOW"; S020:="WPL";{ Index Composition for remaining ASX50 } S021:= "AGK"; S022:="AMC"; S023:="ASX"; S024:="AXA"; S025:="BSL";S026:= "CCL"; S027:="CFX"; S028:="CWN"; S029:="FMG"; S030:="GPT";S031:= "IAG"; S032:="IPL"; S033:="LEI"; S034:="LGL"; S035:="LLC";S036:= "MAP"; S037:="MIG"; S038:="NWS"; S039:="ORI"; S040:="OSH";S041:= "OST"; S042:="QAN"; S043:="SGP"; S044:="SHL"; S045:="STO";S046:= "TAH"; S047:="TCL"; S048:="TEL"; S049:="TOL"; S050:="WOR";{ Advancing Issues } a001 := If(LoadSymbol(S001,C) >= LoadSymbol(S001,ref(C,-1)),1,0);a002 := If(LoadSymbol(S002,C) > LoadSymbol(S002,ref(C,-1)),1,0);a003 := If(LoadSymbol(S003,C) >= LoadSymbol(S003,ref(C,-1)),1,0);a004 := If(LoadSymbol(S004,C) > LoadSymbol(S004,ref(C,-1)),1,0);a005 := If(LoadSymbol(S005,C) >= LoadSymbol(S005,ref(C,-1)),1,0);a006 := If(LoadSymbol(S006,C) > LoadSymbol(S006,ref(C,-1)),1,0);a007 := If(LoadSymbol(S007,C) >= LoadSymbol(S007,ref(C,-1)),1,0);a008 := If(LoadSymbol(S008,C) > LoadSymbol(S008,ref(C,-1)),1,0);a009 := If(LoadSymbol(S009,C) >= LoadSymbol(S009,ref(C,-1)),1,0);a010 := If(LoadSymbol(S010,C) > LoadSymbol(S010,ref(C,-1)),1,0);a011 := If(LoadSymbol(S011,C) >= LoadSymbol(S011,ref(C,-1)),1,0);a012 := If(LoadSymbol(S012,C) > LoadSymbol(S012,ref(C,-1)),1,0);a013 := If(LoadSymbol(S013,C) >= LoadSymbol(S013,ref(C,-1)),1,0);a014 := If(LoadSymbol(S014,C) > LoadSymbol(S014,ref(C,-1)),1,0);a015 := If(LoadSymbol(S015,C) >= LoadSymbol(S015,ref(C,-1)),1,0);a016 := If(LoadSymbol(S016,C) > LoadSymbol(S016,ref(C,-1)),1,0);a017 := If(LoadSymbol(S017,C) >= LoadSymbol(S017,ref(C,-1)),1,0);a018 := If(LoadSymbol(S018,C) > LoadSymbol(S018,ref(C,-1)),1,0);a019 := If(LoadSymbol(S019,C) >= LoadSymbol(S019,ref(C,-1)),1,0);a020 := If(LoadSymbol(S020,C) > LoadSymbol(S020,ref(C,-1)),1,0);a021 := If(LoadSymbol(S021,C) >= LoadSymbol(S021,ref(C,-1)),1,0);a022 := If(LoadSymbol(S022,C) > LoadSymbol(S022,ref(C,-1)),1,0);a023 := If(LoadSymbol(S023,C) >= LoadSymbol(S023,ref(C,-1)),1,0);a024 := If(LoadSymbol(S024,C) > LoadSymbol(S024,ref(C,-1)),1,0);a025 := If(LoadSymbol(S025,C) >= LoadSymbol(S025,ref(C,-1)),1,0);a026 := If(LoadSymbol(S026,C) > LoadSymbol(S026,ref(C,-1)),1,0);a027 := If(LoadSymbol(S027,C) >= LoadSymbol(S027,ref(C,-1)),1,0);a028 := If(LoadSymbol(S028,C) > LoadSymbol(S028,ref(C,-1)),1,0);a029 := If(LoadSymbol(S029,C) >= LoadSymbol(S029,ref(C,-1)),1,0);a030 := If(LoadSymbol(S030,C) > LoadSymbol(S030,ref(C,-1)),1,0);a031 := If(LoadSymbol(S031,C) >= LoadSymbol(S031,ref(C,-1)),1,0);a032 := If(LoadSymbol(S032,C) > LoadSymbol(S032,ref(C,-1)),1,0);a033 := If(LoadSymbol(S033,C) >= LoadSymbol(S033,ref(C,-1)),1,0);a034 := If(LoadSymbol(S034,C) > LoadSymbol(S034,ref(C,-1)),1,0);a035 := If(LoadSymbol(S035,C) >= LoadSymbol(S035,ref(C,-1)),1,0);a036 := If(LoadSymbol(S036,C) > LoadSymbol(S036,ref(C,-1)),1,0);a037 := If(LoadSymbol(S037,C) >= LoadSymbol(S037,ref(C,-1)),1,0);a038 := If(LoadSymbol(S038,C) > LoadSymbol(S038,ref(C,-1)),1,0);a039 := If(LoadSymbol(S039,C) >= LoadSymbol(S039,ref(C,-1)),1,0);a040 := If(LoadSymbol(S040,C) > LoadSymbol(S040,ref(C,-1)),1,0);a041 := If(LoadSymbol(S041,C) >= LoadSymbol(S041,ref(C,-1)),1,0);a042 := If(LoadSymbol(S042,C) > LoadSymbol(S042,ref(C,-1)),1,0);a043 := If(LoadSymbol(S043,C) >= LoadSymbol(S043,ref(C,-1)),1,0);a044 := If(LoadSymbol(S044,C) > LoadSymbol(S044,ref(C,-1)),1,0);a045 := If(LoadSymbol(S045,C) >= LoadSymbol(S045,ref(C,-1)),1,0);a046 := If(LoadSymbol(S046,C) > LoadSymbol(S046,ref(C,-1)),1,0);a047 := If(LoadSymbol(S047,C) >= LoadSymbol(S047,ref(C,-1)),1,0);a048 := If(LoadSymbol(S048,C) > LoadSymbol(S048,ref(C,-1)),1,0);a049 := If(LoadSymbol(S049,C) >= LoadSymbol(S049,ref(C,-1)),1,0);a050 := If(LoadSymbol(S050,C) > LoadSymbol(S050,ref(C,-1)),1,0);[linestyle =solid; color=lime green]Adv:=(a001+a002+a003+a004+a005+a006+a007+a008+a009+a010+a011+a012+a013+a014+a015+a016+a017+a018+a019+a020+a021+a022+a023+a024+a025+a026+a027+a028+a029+a030+a031+a032+a033+a034+a035+a036+a037+a038+a039+a040+a041+a042+a043+a044+a045+a046+a047+a048+a049+a050); ma (Adv,n,E);[linestyle =solid; color=red]Dec:=(50-Adv)+12; ma (Dec,n,E);
|
|
jalna
Regular Joined: 31 Mar 2007 Posts: 95 |
Post Options Quote Reply Posted: 30 Aug 2009 at 7:57pm |
HI Maximo, Looking forward to trying this out.
When i try and close the formula builder it tells me that A formula must not contain/\ :*? or other special reserved letters. If i run the checker over it though it tells me it is a valid Bull script formula so can't work out what to do |
|
jalna
Regular Joined: 31 Mar 2007 Posts: 95 |
Post Options Quote Reply Posted: 30 Aug 2009 at 7:59pm |
oh just worked it out , they mean in the name that I gave it
|
|
jalna
Regular Joined: 31 Mar 2007 Posts: 95 |
Post Options Quote Reply Posted: 30 Aug 2009 at 8:13pm |
DO you think Maximo it would give a good signals in the first part of a new upturn because people would be buying safe stock and then after awhile when the market had run for awhile they would feel safer and start investing in midcap and more speculative stock.
Just a thought but thinking it through the top 50 would be going up anyway Edited by jalna - 30 Aug 2009 at 8:18pm |
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 30 Aug 2009 at 11:13pm |
Yes Jalna,
I can see there is some pre-emptive buying in the top50 before the rest of the market follows (shown by the green line crossing up above the red line). As the market begins to trend in a new direction then demand continues and more money is exchanged for shares until the buy cycle finishes. You can see an indication of a buy cycle ending when the green line goes beneath the red one. The lines also tend to swap over more frequently during consolidation phases. So, you could view this as a market trend filter.
Edited by maximo - 30 Aug 2009 at 11:13pm |
|
jalna
Regular Joined: 31 Mar 2007 Posts: 95 |
Post Options Quote Reply Posted: 31 Aug 2009 at 8:04am |
Thanks Maximo, it does look encouraging. Clearer signals than the 10MA 200 too.
Thanks for sharing Where do you find out the info as to when the Indices are changed . Is it done annually only ? |
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 31 Aug 2009 at 3:40pm |
I just look at the index listing in bullcharts every month as it is updated automatically :)
You can compare that list with the list in the code and make any necessary changes.
You can also see what changes have been made and on what date at:
The changes appear to be made from the end of the 3rd week onwards of any month, but usally less frequently like every 3 months.
Edited by maximo - 01 Sep 2009 at 4:07pm |
|
jhubbard
Newbie Joined: 17 Sep 2009 Location: Sydney Posts: 10 |
Post Options Quote Reply Posted: 23 Sep 2009 at 5:40pm |
Hi Maximo,
Would it be possible to write a scan that would only look at stocks that appeared in the top 3 sectors as defined by your universal relative strength comparison? Thanks, Jeremy. |
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 24 Sep 2009 at 12:22am |
Hi JH and welcome to the Forum. Using the scan properties, 3. Securities Tab, you can limit any type of scan to any sector(s) or index or watchlist that you wish. Just add the 3 sectors you want to include in your scan and away your go.
BTW, I've rewritten the indicator, so it no longer uses a moving average which smoothed it, but also caused it to lag. Rate Of Change by itself is more responsive. I think you will find good stocks are distributed throughout most sectors and not limited to the top 3.
Just as a side note. Try changing the period to 200 and have a look at where the major divergences in the sectors are. That could be an indication of something... Also, Materials and Infotech are at the top. Meaning they have risen more than anything in the last several months and that can be varified by the top movers in the ASX300.
Cheers!
[description ="Universal Relative Strength Comparison, Max"]symb := inputsymbol("ASX 300", "XKO");period:= input("period",300,1);start:= barnumber > lastvalue(barnumber) - 600;sec1 := inputsymbol("Energy", "XEJ");sec2 := inputsymbol("Materials", "XMJ");sec3 := inputsymbol("Industrials", "XNJ");sec4 := inputsymbol("Consumer Discretionary", "XDJ");sec5 := inputsymbol("Consumer Staples", "XSJ");sec6 := inputsymbol("Health Care", "XHJ");sec7 := inputsymbol("Financials", "XFJ");sec8 := inputsymbol("Information Technology", "XIJ");sec9 := inputsymbol("Telecommunications", "XTJ");secA := inputsymbol("Utilities", "XUJ");index:= LoadSymbol(symb,C);sector1:= LoadSymbol(sec1,C);sector2:= LoadSymbol(sec2,C);sector3:= LoadSymbol(sec3,C);sector4:= LoadSymbol(sec4,C);sector5:= LoadSymbol(sec5,C);sector6:= LoadSymbol(sec6,C);sector7:= LoadSymbol(sec7,C);sector8:= LoadSymbol(sec8,C);sector9:= LoadSymbol(sec9,C);sectorA:= LoadSymbol(secA,C);[color =red; width=2]if (start,ROC(sector1,period,%) - ROC(index,period,%),prev);[color =coral]if (start,ROC(sector2,period,%) - ROC(index,period,%),prev);[color =violet]if (start,ROC(sector3,period,%) - ROC(index,period,%),prev);[color =gold]if (start,ROC(sector4,period,%) - ROC(index,period,%),prev);[color =olive]if (start,ROC(sector5,period,%) - ROC(index,period,%),prev);[color =lawn green]if (start,ROC(sector6,period,%) - ROC(index,period,%),prev);[color =Teal]if (start,ROC(sector7,period,%) - ROC(index,period,%),prev);[color =Turquoise]if (start,ROC(sector8,period,%) - ROC(index,period,%),prev);[color =Slate Blue]if (start,ROC(sector9,period,%) - ROC(index,period,%),prev);[color =Blue]if (start,ROC(sectorA,period,%) - ROC(index,period,%),prev);Edited by maximo - 24 Sep 2009 at 12:42am |
|
jalna
Regular Joined: 31 Mar 2007 Posts: 95 |
Post Options Quote Reply Posted: 24 Sep 2009 at 7:16am |
Hi Maximo, Could we add REITS. It would be interesting to watch them. Would I need to make them sector B
|
|
Post Reply | Page <12345> |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |