Login Page - Create Account

Support Board

Date/Time: Tue, 23 Jan 2018 16:14:51 +0000

Post From: Offering To The Community: Custom Stock Index Creator

[2016-03-08 12:50:29]
bjohnson777 (Brett Johnson) - Posts: 204
This is the latest addition to my tool kit. I'll add it to my consolidation DLL probably sometime next week if no problems show up in the wild.

From the "Display Study Documentation" button:

Custom Stock Index Creator. This program takes a list of stocks and creates a custom index from them. (Slow loading charts may not draw the index line correctly. Go into and exit settings to force a redraw.) I originally created this program for two reasons: (1) Existing sector indexes/ETF's contained far too many stocks and tended to all look like the S&P 500 index, which isn't very useful. (2) I wanted to create my own leading indicator index based on my own criteria explained below. This program is primarily intended to use daily bars, but intraday bar functionality has also been added.

The symbol list is a symbol separated by a space followed by a weight and a separating comma and then repeats. Example: sym1 1.0, sym2 1.0, sym3 0.7, sym4 0.3. A weight of 1.0 corresponds to 100%. A weight of 0.5 corresponds to 50%. If no weight is given, it will default to 100%. A malformed symbol list will have an undefined behavior. The symbol list was chosen to be a text string for ease of use, backup, and sharing. Once the graph loads, you can go back into settings and copy out a cleaned symbol list to a text editor to save as a backup or as a different version of an index you are working on. If you create an interesting index, you are encouraged to share it by copying and pasting the symbol list to a message board. If someone else posts an interesting symbol list, copy and paste it into the symbol list box in the settings window to see the new index.

Calculation. Normalization of each symbol is done by looking a number of bars back, finding the high and low, and converting that to a 0-100 range internally. The weight value is then multiplied against the calculated value. Each symbol is added up this way and then divided by the number of active symbols creating a kind of average. That number is then added to a large buffer number to help keep the index positive. If the symbol data does not go back as far as some of the others, it is taken out of the summation and active symbol count when its data runs out. The numbers graphed on the chart are somewhat relative and not that meaningful outside the chart. What is meaningful is the pattern the index creates. Since absolute weights are not used by internal normalization, the graph points may change slightly from day to day. This is noticeable on a 1 minute chart but less so on higher time frames.

This program will open a chart window for each symbol in the list. Sierra Chart requires an open window to get the symbol data. With a long symbol list, the number of windows will quickly become difficult to manage. It is recommended that you open a new and separate chartbook for each index you create. In the empty chartbook, first open a base symbol that you wish to compare against (I prefer the SPY ETF for the S&P 500). Add this study as a custom study. Once it runs, it will open the required number of chart windows to create the index. The extra windows can be hidden or minimized. This is recommended to reduce the CPU load for drawing graphics that won't be seen. To return to your first window, use the CW menu to find your original symbol. The new index will be on this chart and not any of the others. If a source chart window gets closed, the program will have an internal error for that symbol. To bring the window back, go back into the study settings, exit the window, and everything should be recreated. If the chart's time frame is changed, new data chart windows will be opened for each symbol in the new time frame. This can create an excessive number of windows if you're not paying attention.

General Sierra Chart Notes. For each chart, Sierra Chart will try to load as many days as in Chart Settings >> Use Number Of Days To Load. Do NOT load an excessive number of days for an intra day chart. It will create a very heavy processing load and slow down Sierra Chart. With the way the index is calculated, I could not use Sierra Chart's internal moving averages to smooth the line out. It is still easy to add one, though. Go into "Study Settings", select this study and mark it hidden, add a moving average study after this one, change "Based On" to "Custom Stock Index Creator", change "Input Data" to "Index", and change "Scale" to "Independent". The same steps can be used for my Moving Average Ribbon or Bollinger Band Ribbon. To get rid of the source graph, use the "Display As Main Price Graph" settings option. Be sure to rename the graph tab to something meaningful. From there, studies like moving averages and Bollinger Bands (even MACD) will use the index as their data sources. SAR, trend, and Fibonacci lines can also be drawn. This offers some interesting index analysis options. Studies that depend on bars and volume will not work since the index is only a line. Note that this program cannot take into account stock splits. This usually will not be a problem since either the data source or Sierra Chart will recalculate the price numbers internally.

Methodology for creating your own index. First identify the type of index you want: full market, sector, sub-sector, peer, commodity, leading, lagging, and so on. Next choose the symbols you want. This is the hard part. If you sort of know what the graph you want should look like, choose symbols with similar graphs. Choosing symbols with vastly different graphs will just muddy the index and make it useless. Choose enough symbols so that if one spikes or dips that it will not trash the index. I normally try for 10-30 symbols depending on the index type. Note that adding too many symbols doesn't always improve the graph and will just load down Sierra Chart. Finally assign a weight value to each chosen symbol.

I typically break weights up into 5 easy to remember levels: excellent 2.0, good 1.0, average 0.7, OK 0.5, and tolerable 0.3. You don't have to exactly use my given numbers, but it makes for easy use when learning and sharing. Look at the graph for each chosen symbol and write down a weight according to how good it is. If you want to compare the symbol to an existing chart, load this program with only that symbol in the list. If the graph follows what would be your ideal index path, give it a weight of 2.0 (excellent, but rarely happens). If it is reasonably close, give it 1.0 (good, most of the better charts will be at this level). If it kind of follows what you want with some strays, give it 0.7 (average). If it kind of follows but has more strays than you like, give it 0.5 (OK). Anything else that barely follows gets 0.3 (tolerable). If it doesn't follow at all, dump it for another symbol. Generally, anything below OK shouldn't be added to the index as it will not help the graph line. If you find you have a lot more symbols than you thought you would, take the highest rated symbols and leave out the rest.

For my first application, I wanted a leading market index. This is the example that is included with the default settings. These symbols were picked in early 2016 when this study was programmed. They may not be appropriate for the future based on the criteria listed above. The great thing about building your own index is that symbols can later be removed or swapped if one of them goes bad. The proper name for this index is: A leading market index in relation to the SPY (S&P 500) ETF for daily bars (template: INDEX_TYPE in relation to SYMBOL for TIME_FRAME). Naming proper relation and time period is important. An index may not work very well on a different time period.

I want symbols that generally follow SPY but move before it does in the new direction in a clean way. The leading market indicators most sites tout DO NOT do this and would perform poorly in an index. In my research, it turned out that luxury items and non-necessities dominated my list. This makes sense as when people do not have a lot of extra money to spend, these are the first items that get cut from the budget. When comparing charts to SPY, I gave preference to the following: (1) clear turn down before SPY in 2007. (2) Clean pivot up in March 2009. (3) Slow turn down in 2015 when the market went flat. (4) Failure to rise back up in the late 2015 partial recovery.

The following lists out the symbols I researched for my index. Anything below 0.3 is a symbol I do not like for this index. I left some in there as comparisons to the good symbols that can be looked up for what not to do. At the time, a few of those seemed like a good idea but later got pruned from the list. Do not be hesitant to chop if you need to.

General: xiv 1.0, wood 1.0, xlb 0.3, xle 0.7, xlu 0.3, erx 0.7, iyr 0.3, iyt 1.0, eem 0.2, pscm 1.0
Industrial Metals Related: aa 0.2, slx 0.2, jjc 0.2, cper 0.2
Shipping: fdx 0.5, ups 0.5, sea 0.3
Luxury or High Priced: lvmuy 0.1, tif 1.0, sig 0.5, pvh 1.0, vfc 1.0, lux 0.5, kors 1.0, har 0.7, pii 1.0, rl 0.5, hot 0.7, wynn 1.0, giii 1.0, cfi 0.3, mov 0.5
Vehicles: hog 1.0, cat 0.3, de 0.3
Apparel: burl 0.5, dds 1.0, jwn 1.0, kss 1.0, mw 0.3, smrt 0.7, tjx 0.2
Travel: htz 1.0, car 1.0, pcln 0.2, expe 0.2, cpa 1.0, mar 1.0
Food: bwld 0.3, cake 0.5, cbrl 0.5, cmg 0.5, dnkn 0.5, txrh 0.5 (Tend to recover early (like in 2009) but move too far. This is an interesting index on its own.)
Bonds: jnk 1.0, lqd 0.5

From my criteria above, I have too many symbols for a practical list. This is a good thing for diversification. This means I'll take the better ones and leave out the rest:
xiv 1.0, wood 1.0, iyt 1.0, pscm 1.0, tif 1.0, pvh 1.0, vfc 1.0, kors 1.0, pii 1.0, wynn 1.0, giii 1.0, hog 1.0, dds 1.0, jwn 1.0, kss 1.0, htz 1.0, car 1.0, cpa 1.0, mar 1.0, jnk 1.0, xle 0.7, erx 0.7, har 0.7, hot 0.7, smrt 0.7

When you build a list of leading indicators, do NOT try to use it to trade other leading indicators. Trade following or lagging indicators. In this example, SPY, SPXL, or SPXU could potentially be medium to long term traded from this index.

Another index option is to put together a list of the better movers for a sector or sub-sector to compare your stock against (a peer index). If the stock starts falling off early compared to the index (with or without market news), that would give a warning signal. Conspiracy theorists (who are usually right about this subject) will often note that (illegal) market insiders will start dumping a stock before there is news of a problem. A divergence from the peer index might show that problem before the news gets out.

Reading The Index. Periodically choose short, medium, and long term time frames to see how well the index is tracking on your main chart. A long term view will show overall movement. Medium to short term views will realign the index and main chart and possibly show movements that are harder to see if the index line has move too far in relation to the main chart.

Be sure to read "Input Descriptions" on the doc button for the specific settings options.

Update: 2016-12-06. Added new Minimize window function from ACSIL.
Regular compiles moved to "Brett Johnson's Standard Tool Kit" DLL.
Date Time Of Last Edit: 2016-12-07 05:39:45
attachmentCustomStockIndexCreator.cpp - Attached On 2016-12-07 05:39:28 UTC - Size: 34.64 KB - 41 views
attachmentCustomStockIndexCreator.dll - Attached On 2016-12-07 05:39:36 UTC - Size: 111.5 KB - 34 views