Saturday, December 31, 2011

ThinkScript Included: Range Bar Projector

I am starting to look into range bars and was just re-listening to Ken Woods range bar talk in the TOS archive. The second time through I picked-up on something he mentions in passing - range bar projectors. That's a simple enough thing for me to "TOS" off so here's the results of this Saturday morning's fun:

/TF with sdi_rbproj and sidelines.

Since range bars are fixed in their price size you can predict where the forming bar might close: either low + size or high - size.

My preference is to plot lines in the right expansion area for this but I realize that some people might not use the right-expansion capability so I have provided a way to realize the projection right at the forming bar as well:

/TF with sdi_rbproj without sidelines

Here's the code:

# sdi_rbproj
#hint: RangeBarPROJector projects where the forming range-bar will close to the up and downside. Revision 1.0
# author: allen everhart
# date: 12/31/2011
# Copyleft! 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 sideline = yes;
#hint sideline: Yes, plots the projections as lines in the right-expansion area, No plots the projections as up/down arrows on top/bottom of the forming bar.

def barSizes = high-low;
def bs=highestAll(barSizes);

rec rbHi =
  if isnaN(close) && sideline then rbHi[1]
  else if !isNaN(close) && isNan(close[-1]) then low+bs 
  else double.NaN;

rec rbLo =
  if isnaN(close) && sideline then rbLo[1]
  else if !isNaN(close) && isNan(close[-1]) then high-bs
  else double.NaN;

plot phi = rbHi;
plot plo = rbLo;
  if sideline then PaintingStrategy.LINE
  else PaintingStrategy.ARROW_DOWN
  if sideline then PaintingStrategy.LINE
  else PaintingStrategy.ARROW_UP


Wednesday, December 28, 2011

ThinkScript Included: Money Flow Index In A Chart Label

The Money Flow Index (MFI) is a momentum indicator illustrating the strength of money flowing into and out of a security measured on a 0-100 scale. It is also a good over-bought/sold indicator. MFI values over 80 are considered to be over-bought. Likewise, MFI values under 20 are considered to be over-sold. Great! But I don't want to do technical analysis on it and, thus, I wouldn't ordinarily have it on my chart because it consumes precious real-estate at the bottom of my chart, scrunching up the price bars. However, like Average True Range, I am mostly interested in the most recent value of the indicator, so I have written a chart-label study that presents a most-recent view of MFI in compactified form. Here's the picture of this study in action:

SPY With Money Flow Label In Upper Left Corner
The chart label presents the current value of the Money Flow Index followed by my trend indicator. The trend indication is the last two characters, in this case, ^^ (two up-carrots.) What that means is that the MFI has had two successive moves up. If there had been a down move in the MFI two days ago then a v (alas, there is no down-carrot in ASCII) would have appeared in the first position. Also, the grey coloration of the label means that the indicator is in the midrange area. If the MFI is below 20 then the label turns red and green for overbought when the MFI is above 80. Finally, if MFI has just crossed above oversold or crossed below overbought then the chart label is colored Orange.

Here's a picture of an equity displaying this cross-over signal:

FSLR with a Cross Above Oversold Event in the Money Flow label.

Here's the code:
# sdi_flow: Display Money Flow Index as chart label
#hint: Displays the MoneyFlowIndex as a color-coded chart label. Red=oversold, Grey=midrange, Green=overbought and Orange=crossover. rev: 1.0
# author: allen everhart
# date: 12DEC2011
# 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.
declare UPPER ;
input length = 14 ;
input overBought = 80 ;
input overSold = 20 ;

def bar = round(moneyFlowIndex(20,80,length,1),2) ;
def dir = bar-bar[1] ;

  concat(concat(concat("FLO:", bar),
    if dir[1]>0 then "^" else if dir[1]<0 then"v" else "="),
    if dir>0 then "^" else if dir<0 then"v" else "="),
    if bar>overBought then color.GREEN
    else if bar<overSold then color.RED
    else if bar[1]>overBought then color.ORANGE
    else if bar[1]<oversold then color.ORANGE
    else color.GRAY


Wednesday, December 7, 2011

MSFT: The Road Ahead

MSFT Road Map
 I heard Tom Sosnof of, a trader/entrepeneur I admire greatly, put on a bullish diagonal trade for Microsoft today. I believe his trade was -Jan25Put/+Feb24Put for a 30 cent or so credit. When I looked at the seasonality of MSFT I saw that Tom's trade was dubious. Since I need more negative delta in my portfolio anyway I felt compelled to compose and take a Bearish diagonal on MSFT, which I have shared on MyTrade. I bought the -Dec 25 Call/+Mar 26 Call diagonal for a debit of 34 cents. My max loss is $1.34 if MSFT bucks its season and explodes to the upside in the next week and half, otherwise a strong seasonality takes over in MSFT in the first quarter that I think will take MSFT down to the neighborhood of its current 52 week low of $23.65 by March. MSFT has a better than even chance, seasonally speaking, of going even lower but I have given Tom a benefit of a doubt by picking a higher probability target north of $23.65.  MSFT has weekly options which I will avail myself of if they make sense when the time comes to roll next Thursday. I may be a little early since the Aroon indicator has not got to the overbought area but I am willing to suffer through a little end-of-year bullishness.

Sunday, December 4, 2011

AGU Roadmap

 Luca Giusti posted a seasonal pattern for AGU and this looked pretty good on my seasonal projection studies for a Nearly Naked Put Diagonal trade. So I am documenting here the why and how of this trade which I shared on MyTrade.

First of all I have 'splaining to do on my seasonal projection studies. That mess of blue, magenta and green extending into the future are my seasonal projections. These are a graphical digest of the last five to seven years of seasonal behavior that I find to be relevent to trading. To build these I take the fractional price changes of the underlying equity from the same anchor date in previous years and average them together and then multiply the average fractional move against the closing price of the anchor date. This is done repeatedly for each future date to build up a projection line of average seasonal performance.

The top edge of the green mess is 0.3 standard deviations below the average projection and is only displayed when it falls 2% or more higher than the flat line. This multiple of the standard deviation means that 62% of the individual season projections fall above the green mess - a better than even chance for where the future price will go when business is usual. Also, the fact that the green mess tracks so consistently close to the projection through April tells me that AGU is strongly seasonal. After April it falls away from the projection when I anticipate the season to end.

Moreover, my seasonal projections help to indicate whether business is usual or not. In the roadmap above I show two seasonal projections: the blue line (a seven season projection) is anchored 10 trading days back and the magenta line (a five season projection) is anchored on the most recent day. The fact that these two projections converge and move together into the future is a strong indication to me that business is usual for AGU, otherwise any recent trader knowlege of unusual business in AGU would show its existance by separating the seasonal projections because AGU would be off-track wrt the earlier projection.

This all suggests to me a bullish trade in my preferred style: the NND (Nearly Naked Diagonal.) In my formulation of the bullish diagonal, I sell a put in the front month at the first strike ITM and I use this value as a budget to shop for a backmonth strike to buy (usually a goodly number of months back, like 5 or 6, so we have plenty of roll opportunities.) I like to outlay between $1 and $2 for these trades or whatever I feel I can cover in the first roll of the short option. The April 62.5 Put fits the bill and I can put this -Dec70P/+Apr62.5P trade on for a debit of about $1.50 as of Friday prices. This would set my max loss to $9, which is well within my small-acceptable-loss tolerance but keep in mind that this max loss would only be realized if AGU were to go "Lehman" in the next two weeks. Barring that unlikely extreme event I will roll the short option for a credit and thus whittle-down the max loss exposure.

The roadmap says that AGU could rally up to the descending trend line of a symetrical pattern by the first week of January, where it might then fall back to the ascending trendline before finding support for a larger breakout. If I do see precisely this kind of behavior it may pay to buy back the short option that first week of January and complete the roll by selling February closer to the Jan expiration. However, it is of little concern if I don't see precisely this kind of behavior due to the power of the roll as there is wide latitude in the underlying equity price for which a short option can be rolled profitably. NND's are very forgiving in this respect.

Well that's the plan and I will keep you posted as to how reality measures up.


Saturday, December 3, 2011

ThinkScript Included - My TTM_Squeeze Scanner For The CNBC Stock Challenge

The CNBC Million Dollar Stock Challenge has concluded. I did not win but one of my portfolios (Schnauzer, I named them after small dog breeds) that I was active with scored a 99.78% game rank percentile:
Allen Everhart ranks 1,497 on the Million Dollar Portfolio Challenge Top Traders Board
This result was achieved by investing in the few leveraged ETF's that were permitted and by shorting GBP/USD and a good deal of neglect. (Note: a portfolio that I made no investments with, only improving by bonus question money, scored 96.44% game rank percentile.)

Before the challenge started I developed a custom scanner in the ThinkDesktop platform but I did not use it all that much after I found out that leveraged ETFs were permitted investments. However, I do think active traders might find some merit (at least in the education of custom scanner construction) to this scanner.

Here is an image of the scanner loaded into the scan-tab:
My CNBC Scanner

Last Minimum 2 and Market Cap Minimum 500M were CNBC contest criteria that I could match with the standard fundamental filters.

Sizzle Index Minimum 0.5 is a filter I chose because it finds stocks that have options and that are seeing somewhat elevated option activity.  The sizzle index is a measure of option volume and the minimum of 0.5 means I am looking at stocks with 50% greater than average volume.

The last CNBC contest criteria was that volume averged over 100 days be greater than 50,000. For this, one needs to resort to a custom study filter:
  1. Click the Add Study Filter button on the upper right. This will append the AdxCrossover filter to the list (the list may scroll up hiding the Last Minimum 2 fundamental filter but it is still there.)
  2. Click the small triangle on the lower right of the AdxCrossover filter to drop down the list of standard study filters and select Custom, the last menu entry.
  3. In the Scanner Custom Filter dialogue, select the inspector button and highlight AdxCrossover() to replace that text:
  4.  Type the letters si and then select SimpleMovingAvg from the suggestion drop down list. Be sure to append () and then the syntax error will clear allowing the inspector box to appear.
  5. In the inspector box select VOLUME in the price type input box and set length to 100.
  6. Finally append >= 50000 to the text.
    (Note: custom filters are boolean ThinkScript expressions. They must evaluate to true or false - you cannot just cut and paste any ThinkScript code from a chart study.)
    This completed filter should look like:
  7. Click ok and you have created, perhaps, your first custom filter.

The last two filters are some special custom code for which you can repeat the above steps, more or less, to add:

(1.333333 * stdev(close, 20) / averageTrueRange(ATRLength = 20) >= 1) && (1.333333 * stdev(close, 20)[1] / averageTrueRange(ATRLength = 20)[1] < 1)

Inertia(close - ((Highest(high, 20) + Lowest(low, 20)) / 2 + ExpAverage(close, 20)) / 2, 20) > 0

These last two filters are the criteria that John Carter of Trade The Markets uses to indicate when to take a Bullish trade. You can verify this by bringing any of the stocks found in the scan and inspecting the charts with the TTM_Squeeze and TTM_wave studies. For example:

ANSS with a Bullish Squeeze Breakout
 I hope that was helpful to you all.


Friday, December 2, 2011

Stealth-Dip Update

Dow/Gold Dec 2, 2011
The above chart plots the track of the Dow/Gold ratio. This literally prices the Dow in terms of Troy Ounces of Gold. Usually economists look at this ratio to compare historical values of the Dow over eras of highly variable inflation and monetary policy. My thesis is that the much anticipated second dip in the broad market has already occurred but was disguised by the two rounds of quantitative easing. The chart above is consistent with my stealth-dip thesis: the low in August occured when S&P downgraded the US debt and is lower than the March 2009 low in the ratio. The D/G has touched above the March 2009 low-level but I don't consider the thesis confirmed yet. Confirmation would come when the market tests the 7.2 level as support which may happen sometime in Spring of 2012.  You heard it here first.

Comments welcome.


Thursday, December 1, 2011

Final 2011 Presidential Cycle Update

Final 2011 Presidential Cycle Update
The year prior to a presidential election year is usually a very bullish year. Presumably this is due to incumbents working the levers of government to make the economy as rosey as possible. What we got was a big divergence from the norm (blue line) to the downside. The blue oval is 1 ATR high and centered on the intersection of the cycle projection anchored on Dec 1 and the year-end. We may yet squeak out a gain for the year but it is somewhat doubtful and I give it something like a 20% chance.