Friday, March 28, 2014

buy now? macro perspective with dow/gold ratio

as the first quarter draws nigh and the market is flat for the year, i like to look at the macro perspective to get a grip. my favorite way to do this is to look at the dow/gold ratio:

as i see it, after the cypress rip in '13 the d/g moved into a upward channel with a higher-high and higher-low. we have now bounced at the bottom of the channel. technical analysis would have us buy this support. what do you think?

Sunday, March 16, 2014

thinkscript included: sdi_lastpps - return last pps signal - useful for multiple time-frame scans

the lastpps script returns the last buy/sell signal of the proprietary pps indicator. it returns +1 if the last pps signal was a buysignal and -1 if the last pps signal was a sellsignal. this script is intended to be used in a custom-study scan although it could be added to a watchlist as a custom column.

i find the pps indicator to be very good at getting one into a good trade early. after reading brian shannon's technical analysis using multiple timeframes (see brane fud page), though, i want to scan for stocks that are exhibiting a pps signal concurrently in multiple timeframes and the thinkorswim implementation of pps does not facilitate this because it only delivers a signal on the bar when the trigger occurs. that's good for charts but lousy for multiple timeframe scans where the signal almost never develops in the current bar on all timescales.

here's how i use sdi_lastpps in a multiple timeframe scan for bullish stocks:

just swap the greater relationship operator with less and you have a bearish scan. (note: you will need to have a funded thinkorswim account to implement a custom scan.)

here's the code, not much to it really:

################################
# sdi_lastpps: returns the last buy/sell signal of the proprietary pps indicator. it returns +1 if the last pps signal was a buysignal and -1 if the last pps signal was a sellsignal. this script is intended to be used in a custom-study scan.
#hint: returns the last buy/sell signal of the proprietary pps indicator. it returns +1 if the last pps signal was a buysignal and -1 if the last pps signal was a sellsignal. this script is intended to be used in a custom-study scan. rev: 1.0
http://www.smallDogInvestor.com
# author: allen everhart
# date: 16mar2014
# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale.
# Help me get the word out about my blog by keeping this header
# in place.

def sig=
    if(!isnan(PPS().buySignal)) then 1
    else if( !isnan(PPS().sellSignal)) then -1
    else sig[1];
plot lastSignal=sig;

################################

Friday, March 14, 2014

thinkscript included: sdi_overunder - chart label to display count of closes over/under previous high/low, resp.

a few weeks ago i blogged about the superbowl betting business. in the course of researching spread-bets i discovered that bookies offer another kind of bet called over-under. in the over-under wager you are betting on the whether the combined total scores of the two teams is over or under a number of your choosing. this is a bet on whether or not you feel the offense of both teams is stronger than the defenses, since defense does not generally score points (super bowl xlviii opening play aside!)

this over-under got me to thinking about a similar battle i see playing out on my charts between bulls and bears. what i see my fellow traders eyeballing on charts for trading opportunities is whether or not the current closing price of a stock is above the high or below the low of the previous bar. so i started thinking of the close-above-the-high as an over and the close-below-the-low as an under. then, just to get the feel of these things, i wrote a script that tracks how many of each of these have occurred recently and displays them on a chart label. here's how this looks:
spy with sdi_overunder chart label with 20 bar lookback.
what i observe is that these over/under counts are at least as good at evaluating the technical mood of the market as other professional studies and are an interesting confimation that is independent of moving averages. so when over is twice or more the under count then the market is generally bullish over the lookback period and vice-versa.

in addition, the total of over and under is an indication of the trend strength and/or volatility. if the total is less than half of the lookback period, as is the case above, then the majority of the trading days have been somewhat indecisive. this seems to indicate a weakening bullish trend in the above chart, which i think is a reasonable assessment of the current market.

maybe this is just a curiosity, i dunno. in any case here's the thinkscript so you can decide:

################################
# sdi_overUnder: Display count of closes-above-previous-bar-high (over) and count of closes-below-previous-bar-low (under) in a chart label.
#hint: Display count of closes-above-previous-bar-high (over) and count of closes-below-previous-bar-low (under) in a chart label. Chart label is color-coded to reflect bullish/neutral/bearish condition. rev: 1.0
http://www.smallDogInvestor.com
# author: allen everhart
# date: 14mar14

# copylefts reserved. This is free software. That means you are free
# to use or modify it for your own usage but not for resale.
# Help me get the word out about my blog by keeping this header
# in place.

input lookBackPeriod = 20 ;
#hint lookBackPeriod: Number of bars to evaluate. rev: 1.0
http://www.smallDogInvestor.com
def over = fold ih=0 to lookBackPeriod  with nh=0 do
    if getvalue(close,ih)> getvalue(high,ih+1) then nh+1
    else nh;

def under = fold ilo=0 to lookBackPeriod  with nlo=0 do
    if getvalue(close,ilo)< getvalue(low,ilo+1) then nlo+1
    else nlo;
plot colorChooser = double.NaN;
colorChooser.hideTitle();
colorChooser.hideBubble();
colorChooser.defineColor("Bullish", color.dark_gREEN);
colorChooser.defineColor("Neutral", color.DARK_ORANGE);
colorChooser.defineColor("Bearish", color.RED);
AddLabel(1,
  Concat(Concat(Concat("over:", over), " under:"), under),
  if ( over > under ) then colorchooser.color("Bullish")
  else if ( over == under) then colorchooser.color("Neutral")
  else Colorchooser.color("Bearish")
  );

##############################

Sunday, March 9, 2014

thinkscript included: sdi_ivp patch revision 1.31

previously sdi_ivp was using the standard thinkscript function takeValueColor to match the label color to the color of the most recent dot of the historical iv%r indicator. it appears that the operation of takeValueColor does not perform its duties reliably. unpredictably, sometimes the label color matches, sometimes it doesn't. this patch level corrects this problem by replacing the use of takeValueColor with the logic that the historical iv%r uses to establish color choice. you can obtain this patch on the original post where i maintain the most recent release.

Saturday, March 8, 2014

thinkscript included: sdi_tde release 1.2

in this release i color code the after-market earnings releases in red. here's how this looks:


dow 30 stocks with color coded tde

as always, the latest release thinkscript is maintained on the original post.

Sunday, March 2, 2014

thinkscript included: sdi_ivp release 1.3

i've opened the hood on the sdi_ivp script once again and the result is release 1.3. this time in response to several inquiries as to whether i could program a hot-tip (or powertip) for the candles that shows the value of the indicator in the past when the mouse hovers over a candle. unfortunately mouse events are not available in thinkscript. however, this got me to thinking that maybe there was a way to indicate when in the past has the ivp transitioned between high and low, one that did overly crowd a chart. so here's my solution:
sdi_ivp release 1.3 on spy
the dots running just above the chart high is this new indicator. it follows a simple red light/green light color scheme, where you can think of the green-light as go for premium selling trades.

then, as tina turner says "we never do nuthin' nice and easy," i complicated it a little. i tied the label color to the current color of the dots. maybe you want to show a midrange - there's a parameter for that. maybe you want to place the dots below the low of the chart - there's a parameter for that. maybe you don't like the choice of text for the label - there's a parameter for that. maybe you don't like the colors for high/mid/low - there's a parameter for that.

about the new default text for the label: i decided that i like this text to be "iv%r" for implied volatility percent range. this is because there is precedent for this nomenclature in the technical indicator biz e.g. williams %r, and i don't like the appellation of rank, which i think implies something completely different. a rank is the ordinal value of an item in a list e.g. class rank. i think that calling this indication a rank will eventually lead to ambiguity when people begin comparing implied volatilities between companies e.g. in the same industry. but, hey, i'm just a small dog investor so call it what you want ... there's a parameter for that.

as always i maintain the new releases for a thinkscript  on the original blog post which you can get here.