Saturday, July 21, 2012

thinkscript included: scanning for arrows

people have written me that they are having trouble using my sdi_itsig in a custom scan filter on the thinkdesktop platform. the problem appears to be that sdi_itsig has too many plots. user written studies must have one and only one plot to be eligible for use in a custom scan filter. so rather than rewrite sdi_itsig, i have written a new study that is scanner friendly. i call it sdi_3ga.

3ga is a stripped down version of itsig. it only looks for three green arrows. if you add it to a chart it plots a line that has two values, 0 and 1. while a 0/1 line is not very interesting to look at, sdi_3ga, can be added to a custom scan and that is its entire purpose.

the thinkscript is at the bottom and i assume you know to add a user written study to your platform.

here's how to work with sdi_3ga in the scanner:

click the scan tab, then click stock hacker. you should have a screen like:
click add study filter, then click the pencil icon. you get a pop-up like:
click the editor tab and you get:
in the editor textbox replace the text "ADXcrossover()" with "sdi_3ga()".
you can also select the type, fresh or all.

click ok then ok on the warning pop-up and you are good to scan.

here's the thinkScript:
# sdi_3ga: Three Green Arrow
#hint: Scan friendly study that plots a 1 when investool green arrow signals are present rev: 1.0
# author: allen everhart
# date:19jul2012
# 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 type = { fresh, default all};
def Fulld = StochasticFull("over bought" = 75, "over sold" = 25, "k period" = 14, "d period" = 5)."FullD";
def stochArrow =
  if fulld > 75 then 1
  else if fulld > 25 && fulld[1]<fulld then 1
  else 0;
def greens = if stochArrow && MACDHistogram("fast length" = 8, "slow length" = 17, "average type" = "SMA")>0 && close>SimpleMovingAvg(length = 30) then 1 else 0;
plot sdi_3ga =
  if type==type.fresh && greens==1 && !greens[1] then 1
  else if type==type.all && greens==1 then 1
  else 0;

Saturday, July 7, 2012

thinkscript included: the trouble with trin

a popular measure of market breadth is an indicator called trin (and also trin/q on the thinkdesktop platform.) these are also known as the arms indices. the problem i encounter with trin stems from my desire to plot it as a lower study indicator on a normal linear chart of the related futures products, /es and /nq, resp.  you see, trin, being a ratio of several other breadth measures ((advancing stocks/declining stocks)/(advancing volume/declining volume)) presents a neutral reading when it is at one, a bullish reading for values less than 1 and a bearish reading for values greater than 1.

the first trouble i have with trin is that it is an inverse indicator. it indicates sell when it is up and buy when it is down. just as a matter of sanity i always try to rejigger such indicators so that up is a buy signal and down is a sell signal. this is not hard to do just plot the negated (-trin) value.

the second trouble i have with trin is that it is a nonlinear indicator. values in the bearish area are linear, with a value of 4 being twice as bearish as a value of 2, but values in the bullish area are logarithmic with bullish readings of 1/4 being twice as bullish as 1/2 (and which correspond to the bearish 4 and 2, respectively.) a plot of bullish trin readings look kind of squashed on a normal, linear-grid chart, even if one is plotting the negated value. what i want is to plot bullish readings as their inverse value, 1/trin.

finally, the third trouble i have with trin is stitching together these two disparate views into a single indicator. the solution i use is to re-origin the neutral trin reading from one to zero. thus, if trin is greater than or equal to 1 then i will plot 1-trin otherwise i plot (1/trin)-1. this is the view of trin that i present in my study called sdi_breadth. here's a picture of what i'm talking about:

/ES with sdi_breadth

a bonus of this view of trin is that we can plot a legitimate moving average of the values. this is true because bullish and bearish readings are on the same scale - a one point change in the bearish area is equal to a one point change in the bullish area (not so for the raw trin plot.) so the green/red line is a 6 bar moving average of the histogram plot, brc (breadth corrected.)

also, values of raw trin that are close to one are more-or-less neutral. likewise values of brc that are close to zero are neutral. only now with brc we can equitably declare values within say, .2, from zero to be more-or-less neutral which i show in grey.

so here's the code:

# sdi_breadth - TRIN-based market breadth indicator
#hint: a view of the TRIN and TRIN/Q ratio's that is inverted and reorigined from the neutral reading of 1 to 0. this unpancakes the bullish readings to create an indicator that is evenly represented on an linear scale, can be averaged and analyzed technically. plots bright red for increasingly bearish bars, bright green for increasingly bullish bars, darkened bars represent fading and grey bars represent weak readings below the threshold. rev: 1.1 source:
# rev: 1.1 - get the color right on the first bar
# author: allen everhart
# date: Jul 17, 2010
# 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 lower;
input source = { default "$TRIN", "$TRIN/Q"};
#hint source: ratio selection
input threshold = 0.2;
def trclose = close(source);

plot brc =
  if trclose >= 1 then
    1 - trclose
    (1 / trclose) - 1

  if absValue(brc) < threshold then
  else if isNaN(brc[1]) && brc >= 0 then
  else if isnaN(brc[1]) && brc < 0 then
  else if brc >= 0 && brc >= brc[1] then
  else if brc >= 0 && brc < brc[1] then
  else if brc < 0 && brc <= brc[1] then

input mvgAvgLen = 6 ;
plot bma = average(brc,mvgAvgLen);
  if bma[1] > bma then color.RED
  else if bma[1] < bma then color.GREEN
  else color.LIGHT_GRAY
#plot bn = barNumber();

Friday, July 6, 2012

amzn bull put vertical

So here's an example of my current trading chart and style:

AMZN Weekly with seasonal projection.
The setup I am looking for is a liquid, triple-digit stock with a strong season coming up and is on-track for a repeat. The green arrow indicator is the PPS indicator and it is signaling a turn into the season. Then I want the stock to pull back into the body of the previous bar a little as AMZN did today.

The trade I took is called a bull-put vertical spread. I sold the August 220 put and bought the August 215 put simultaneously for a $1.75 credit. This has a maximum risk of $3.25 per spread and I put this spread on 3 times for a total risk of about $1,000 and a total potential gain of about $500 - a 50% return on risk.

The probability of success, if held to expiration, is about 60%:

I keep a limit order on to buy these back for 1/5 of the price I sold them, so I don't usually hold these into expiration.

Thursday, July 5, 2012

Still Here and Trading but New Work Situation

Hi smalldog fans,

Sorry that I've really slowed down on posts. I am still here, still trading but I have taken on a new work situation. So that means that I am not day-trading. Nor am I trading weekly options anymore. To give myself enough time to focus on new work activities I have shifted my focus to trading monthly options. In particular, I am concentrating on verticals and iron condors.

I've had a nice run (3) of winning trades utilizing Dan Sheridan's RUT Iron Condor, for example. If you have a funded account on TOS you can hear Dan explain this trade in the April 18 archived seminar. I do his trade trade 1/2 size and plan to add a contract leg after each $2,000 profit, in keeping with the size to portfolio ratio of Dan's trade.

Additionally, I've been seeing better performance by focusing on weekly aggregation periods in my charts. Its a less noisy chart, the supports and resistances are more reliable, my seasonal projection is cleaner and the PPS indicator is fairly accurate for these weekly charts.

I've shared some of these trades on MyTrade but perhaps I plan to start a series of posts that show my weekly chart set-up and discuss how it helps support my trading decisions.