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)



################################
# sdi_csl_label
script u{ input sym="SPY"; plot x=close(sym)>close(sym)[1];}
#hint: Displays color coded label with the core sector list up/down count rev: 1.0.0 http://www.smallDogInvestor.com 
script d{ input sym="SPY"; plot x=close(sym)<close(sym)[1];}
# author: allen everhart
def upCnt=0
# date: 18jan2016
#+u("$BKX")
+u("$DJSINS")
# copylefts reserved. This is free software. That means you are free
+u("$DJT")
# to use or modify it for your own usage but not for resale or reprinting. 
+u("$DJUSCA")
# Help me get the word out about my blog by keeping notices of origin in place.

+u("$DJUSCL")
+u("$DJUSHB")
+u("$DJUSHC")
+u("$DJUSNS")
+u("$DJUSRE")
+u("$DJUSRR")
+u("$DJUSRT")
+u("$DJUSSW")
+u("BTK")
+u("CEX")
+u("DRG")
+u("OSX")
+u("SOX")
+u("TOB")
+u("UTY")
+u("XAL")
+u("XBD")
+u("XNG")
+u("XOI")
+u("XTC")
;
def dnCnt=0
#+d("$BKX")
+d("$DJSINS")
+d("$DJT")
+d("$DJUSCA")
+d("$DJUSCL")
+d("$DJUSHB")
+d("$DJUSHC")
+d("$DJUSNS")
+d("$DJUSRE")
+d("$DJUSRR")
+d("$DJUSRT")
+d("$DJUSSW")
+d("BTK")
+d("CEX")
+d("DRG")
+d("OSX")
+d("SOX")
+d("TOB")
+d("UTY")
+d("XAL")
+d("XBD")
+d("XNG")
+d("XOI")
+d("XTC")
;
plot colorChoice=double.nan;
# author: allen everhart
colorchoice.sethiding();
#source http://www.smallDogInvestor.com 
colorchoice.hidetitle();
colorchoice.defineColor("strongly bullish", color.gREEN);
colorchoice.defineColor("bullish", color.UPTICK);
colorchoice.defineColor("neutral", color.oRANGE);
colorchoice.defineColor("bearish", color.DOWNTICK);
colorchoice.defineColor("strongly bearish", color.RED);

addlabel(1, "CSL:+"+upCnt+"/-"+dnCnt, 
    if upCnt>17 then colorchoice.color("strongly bullish")
    else if upCnt>13 then colorchoice.color("bullish")
# copylefts reserved. This is free software. That means you are free
    else if upCnt>9 then colorchoice.color("neutral")
# to use or modify it for your own usage but not for resale or reprinting. 
    else if upCnt>5 then colorchoice.color("bearish")
# Help me get the word out about my blog by keeping notices of origin in place.
    else colorchoice.color("strongly bearish")

);

2 comments:

  1. Glad to see the Blog active again.

    Did this code post properly on the webpage...as in header, etc.?

    Finally, I think that this conference might be close to your area ~ NYC?

    Quantcon.com

    ReplyDelete
    Replies
    1. Yes. The code functions correctly and is displayed as intended.
      I'll look into the conference.

      Delete