Sunday, January 31, 2016

thinkscript included: master beta - with sdi_betalabel

just a quickie - beta in a chart label - and an organizational idea. here's the pic:
SPY with sdi_betalabel in subgraph.
beta tells you how much an equity typically moves relative to the market. a beta of one says that spy typically moves the same amount as the market (one would hope!) beta's between 1 and 2 are elevated and beta's above 2 are high. beta can be below 1 for slow and steady movers or even negative, typically seen for inverse etf's.

the organizational idea is to place all these good-to-have labels in a separate subgraph to reduce label-bloat in the main price graph. just drag and drop the study from the edit studies (beaker icon in chart tab) dialog:

here's the code: (how to install)

Sunday, January 24, 2016

thinkscript included: sdi_linregchan - a custom linear regression channel

this script encapsulates the results of my investigations of the various linear regression channel studies available on tos and expresses my personal preferences for display. here is the picture:
sdi_linregchan for SPY
there's a lot of information here so i gots some 'splaining to do:

first of all, the gray center line in long dashes is the standard linear regression for the most recent 32 (default) closes. a linear regression is the best-fit straight line through a set of data. by 'best-fit' it is meant that the differences (or variances) between the close prices of the candles and the center line are mathematically minimal across the data set. 32 closes is my default for this study because that is about a half of a 'quarter' on the time-aggregation of day.

the next lines out from the center line in gray, medium-dashes are 1.281 (default) multiples of a standard error from the center-line. standard error is the proper statistical measure of data dispersion to use when constructing channels because it is calculated from variances from the linear regression line. a channel that is 1 standard error away from the center line encloses 68% of the data. as a trader, i didn't think that price moving to 1 standard error from the center line was a particularly interesting opportunity. interesting opportunities occur, in trader-think, when an 80% variance from the norm occurs. so the rationale for using 1.281 is that, statistically, a channel that is 1.281 standard errors wide around the center line encloses 80% of the data.

the third set of lines out from the center line in gray, short-dashes are 2 standard errors out from the center line and enclose 95% of the 32 data points. in a sample of this size there is typically one, or less, close outside of a 2se channel. 

the fourth set of lines out from the center line in solid gray are aligned with the close that is maxv (maximally variant) from the center line. the maxv channel is what you will get with the tos study called linearRegCh100, although they don't say that explicitly in their documentation. in my study, the candle of the maxv is highlighted in lime and its standard error multiple is displayed in the chart bubble. 

maxv's typically hang-out close to the 2se level but sometimes go way outside. so the study will display a fifth set of lines in gray dots should the maxv exceed 3 standard errors.

the lrs label displays the slope of the linear regression line. so, -.68, says that the linear regression line is losing 68 cents per day (candle.) the vv^ in parenthesis is the tick-trend of the slope. this says that over the last 4 candles the slope decreased from 3 days-back to 2 days-back and from 2 days-back to 1 day-back but increased from 1 day-back to the current candle.

the se label displays how big, in percent, a standard error is wrt to the end-point of the center line along with a tick-trend.

and finally, the maxv label displays how big, in percent, the end-point of the upper maxv channel is wrt to the end-point of the center-line.

here's the code: (how to install)

Tuesday, January 19, 2016

thinkscript included: sdi_csl_label - core sector list metrics in a color coded label

being a fan of shadow trader, i have come to see that their core sector list is an important indicator of the mood of the market. however, this is a part of brad's broadcast where we hear him going to the market-watch tab and mouthing the up/down count on 23 active symbols ($bkx hasn't been updated since 3/27/2015.) i just thought that it might be more convenient to put that in a chart label. then, i thought, why not color code the label like a mood ring. there's 23 active symbols in the list so that makes it easy to break the count into 4 sections. an up count of 18-23 is strongly bullish (default bright green), 14-17 is somewhat bullish (dark green), 10-13 is neutral (orange), 6-9 is somewhat bearish(dark red), 0-5 is strongly bearish (bright red) .

so that's what i've done. here's how this looks today:

here's the code: (how to install)

Monday, January 18, 2016

aispy follow-up

one of my reader's asked me to follow-up on aispy, some 2 years after the release. so here's what this looks like today:

there's a $1400 loss vs. a $238 gain on a buy 'n hold. what went wrong? ai spy is a 'tuned' system. that is, it searched for settings that produced good results in a backtest. so if the forward test era was something like the backtest era we would have seen positive results. it is unreasonable to think that the market would maintain a correlation to any particular time period, thus, a drift in results is to be expected. i had no delusions that the market would stay in-tune with the backtest era. however, it's not unreasonable to think that maybe a small period of time following the backtest era might be positive and to be sure, if you scan back in the p&l subgraph there is some green on the screen. not much, though. also, since it is compute intensive to tune aispy (it takes a weekend of computing just for one ticker!) i have pretty much let this fall to the wayside.

the learning experience i had from programming an ai system was invaluable. what ai does is to cast your 'problem' into a vast solution space and then hunt for solutions that are acceptable or just better than what was previously achievable by pure reasoning alone. if these 'better' solutions abound in your solution space then the ai process will find them quickly. if not, then not. however, i don't think the ai 'knows' anything. that would require human beings to program the network weightings to somehow gravitate to special classes of solutions but then would those solutions be better than what could be achieved by pure reasoning?