Sunday, February 15, 2015

my comp - display labeled comparison plots (thinkscript included)

thinkorswim has a native comparison study that you can apply to a chart. this plots the performance of an comparison equity to the charted equity. the method employed is to re-origin the comparison product to the closing price on the first bar of the charted equity and then apply the percentage moves of the comparison product to the comparison plot. when you get a lot of comparison equities on a chart it looks like this:
SPY with sector etf comparisons.
spaghetti! and it takes some forensics to figure out which product is which colored line. 

sdi_comp plots the same comparison line but adds a bubble at the endpoint of each comparison plot to identify the ticker. also, a chart label is displayed at the top in the same color as the comparison line. here's how this looks:
SPY compared to sector etf performance using sdi_comp
ok, still spaghetti but it should be a little easier to figure out what's what. you should at least be able to see what the two extreme sector etfs are: xly the leader and xle the laggard. 

in the theory of sector rotation xly, the consumer descretionary sector etf, is typically a beneficiary of the late stages of an economic contraction cycle while xle, the energy sector etf, is typically prominent in the late stages of an economic expansion. iyt, the transportation etf, is a beneficiary of the early stages of economic expansion and it is clearly lagging a little bit. so this array of sector performance would seem to indicate the economy is in the late stages of an economic contraction soon to begin an expansion phase ... in theory.

here's the code: