Login Page - Create Account

Support Board


Date/Time: Sat, 27 Apr 2024 11:42:13 +0000



[User Discussion] - Offering To The Community: Custom Stock Index Creator

View Count: 8526

[2016-03-08 12:50:29]
bjohnson777 (Brett Johnson) - Posts: 284
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. (Note: Slow loading charts may not draw the index line correctly. Go into and exit settings to force a redraw, do a Chart >> Recalculate, or CTRL-INSERT.) 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.

The volume function is enabled by default but set to not draw. This is because a study is confined to a single Chart Region and volume bars would squash the index line. To copy the volume bars to another Chart Region, use the 'Overlay (Single Line)' study with the following settings: Based On: Custom Stock Index Creator, Chart Region 2, Scale: Independent, Chart Number: this one, Input Data: VolumeIdx, Multiplier: 1, Display Zero Values: Yes; Subgraphs Tab: Yellow, Bar, Solid, 2.

The volume function has 4 modes: 1) 'Price*Volume (Weighted)' (recommended setting) multiplies Typical Price times Volume times Weight to get a uniform unit of movement across all source data charts and sums it with the other source data charts. This will show total amounts spent per bar. 2) 'Price*Volume Avg' takes 'Price*Volume (Weighted)' and divides it by the total number of active stocks. 3) 'Volume (Weighted)' multiplies the Volume times Weight and sums it with the other source data charts. 4) 'Volume (Straight)' just sums all the Volumes of the source data charts. In general, use 'Price*Volume' when building an index of many different types of symbols. Use one of the 'Volume' options when comparing different versions of the same thing (like different expiration times for a futures commodity).

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 the default). 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 intraday 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 first 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: 2022-07-10. Minor fixes to support new SC version (2411).
Regular compiles moved to "Brett Johnson's Standard Tool Kit" DLL.
Offering To The Community: Brett Johnson's Standard Tool Kit
Quick compile instructions:
Offering To The Community: Brett Johnson's Standard Tool Kit | Post: 114621
Date Time Of Last Edit: 2022-07-10 07:39:46
attachmentCustomStockIndexCreator.cpp - Attached On 2022-07-10 07:39:39 UTC - Size: 42.95 KB - 135 views
[2016-04-25 09:30:52]
bjohnson777 (Brett Johnson) - Posts: 284
Update.

I ran into a bar time alignment problem while working on my Forex Currency Decorrelation program. In theory, this program could have that, too. I ported that code over and did a little clean up.

Also note: If the index line doesn't draw correctly on the initial load, it's probably waiting for other charts to finish loading. Once done, go into settings and exit to force a redraw.
[2016-07-20 08:51:45]
bjohnson777 (Brett Johnson) - Posts: 284
Update:

I got tired of 2 stocks hanging the intraday list, so I removed them from the examples.

No other functionality changes.

Since this program can take so long to load from so many charts, remember to use Chart >> Recalculate, CTRL-INSERT, or INSERT to redraw it once everything is loaded.
[2016-10-15 06:38:37]
bjohnson777 (Brett Johnson) - Posts: 284
Today's DLL was compiled with the M$VC++ change over.
You may need to update your SC version.
Keep your previous DLL version until you've tested the new compile.
Most changes were made to shut up useless M$VC++ warnings when compiling.
There are a few compile warnings left about "argument" that can be ignored.
No real functionality changes have been made.
[2016-11-12 20:20:21]
bjohnson777 (Brett Johnson) - Posts: 284
Minor update now using the "Get Highest Chart Number In Chart Book" function simplifying the "Close All Other Charts" options in the Settings window. I also added a forced recalculate to reopen the needed data windows. Previously the other windows would not reopen like they should have.

Double check your settings window to make sure the options didn't get scrambled.
[2016-12-07 05:40:18]
bjohnson777 (Brett Johnson) - Posts: 284
Update:

Added new Minimize window function from ACSIL.
[2016-12-08 13:33:55]
User345334 - Posts: 23
hi,

i was looking for a tool to make my own index for a long time , thanks for this tool , unfortunately i'm not able to use it for some reason can you please tell me what i'm doing wrong?

i go to add custom study
then use the default setting.
and don't see nothing on the chart.

thanks.
avi.

http://www.sierrachart.com/image.php?Image=1481203760419.png
[2016-12-09 06:39:59]
bjohnson777 (Brett Johnson) - Posts: 284
Few things to check for:

Are you on the most current version of Sierra Chart? The latest update makes use of a new function in there.

Did you set to YES: "Are you ready for MANY open windows?" This study opens MANY other windows for a data source. It should be run in its own chartbook so it doesn't trash an existing one.

With all the new windows open, you might need to select your first window again from the CW menu at the top.

I normally open the daily SPY ETF as the background and then run this study with the defaults. It may take a few minutes for all the data to download for each extra chart. Once it does, you may need to hit the INS key or select Chart >> Recalculate if the white line barfs.

If you come up with an interesting custom index, please share. :-)
Date Time Of Last Edit: 2016-12-09 06:41:35
[2016-12-09 07:53:04]
User345334 - Posts: 23
thank you so much after follow your instruction it's work.
i'm sorry i'm not a coder so i don't have custom index to share.

i have some ideas about your index and i will like to ask if i can hire you to do some modification?
regards.

:-)
[2016-12-09 09:10:13]
bjohnson777 (Brett Johnson) - Posts: 284
Depends on what the modifications are. My health is really bad, and I'm behind schedule on everything. If they're simple changes, I can probably do them. If they're complicated, I may not be able. What are your ideas?
[2016-12-09 11:11:40]
User345334 - Posts: 23
first i hope your health will be good again.
this job is not urgent if you got more important things i can wait.
i can offer you 100$ (i hope this is ok) for this indicator if it possible to do.

i will try to explain what i need , i hope this will be clear.

1. the work that i need is based on the cumulative delta bar -volume study and yours index creator(but maybe there is no need for the index creator i'm not sure)
the cumulative delta bar -volume study work on 1 symbol let say a stock, i want instead of one stock to put a list of stocks like in your index creator for example:
AAPL+MSFT+FB+GOOG+INTC+CSCO+V+IBM and much more(this index is very simple just adding the values together) let call it index1 .
and then i want to subtract index1 with index2 ( index2 will be another list of stock symbols)

so i will able to see cumulative delta bar -volume study of input index1 minus index2.

2. the second modification is to change cumulative delta bar -volume study calculation , right now is tacking just the volume (number of contracts) of each trade and add to cumulative vol if the trade was on the ask or subtract if this trade
was on the bid.

i want to change it so it will tack the price of the symbol and multiply by the vol (instead of just the vol number for example aapl trade in 52.05$ and last trade was on the ask 1000 shares so i want to calculate 52.05*1000 = 52050 to add to the cumulative delta) and of course sum all symbols

that all , i can imagine that you probably have question so please ask i will do my best to answer them.

regards.

avi
[2016-12-09 11:57:36]
bjohnson777 (Brett Johnson) - Posts: 284
I'm only half following your description. I've never used the Delta Bar stuff, so I don't know what it looks like.

"Cumulative Delta Bars - Volume" is calculated by ACSIL sc.CumulativeDeltaVolume(), description here:
sc.CumulativeDeltaVolume()

This doesn't show much on how it's done.

Can you give a general description of why you want to calculate "index1 - index2" ? That might help me understand more.

I've done a bunch of volume experiments in my main DLL. Have you had a look at it?
Offering To The Community: Brett Johnson's Standard Tool Kit

With my rotating sleep schedule, it's past my bed time. I'll have another look at the study late tonight.

Are you up all night like me? Or are you over seas (relative to Texas)?
[2016-12-09 12:17:17]
User345334 - Posts: 23
hi, your night are my morning i'm from Israel.

ACSIL sc and DLL. are like chinese for me i'm not a coder,

what i'm basically want is to sum some symbols of call option let say for AAPL and call this group of calls option index 1
and then subtract with index 2 that will be put options (this way i can see if i got more call option buyers or put buyers)

this is the main idea right now i do that EOD in excel and wanted to see this in real time if possible.

thanks.

avi.
[2016-12-10 12:29:31]
bjohnson777 (Brett Johnson) - Posts: 284
I almost got to visit Israel back in 1999, but the local CheckPoint Software office stopped the tours of the home office when it became my turn. Maybe someday I can go on my own if my health gets better.

I was overloaded by another project and ran out of time today. I've also had a couple other ideas for enhancements using volume.

Adding a second list would be a lot of work right now. The alternative is to use 2 charts: one for calls, the other for puts. Sierra Chart has an overlay study to copy the values from one chart to another. I think using "Study Subgraph Multiply" by -1.0 and "Study Subgraphs Difference" will then get you a nice graph of the call/put difference.

I've got a couple other ideas to also mess with. I'll try to interleave this project with my others this week. If the world doesn't collapse on me, it will probably be closer to the end of the week before I have anything to post. If you're following this forum thread, you'll get an email notification when you do.
[2016-12-11 01:24:00]
Neo - Posts: 198
Thanks for your contributions Brett, your work is much appreciated. Some of the offerings in your toolkit have been useful to me.

I am wondering if it is possible to adapt your custom stock index so that it calculates the % of stocks in a chartbook currently trading ABOVE/BELOW their daily VWAPs. So this could be setup over a custom universal of stocks, or on a common universe eg Nasdaq100

% of stocks currently trading above VWAP is a popular metric amongst equities prop shops.

I am currently calculating this using a spreadsheet study, where a TRUE value is given to each stock if the last trade price was greater than it's daily VWAP, and then the SUM of all TRUE values is used to calculate the %. The spreadsheet study is restricted by the number of columns, so it's only really useful for looking at real-time values, and not historical values( at least not over 100 stocks)

The premise is that looking back over historical % values you could determine if there was a correlation between your signals that outputted winning/losing trades, and your custom index relative to its % ABOVE/BELOW VWAP. So % of stocks ABOVE/ BELOW VWAP could act as an alpha factor, helping to separate noise from a true signal.

If this is something you could adapt I would be willing to pay you for it.
[2016-12-12 11:28:34]
bjohnson777 (Brett Johnson) - Posts: 284
I spent a few hours today and got the volume layout in place. It's responding, but it's not behaving quite as I would have expected. I'll have to look into it further later when I get more time.

For VWAP, ACSIL in Sierra Chart can open multiple chart windows as data sources, but it cannot load studies into the newly opened charts. If the VWAP study is manually added to each newly opened chart, ACSIL can access the data, but it has to be in an EXACT location. This makes it extremely tedious and problematic to get reliable results. As odd as this may sound, your spreadsheet way is currently easier.

Sierra Chart currently doesn't know what is in index funds like the NASDAQ 100. If it supported it, Sierra Chart would have to open 100 separate data windows. That's doable, but it would be extremely heavy. Keeping the bar data on disk for all those windows would also take up a lot of space.

Eventually Sierra Chart will support some kind of multi-stock scanning ability like some of the other platforms, but it is very low on the developer's priority list. I doubt they'll even look at it within the next year. Something like that should really be done on the server side instead of the chart side. I only skim this support forum, but there have been a couple request posts about it within the past month or so.
[2016-12-12 21:48:42]
Neo - Posts: 198
Are you sure it would be difficult to accurately reference each charts price in relation to VWAP? To me it seems that the ASCIL interface would make this relatively easy, however, I've got no real experience using ASCIL, so I can't really comment!

-On each chart setup a VWAP study, add a color bar alert study using OHLC>ID1.SG1, so values (1,0) are outputted.
-Create an ASCIL study using or Referencing Study/Indicator Data in an ACSIL Function http://www.sierrachart.com/index.php?page=doc/ACSILProgrammingConcepts.html#UsingStudyData
-create input values for each potential chart( eg 100)
-Calculate the Sum of all (1,0) to get % above VWAP


FYI I have 100s of charts loaded during the day :) For a real-time calculation, you would only require the current day to be loaded on each chart, so if this works using a spreadsheet study then ASCIL should definitely handle the load ( based on 100 charts). A server side scanning feature would be awesome, however, you can currently create a decent real-time scanner using a Spreadsheet study as the frontend( the biggest limitation is the lack of conditional formatting/ column sorting)
Date Time Of Last Edit: 2016-12-13 02:58:48
[2016-12-13 08:36:41]
bjohnson777 (Brett Johnson) - Posts: 284
I'll start by apologizing... I missed an ACSIL function that's been added since I last read the doc page. This is the first thing I would need:

sc.GetStudyNameFromChart()
http://www.sierrachart.com/index.php?page=doc/ACSIL_Members_Functions.html#scGetStudyNameFromChart

There's another missing piece I'll explain in a moment.

The reason for needing sc.GetStudyNameFromChart() is that internally all studies are referenced by an ID number or index number. Any minor changes to the chart can change the ID number to something else (mentioning "EXACT location" in my previous post). That would mean that ACSIL would be accessing the wrong study and getting bad data. By getting the study name, it doesn't matter if the ID number changes. A test can be run against the name to first verify that it is correct. If not, the program can search the name list to see if it was moved or deleted from the chart. This provides a margin of safety.

The other missing piece is being able to automatically load a study (VWAP in this case) to a newly opened chart by ACSIL. I don't see any way of doing this in the documentation. To be honest, to have ACSIL try and figure out what a new study needs is insanely complicated to program... but I had an idea around that yesterday. The workaround is to have the human create a Study Collection and get all the studies tweaked to desired values. After that, ACSIL would (in theory) just apply the Study Collection to the newly opened chart. This works well for automation and guarantees that a chart doesn't get missed (like the 100 charts out of the NASDAQ 100). For someone to individually add a study to 100 charts would probably take between 2 and 4 hours. For ACSIL to do it automatically would probably take about 5 minutes.

I think I'm going to open a support request for this feature in a few minutes. This should be easy for the SC dev's to implement since most of the work has already been done in the deeper internals of SC. I don't know how long it will take them to implement this feature, though.

Once this gets implemented, it shouldn't be too hard to create a full length chart (even on multiple time scales) for the number of stocks above/below VWAP. There might be some interesting chart patterns from this.

The biggest thing slowing me down right now is my health issues. I have some vicious variant of Central Sleep Apnea where my brain forgets to breathe when I'm unconscious. I spend around 12 hours in bed hooked up to an artificial ventilator. If I'm lucky, I'm unconscious for most of that time, but my equivalent sleep compared to a normal person will be 3-4 hours per night. It's really tearing me up, and for the past several months it has been getting worse. For my next medical project/wetware hack, I'm going to use the OpenEEG project and create a brainwave interface to the computer. I'm hoping to use electrical signals to try and force my brain into deeper levels of sleep and stop the insomnia that's been plaguing me for the past several months. I've already done simpler forms of this and know it works, but I need something that is much stronger.

The past 2 nights have been bad, and I'm pretty much useless today. If the SC dev's can get the missing function programmed, it will probably be 2 months before I can sit down and program this (that might be how long the SC dev's take to get their part implemented, anyways). I'd like to expand the code so my new program's framework can be used more generically as a stock scanner (kinda what I mentioned above). In a study format, it will still be a bit clumsy to use, but it should be far easier than the spreadsheet.

And speaking of spreadsheets, I read somewhere in the docs that an external spreadsheet program could be used. Since I know C++, I've never bothered learning spreadsheets, but do you think an external spreadsheet could get around some of your current limitiations? It might be worth digging forther in the docs for.
[2016-12-13 12:42:49]
bjohnson777 (Brett Johnson) - Posts: 284
I got the quirk figured out and have uploaded a beta version for you to test. Give these instructions a try:

Open a new chartbook. Add the following studies with the following settings:

Custom Stock Index Creator: Short Name: Call Index, Chart Region: 2, Scale: Automatic, Symbol List: enter the call symbols, Volume (Straight). Subgraphs Tab: Index: Ignore. VolumeIdx: Green, Bar, Solid, 2.

Overlay (Single Line): Short Name: Call Index Line, Based On: Call Index, Chart Region 1, Scale: Independent, Chart Number: this one, Input Data: Index, Multiplier: 1, Display Zero Values: Yes. Subgraphs Tab: Green, Line, Solid, 2.

Custom Stock Index Creator: Short Name: Put Index, Chart Region: 1, Scale: Automatic, Symbol List: enter the put symbols, Volume (Straight). Subgraphs Tab: Index: Red, Line, Solid, 2. VolumeIdx: Ignore.

Study Subgraph Multiply: (singular version, not plural) Based On: Put Index, Short Name: Put Volume, Chart Region: 2, Scale Automatic, Input Data: Volume, Multiplier -1, Draw Zeros: Yes. Subgraphs Tab: Red, Bar, Solid, 2.

Study Subgraphs Add: (plural version, not singular) Short Name: Volume Difference, Chart Region 3, Scale: Automatic, Input Study 1: Call Index: Volume, Input Study 2: Put Volume: Result, Offset: 0, Draw Zeros: Yes, Perform Add With Zero Value: Yes. Subgraphs Tab: Purple, Bar, Solid, 2.

Sometimes a graph will disappear. Do Chart >> Recalculate or CTRL-INSERT. Full recalculate doesn't always restore the graph but partial will.

Results:
Main Price Graph should have green and red lines for call and put price index lines.
Second graph should have a stacked bar graph for green/call and red/put. Red lines should be negative and proportionally scaled to the green ones.
Third graph should have the difference between the green and red of the second graph.

To save all this: Analysis >> Studies >> Save Studies As Study Collection.
Enter a name like: Call-Put Index
Hit the "Save All" button.
Open a new chartbook for a different set of option symbols, select Analysis >> Call-Put Index, go into the Custom Stock Index Creator settings and enter new Symbol Lists for the new call/put symbol.

(Note that the beta version will be deleted once finished. The completed and stable version will always be attached to post 1 of this thread.)

edit: clarified instructions a little
Date Time Of Last Edit: 2018-01-31 07:09:25
[2016-12-13 18:40:51]
User345334 - Posts: 23
thanks for the new file i'm exciting to check it out , it will tack me some time to create the list of the options name, thanks again.
[2016-12-14 10:26:55]
User345334 - Posts: 23
hi, it's look like the platform can't handle so much symbols , if i use a few symbol it look like working but when i upload all the options symbol it's not show any data i'm attaching a file with call symbol for you to see.
attachmentcalls symbols.txt - Attached On 2016-12-14 10:26:38 UTC - Size: 3.2 KB - 488 views
[2016-12-15 06:28:55]
bjohnson777 (Brett Johnson) - Posts: 284
@CTZ16C10000,@CTZ16C10100,@CTZ16C10200,@CTZ16C10300,@CTZ16C10400 ...

You're going to have to help me understand what those symbols translate to. I know there's a date component to them, but that's about it.

There's a limit to the Symbol List of 2k (just over 2000 characters). If you look at your attachment, it's listed at 3.2k.

It looks like you have 271 symbols in the list. Double that for the matching Put List and you've got 542. Can your computer handle that many open symbols at one time?

You'll also need to change "Limit Number Of Open Charts" to something above 600. Make sure you're starting with a fresh chartbook so the Index Creator is on chart #1.

If you change time frames, another 542 windows will try to be opened.
[2016-12-15 07:23:00]
Neo - Posts: 198
No need to apologize, Brett, thanks for looking into this further and explaining in more detail.

The idea of automatically loading a study onto a newly open chart sounds great, however, it's over my head in terms of programming skills.

Sorry to hear about your health issues, I had some minor issues with sleep Apnea and ended up resolving them by losing a whole lot of weight. Has your doctor ever suggested Modafinil to combat daytime sleepiness? The Biofeedback stuff looks really interesting, good luck with it.

Re % of stocks in a chart book above VWAP- What do you think about this? It won't give historical values but will give values based on the last price.

#include "sierrachart.h"
#include <string>

#define MAX_ITERATIONS 10000

//This is a tentative solution to the problem of determining
//the proportion of charts in a chartbook trading above their
//respective VWAPs.

using namespace std;
SCDLLName("Proportion Trading Above/Below VWAP DLL")

SCSFExport scsf_ProportionTradingAboveVWAP(SCStudyGraphRef sc){
  SCInputRef ChartStudy = sc.Input[0];
  if (sc.SetDefaults){
    sc.GraphName = "Proportion Trading Above VWAP";    
    sc.AutoLoop = 1;     
    sc.FreeDLL = 1;
    sc.Subgraph[0].Name = "Proportion Trading Above VWAP";
    sc.Subgraph[0].PrimaryColor = RGB(255,0,0);
    return;
  }
  int num_of_charts;
  int num_trading_above_vwap = 0;
  for(num_of_charts = 1; num_of_charts < MAX_ITERATIONS; ++num_of_charts){
    SCGraphData BaseGraphData;
    ChartStudy.SetChartStudyValues(num_of_charts, 1);
    sc.GetChartBaseData(ChartStudy.GetChartNumber(), BaseGraphData);
    if(BaseGraphData[SC_HIGH].GetArraySize() == 0){
      //No more charts.
      break;
    }
    //Get the most recent trading price.
    int last_bar = BaseGraphData[SC_LAST].GetArraySize() - 1;
    float last_price = BaseGraphData[SC_LAST][last_bar];
    
    //Get the VWAP for the specified period of time.
    float cumulative_price_volume = 0.0;
    float cumulative_volume = 0.0;
    int num_of_trades = last_bar + 1;
    for(int j = 0; j < num_of_trades; ++j){
      cumulative_price_volume +=
        BaseGraphData[SC_HLC][j] * BaseGraphData[SC_VOLUME][j];
      cumulative_volume += BaseGraphData[SC_VOLUME][j];
    }
    float VWAP = cumulative_price_volume / cumulative_volume;
    if(last_price > VWAP){
      ++num_trading_above_vwap;
    }
  }
  --num_of_charts;
  float proportion_above_vwap =
    (float)num_trading_above_vwap / (float)num_of_charts;
  sc.Subgraph[0][sc.Index] = proportion_above_vwap;
}

[2016-12-15 07:27:49]
User345334 - Posts: 23
hi. the symbol name contain which futures contact his representing CT- cotton,Z- the expiry month, 16- the expiry year , C -call option, 10000 - the strike price 100.00

yes i allowed 600 symbol to open but still this don't show nothing it look like a big task to ask the platform or my computer to calculate.
[2016-12-15 07:47:08]
Neo - Posts: 198
Are you trying to load 500+ symbols at once? That is far too many.

You need to try breaking them up, eg add 50 each time

Also,

-What is the minimum amount of days you require for each chart? and how many days are you currently trying to load onto each chart?
-In data/ trade services, what is your intraday data storage time unit? If you are trying to load that many charts then make sure this is set to seconds, not ticks.
-In data/ trade services, what is your Max Historical intraday days to download? For testing purposes Set this to the minimum number of days you need to load on each chart.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account