Saturday, December 13, 2014

what are the chances of a santa claus rally?

sdi_seasonalstgy on spy set to buy on trading day 241 and sell after 11 trading days
santa claus rallys occur approximately 2 out of 3 years based on the last 10 years, admittedly not a big sample. 1 out of 3 years you get a lump of coal. overall there is positive expectancy.

Sunday, December 7, 2014

bonus thinkscript: sdi_psarstgy_nq100 - the fabulous psar strategy preconfigured with psar-psearch optimizations

bonus thinkscripts are the extra's you get when you purchase a distribution of my thinkscript suite. in the past they have been thinkscripts that i pass along from other open sources in the import format. this new thinkscript is one for which i am not blogging the source code.

sdi_psarstgy_nq100 is the marriage of my previous sdi_psarstgy with psar-psearch. it is simply the psarstgy preconfigured to employ the psar-psearch optimized parameters for acceleration factor and acceleration limit when viewing any of the nasdaq 100 stocks. here's how this looks on aapl:
sdi_psarstgy_nq100 on aapl.
this chart shows how $10,000 of trading capital deployed buying and shorting aapl in 32 alternating trades might have returned 43% by the mechanical psar strategy with optimized input parameters.

Monday, December 1, 2014

turkey-trade fail

the thanksgiving week seasonal trade i posted last week failed. here's what this looked like:
turkey trade on spy
this was a small, acceptable $47 loss on $10,000 of investment. i'd try that again.

Sunday, November 30, 2014

bonus thinkscript: sdi_avatod - average volume at time of day

bonus thinkscripts are the extra's you get when you purchase a distribution of my thinkscript suite. in the past they have mostly been thinkscripts that i pass along from other open sources. this new thinkscript is one for which i am not blogging the source code.

here is the image for my average volume at time of day script:

wmt with sdi_avatod 
average volume at time of day is an important concept for the investors business daily (ibd) crowd. in the image above the 50 day/1 hour avatod is shown as the red stairstep lines. the first hour of trading is particularly important (volume highlighted in a lighter shade of blue) as above average volume then is thought to be an early indication of institutional trading. on a holiday shortened day the the first hour of trading on wmt shows volume way above the 50 day average for the first hour of trading with a price gap to the upside. draw your own conclusions.

Monday, November 24, 2014

perhaps the best week to be long stock

seasonally speaking, thanksgiving week is one of the best weeks to be long stock as you can see from this chart with my sdi_seasonalstgy:
simulation of $10,000 of spy bought on the open of trading-day 227 (the monday before cyber-monday, more or less), held for 4 trading days,  and sold on the open of  trading-day 231 (cyber-monday, more or less) over last 20 years
next week - back to 50%

Saturday, November 22, 2014

thinkscript included: sdi_yield_label

this one is so obvious that i am surprised that there is not a standard tos study to display a stock's yield in a chart label. here's the picture:
spy with sdi_yield_label in upper left hand corner

here's the code:
# sdi_yield_label: Display Yield In A Chart Label.
#hint: Displays yield in a chart label. sdi_ivp rev: 1.0.0 
# author: allen everhart
# date: 22nov2014
# revision 1.0.0
# 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. 
plot labelColor=double.nan; #just to pull-in the color-chooser widget
addLabel(1,concat("Yield:",asPercent(getYield())), labelColor.takeValueColor());

Sunday, November 16, 2014

the 80/25 strategy

one of jim cramer's favorite investing themes is to trade with 'house' money. what he is talking about is buying a stock, waiting for it to double and then selling half - at which point you have recovered the money you invested and your remaining shares have zero cost-basis (zcb.) then you retain the zcb shares until some other investment objective is met.
do you really need to wait for a doubling of price to create a zcb position?
no! the sell-half-after-doubling strategy is just the most facile arithmetic (1/2 is the inversion of 2 - anybody could do that in their head.) in reality it is somewhat rare for a stock to double within my patience time-horizon - about a business quarter - which i don't think is so unusual considering the great many choices of momentum stocks to choose from. a far more likely scenario is that a favorable stock rises by 25% in a quarter. given a 25% appreciation one could sell 80% (since 4/5 is the inversion of 5/4) of one's shares and have a house-money position on the remaining 20%. once i have my money back, i can have a great deal of patience - this is the essence my 80/25 strategy. 

one could pick other ratios to work with, say, a 75/33 (sell 75% after 33% gain since 3/4 is the inversion of 4/3), 67/50 (2/3 is 3/2 inverted) or for those golden ratio fans 61.8/61.8 (sell 61.8% of shares after a 61.8% gain - since .618 is the inversion of 1.618 - try it!) however, there is good reason to concentrate on 80/25 because our friends at investor's business daily have researched that 25% is the most common run-up in a quality stock before a pull-back occurs. ibd's strategy calls for selling 100% of the stock after a 25% gain but i think it makes sense to take the profit in stock since nobody is paying interest on cash these days, and especially if the stock pays a dividend (in which case one essentially has a small, but free, annuity.)

i have more ideas about how to implement this strategy that i will explore in follow-up posts.

Tuesday, November 11, 2014

keepin' it real with dow and gold

ok, i admit it. i'm a little freaked out with the market at all time highs and gold sinking to the center of the earth. but are the numbers faking us out? yes! i would argue. this is because the ratio of the dow to gold is only 15. since gold is considered a constant store of value, the dow/gold ratio is what economists look at when they want to back-out inflation and central bank intervention. here's the picture:

dow / gold study (source chart of dow-gold is hidden)
in prosperous times the dow/gold ratio ranges into the 20's and 30's. we are not even back to the levels we were at before the housing bubble burst. so if you're thinking the market has flown too high and gold too low, think again!

Saturday, November 1, 2014

how to 'soup'-up thinkorswim

thinkorswim (tos) is my trading platform of choice. it provides a full-featured charting platform with extensive quoting of many different markets (some of which you would pay extra for on other platforms just to see 'em,) and a robust user-programmable scripting language. however, at times, it is a love/hate relationship. this is because application performance is not always great.
the garbage about java...
i think the first thing to recognize is that tos is written in the java programming language. java is an object-oriented language that is based on a dynamic-memory technique called heap storage. heap storage enables programmers to concentrate on solutions and less on housekeeping. in particular, a java programmer doesn't have to figure out the the prickly details of when to deallocate memory. in java, memory deallocation is automated by a software subroutine called the garbage collector. the garbage collector sifts the heap looking for objects that have a zero reference-count and deallocates them. thus, heap storage vanquishes a whole raft of memory-leak considerations that are the bane of non-heap programs. garbage collection is done automatically and is triggered by low-levels of available heap (also explicitly in the tos help/system tab but something is wrong if you need to do that.) the trade-off with heap storage is a higher requirement for memory. the higher requirement comes from the need to have a high level of free memory in the heap so as keep the garbage-collector relatively inactive. several pointers that follow address the proper care and feeding of java's heap storage.
up your bits and bytes...
the bit-number refers to the number of bits used to compose the address of a particular byte in memory. a 32-bit machine can create a unique address for 2^32 (2 raised to the 32th power) bytes. which means that a 32-bit machine can only ever utilize 4 gigabytes of ram. now, if you are on a 64-bit machine then you probably don't know what i'm talking about. that is my first advice to soup-ing tos. upgrade to a 64 bit machine that has a boat-load of memory. a 64-bit machine can assign an address to 2^64 bytes (about 16-million terrabytes) which is to say you are only constrained by budget as to how much memory you can install on a 64-bit machine. at some point the amount of memory installed is overkill but applications are like furniture and expand to fill all available space. you should get at least 8 gigabytes which is twice the amount of memory that can be addressed by a 32-bit machine.
up your processors...
also, most pc's these days have multiple processors. this enables a computer to literally walk and chew-gum - genuinely parallel (not just concurrent) computing. java supports parallel processing by a programming technique called threading, and tos undoubtedly is a multi-threaded application. which means, that at a minimum say, it could be running the garbage collector in parallel while your chart is painting. (2/28/16 alas, the garbage collector suspends all threads and always runs single-threaded resulting in the infamous gc-pause, for this reason you might want to consider running two instances of tos) if you are puchasing a machine on which to run tos then more processors are better. quad-core is a buzzword i hear a lot, maybe there is an even greater multiple available. my old clunker is dual core.
a virtual fairy-tale...
your operating system is like a sly gigolo - it makes an application feel like it is the only application in the world. to a running application, the memory address space it sees starts at zero and ends at the architecture limit (2^32 or 2^64) and the app has not a care in the world about whether the memory it is accessing is actually loaded into memory or conflicts with another application's memory. the os's job is to translate this fairy-tale, single-application viewpoint into the real-world of the physical machine where the program starting address is definitely not zero, there is far less ram than the architecture limit and there are multiple applications vying for system resources. in order to accomplish this the os employs a memory trick called virtual memory in which the os divides memory into chunks, called pages, and backs them to the mass-storage device (i.e. disk.) which is all to say that despite having a boat-load of the fastest random-access memory that money can buy your system's performance still has a disk-speed component because of virtual memory. there are two points of soup'ing advice that address the proper care and feeding of virtual memory:
up your page-file...
the first advice is to make sure your computer has an adequately sized page-file. the page file is the backing-store for the memory of a running application. so, however much memory your running applications occupy, there must be as much space available (and then some) in the page file on disk. a general rule of thumb is that the page-file should be twice the size of the ram and it doesn't hurt to have more. under-utilization is the only downside to an overly large page-file, whereas, an under-sized page-file will cause your system to thrash (where the os gets into a vicious cycle of transferring the same pages between ram and the pagefile.)
solidify your experience...
the other bit of soup'ing advice that follows from virtual memory is to upgrade your disk to an ssd (solid-state disk.) ssd's eliminate the delay of having to wait for a physical read-head to move (called seek time) to the right spot above a spinning disk and greatly reduce the delay in reading data caused by the speed at which a physical disk passes beneath the read-head (called rotational latency time.) basically, ssd technology is something like 10x faster than hard disk technology, and much more if you are on a disk that is 4 or 5 years old. this is like crack for a memory hungry application like tos. i spent $120 at staples to buy a 100gb ssd. it took me 30min to copy the image from my clunker hard drive and the performance improvement was night and day, not least to mention my vista os reboots in under a minute now.
up your memory settings...
as for tos memory settings, i set mine to the 1280-1280 maximum available to my 32-bit machine. this means when tos starts up it allocates a heap of 1.2 gigabytes all at once. the trade-off is that other applications might be starved for memory when i have tos running. however, for me, when i am trading everything else is secondary.
throttle your quote-speed...
even with all these stops pulled-out, i still was experiencing some nasty performance problems that were only remedied by restarting tos. by monitoring the help/system display i could see that my system was exhibiting a behavior i call heap-thrashing. this is a vicious cycle whereby the free memory would deplete to 25k or so, then the garbage collector would free 125k or so, and then 100k would get immediately allocated. i believe that this behavior is a quote-speed problem because it only occurred when the cash-market was open and when i adjusted the quote-speed from real-time to max 10-second delay (on the settings/application-settings dialogue) i was able to almost completely eliminate this problem while preserving a substantially live-market experience. on the help/system tab you can monitor the number of quotes per minute being received by tos. when i was experiencing heap-thrashing i was receiving in excess of 12,000 quotes per minute. after throttling this back to max 10-second delay this number went to about 3,000 quotes per minute.
cable it...
additionally, i see intermittent performance problems. all the local platform metrics are 'nominal' but there's an intermittent delay drawing a chart or updating data in a custom watchlist column. when this happens there's probably a communication delay. i have found through trial and error that my thinkorswim platform experience is smoother when i cable directly to my router with an ethernet cable instead of using wi-fi. now, a lot of things can go wrong with radio communications. in my former career i was programming computer systems that communicated by radio to terminals and one such system was experiencing intermittent delays. the problem was diagnosed and corrected only after a month of full-time consultation with radio experts who used hi-tech monitoring equipment (side note: be careful what you say on a cell-phone because all that gets transmitted un-scrambled on public airwaves.)  it turned out that a similar system running on a different frequency that was only used between 10am and 11am in the morning was creating what the radio experts called 'harmonic distortion.' so with the density of wi-fi routers in some locations it doesn't surprise me that there is sometimes a hard-to identify problem with wi-fi communications. i never could diagnose my tos issue with wi-fi because everything else worked great- webpages loaded instantly, pings showed no packet loss -only tos was hampered. even so, i stay tethered to my router.
up your isp...
i have word that the thinkorswim servers are physically located in in dallas. you can check your communications delay to the dallas area using internet speed tests such as this. here's what i get for this test:

i am getting a relatively good tos experience with this level of communication service. upping the speed of isp communications will enable you to receive more quotes per minute over the same bandwidth but you also have to have a fast enough and big enough bucket on the other end to handle all those quotes. in retrospect, i think, perhaps, some of my tos performance issues might be related to my upgrading from dsl, where i was getting 1 mbs, to cable modem. 

here's the system config with which i am having a good tos experience:
  • 32 bit machine
  • dual-core
  • 2 gigabyte ram
  • solid-state disk.
  • 4 gigabyte pagefile
  • 1280-1280 tos memory settings
  • max 10-second delay quote-speed.
  • 10base-t cable to 20mb/s router
  • 20mb/s cable modem

but my next machine might be configured like:

  • 64 bit machine
  • quad-core machine
  • 8+ gigabyte ram
  • solid-state disk.
  • page-file 2 to 3x ram
  • maximum tos memory settings.
  • maybe real-time quote-speed.
  • 10base-t cable to 20mb/s router
  • 20mb/s cable modem

Saturday, October 11, 2014

thinkscript included: is trading the hull moving average a good strategy?

on tuesday, october 7th, on tastytrade's tech-tools segment, steve miller, aka slm, said he liked the hull moving average and encouraged his users to "play" with it. so i did. 

the hull moving average employs a smoothing technique that claims to reduce "lag" - a trading signal that comes a little too late. if you watched slm's presentation it clearly seems to do just that. the rollover of the hma certainly seems to occur way before some of the traditional moving average crossovers that investors watch - but can that make you money? 

it's really hard to eyeball a chart and make an assessment that is not subjective. first of all, the rising/falling color transition is not fully determined until the candle after the transition completes. this means that a trade entry would not occur until the open of the 2nd candle past the color transition.  the cumulative p&l of trades taken this way is something i wouldn't want to evaluate by eye. fortunately, there is the thinkscript strategy facility, with which i can simulate trading such signals and evaluate these things objectively. so here's a typical picture of the hull strategy at work:
simtrading $10k on spy via hull moving average signals compared to passive investment
the top graph shows when and at what price the hull strategy  bought, reversed and shorted $10,000 worth of spy, as indicated by the pink labeling and arrows. the pink number is the amount of shares transacted. when the dashed line connecting the reversals is colored cyan the trade made money and when the dashed line is colored red the trade lost money. the floating pl subgraph shows the day-by-day cumulative profit and loss for the strategy over the 1-year duration of the chart. the bottom subgraph shows the growth of $10,000 invested over the same period of time by the buy 'n hold method and by dollar-cost averaging (i.e. buying about $833 worth of spy every month.) so here we see that, as of Oct 8,14, that the hma strategy was down money while buy 'n hold showed a position improvement of +$1,650 and dollar-cost-averaging, +$372. this is very typical of the equities i looked at.

now the kinds of equities i tend to be interested in reflect that i tend to be a long trader. however, i did find that the hull strategy shined for equities in a long-term decline. take gld, for instance:

and even more impressively, slv:

so it seems that if you have a bearish opinion that was formed by some other method, that taking the bearish trades from the hma signal could be profitable.

here is the code (how to install):

# sdi_hullmastrat - plot results of trading the rollovers/unders of the hullMovingAvg 
#hint: shows the trade simulation of trading the hullMovingAvg rollovers / unders using a fixed amount of money. rev:1.0.0 
# author: allen everhart
# date: Oct 11, 2014
# 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 dollarsPerTrade=10000;
#hint dollarsPerTrade: controls the amount of money the simulation uses to trade. rev: 1.0.0 
input length=20;
#hint length: the number of charting periods passed to the hullMovingAvg calculation. 
def shareSize = Round(dollarsPerTrade / close, 0) ;
def ma=hullMovingAvg(length=length);
def buySig=ma crosses above ma[1];
def sellSig=ma crosses below ma[1];
addOrder(OrderType.BUY_AUTO, buySig,name="long", tradesize=sharesize);

addOrder(OrderType.SELL_AUTO, sellSig, name="short", tradesize=sharesize);

Saturday, October 4, 2014

thinkscript included: how to beat the s&p with a simple seasonal strategy.

it's that time of year again. no, not to binge on candy and tp your neighbor's tree. it's the time of year to initiate the world's most boring strategy that happens to beat the s&p over the last 15 years. that's right, you don't need cramer, a hedge fund, a certified market technician, nor even an astrologer to beat the market. you just need to trust that something that has been working will continue to work: the halloween strategy.

the halloween strategy is the flip-side of the market aphorism: sell in may and walk-away. it tells you when to buy. thus, there are just two rules:

  1. buy on the first close above the 50 day simple moving-average in the month of october.
  2. sell on the first day in the month of may.

how's this been working? well, let me draw you a picture:
trading $10k on spy via halloween strategy vs. growth of $10k via passive strategies
this chart shows that the profit and loss of trading $10,000 (without compounding!) of spy, the s&p 500 etf, by the halloween strategy over the last 15 years produced a net profit of $10,261 (double the $10k trading capital.)  this beats both the passive strategies of buy 'n hold and dollar-cost-averaging over the same period which only improved the 10k invested by 5k. (note: there is no accounting for dividends and commissions.)

while it might seem fantastical to double in 15 years let me remind you that this only amounts to an annualized return of 6.8%, uncompounded.

should you participate in this year's halloween? let me just interject the cliche disclaimer: past performance does not guarantee future performance. however, knowing the past can help temper expectations. if we extend the picture back 20 years we see something different:
halloween strategy vs passive investing over 20 years
now, halloween strategy (profit of $18.5k) falls in between buy 'n hold (profit of $33k) and dollar-cost averaging (profit of $6.5k.)  so, the boom-boom years of the late 90's were not years of out-performance for the halloween strategy relative to buy 'n hold (trick!)  however, if you didn't inherit wealth 20 years ago then you are stuck doing some sort of dollar-cost averaging. this halloween strategy could be a great 401k strategy - put your money in an s&p fund for half the year and then in a fixed-income fund for the other half. if you reinvest the profits then you will get a compounding effect, which can be estimated by the rule of 72. thus, given average past results, one might expect this strategy to double your money in about 11 years.

here's the thinkscript (how to install):

# Derived from TDA's halloween strategy.
# With minor modifications to create a constant dollars Per Trade by Allen Everhart 
# Source: 
input dollarsPerTrade = 10000;
input price = close;
input length = 50;

AddOrder(OrderType.BUY_AUTO, GetMonth() == 10 and price > Average(price, length), tickColor = GetColor(1), arrowColor = GetColor(1), name = "HalloweenBTO", tradeSize = Round(dollarsPerTrade / price, 0));
AddOrder(OrderType.SELL_TO_CLOSE, GetMonth() == 5, tickColor = GetColor(2), arrowColor = GetColor(2), name = "HalloweenSTC");

Sunday, September 14, 2014

thinkscript included: sdi_consbar - display consecutive up and down count

a while back when i was playing with altucher's strategy i wrote a little study called consbar, or consecutive bar, to help me validate the signals from altucher's strategy. recently, people have been writing to me to develop a scan that finds ttm_scalper_alert signals. this ttm_scalper_alert looks for 3 consecutively higher/lower closes to throw an indicator on the chart. the problem is that ttm_scalper_alert backdates the indication signal to the start of the run, which makes it confusing to scan for (hint: use the clause 'within 3 bars') because the indication never appears on the currently forming bar. now, maybe you want to investigate how the market behaves after other consecutive runs as well, say 4 or 5. it is in this spirit that maybe you will find my consbar to be useful. so here's the image followed by the code:
sdi_consbar showing runs of consecutively higher or lower closes on spy
# sdi_consbar: display consecutive bar count
#hint: displays the count of consecutively up days and consecutively down days.  rev: 1.00 
# author: allen everhart
# date: 14sep2014
# 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;
def bars_up = if close > close[1] then bars_up[1] + 1 else 0;
def bars_down = if close < close[1] then bars_down[1] + 1 else 0;

plot up = bars_up;
plot dn = bars_down ;

up.setDefaultColor( COlor.DARK_GREEN );
dn.setDefaultColor( Color.RED ) ;

Wednesday, August 6, 2014

gold season, here-now?

seasonal $10,000 hold on gld over next 21 trading days
i'm just waiting for my favorite buy-signal ...

Sunday, August 3, 2014

august, the cruelest month?

results of holding $10,000 of spy for 20 trading days in august over last 10 years
this chart shows how $10,000 worth of spy, the s&p 500 etf, fared in a 20 trading day hold in the month of august. this is not excessively cruel but look for warmth on the beaches instead of the stock market. the simulated trades in this chart were generated by my sdi_seasonalstgy script.

Saturday, July 26, 2014

bullet-proof investing

the basic idea of bullet-proof investing is to put some money in safe long-term fixed interest instruments and then use the interest that will be paid to you eventually as a budget to play the market now. i get this idea from the wall street journal website: how to build your own annuity

so what the wsj is talking about is:  

  1. buying a 10-year cd. i find that i can buy a 10 year cd in my ira brokerage account at an apr of 3.30% in units as small as $1,000. cd's are fdic insured and are just a notch down from treasuries in terms of safety.  there are issues that one might fuss about, such as early withdrawal penalties, but i plan to scale-in a little at a time so the impact of that is minimal. scaling-in also gives me the ability to take advantage of what i anticipate will be an era of increasing interest rates.
  2. calculate how much interest is thrown-off. there are many online cd interest rate calculators (such as this one) which tell me that, at 3.3% apr, $1,000 will become $1,387 after 10 years. thus, there is a budget of $387 to work with, (which doesn't sound like much but read on...)
  3. buy a broad market index etf or mutual fund. it so turns out that my brokerage offers vanguard's total stock index etf (ticker:vti) on a zero-commission basis. thus, it is totally efficient for me to buy shares in one'sy-two'sy amounts. vti last traded at about $102, so, to be 100% bullet-proof, i would buy 3 shares of vti for every 1k of fixed interest. that way, even if the whole stock market goes to zero, i come away slightly better than break-even.
however, that is over-insurance, imho. really, if the whole stock market goes to zero then it would only be because there was a calamity the likes of which the world has never seen - perhaps not even the us government could survive such a disaster to make good on fdic insurance. 

a more likely bad outcome, one worth protecting against, would be that, perhaps, the market gets chopped in half. so a 95% (about 2 standard deviations) bullet-proof strategy would be to invest twice the interest or $784 or, say, 8 shares of vti. this worst case scenario looks like this: in 10 years $816 invested in vti drops to $408, while the cd matures yielding $387 and i am down only $21. as wsj points out, the more likely outcome would be that vti doubles (a 7.2% apr by the rule of 72) in 10 years and this scenario looks like this: in 10 years $816 becomes $1632 and the cd matures yielding $387 and i am up $1,203, or a gain of about 68%.

for your pup's, maybe they save $100 week from some employment activity in a small brokerage account. after, 10 weeks, they could buy a 10-year cd at the 3.3% rate. then, for the next 8 weeks they buy 1 share of vti per week, commission-free. after 8 weeks of that they switch back to saving cash for the next 10-year cd and so on. 

also, vti is optionable. so once 100 shares are acquired one could then sell call premium to lower the cost basis. it would take only $12,500 of 3.3% cd investment (less at higher rates) to reach this level. furthermore, vti, pays a 1.7% dividend, which might be dripped to produce gains on a generational time-horizon. in any case, after 10 years the cd will roll-over ... lather, rinse, repeat!

Saturday, July 12, 2014

a little x was good for me

united states steel, stock ticker x (what were you thinking!?), is a psar-search star that i did well with recently. let me draw you a picture:
over the preceding 52 weeks, simulated trading for x on my optimized psar signals made $4,106 in 7 trades that each bought or shorted $10,000 worth of x.

on june 18, the optimized psar reversed and went long (simulated buy of 395 shares.) on monday june 23 i noticed a recent psar event on x and decided to live-trade x to the long-side. to get long on x, i bought a call spread by simultaneously buying the aug1 24 calls and selling the aug1 28 calls. i paid $2.00 for this spread and then entered a good-til-cancelled order to sell at $3.05, about 50% of the maximum possible gain in this trade. my risk was only the  $600 (=3 spreads * $2/spread * 100shares/contract) i paid for the spreads.

on july 11, just before the close, the trade hit my target price and i closed the trade for a 48% gain (net of commissions.) here's an image of these trades from my account statement.
the stock equivalent of this position would have been about 120 shares (=0.4 delta * 100 shares/contract * 3 contracts) and would have cost about $3,010 at the open price on june 23 of 25.08. if one were prescient enough to sell the high of 28.3 on july 11 then, maybe, one could have realized a 12.8% gain (~$385) but at 5 times the risk.

want my psar settings for x? come to the psar-search page where, for a modest fee, you can buy optimized settings for the acceleration factor/limit input parameters to the standard psar indicator. you can use those parameters in any trading platform that provides the psar indicator or in my sdi_psarstgy (free), pictured above, on the thinkorswim platform, which will provide an on-going back-test analysis as well as the indicator.

Thursday, July 10, 2014

nugt, psar-psearch superstar

nugt just threw a buy-signal:
psar-search bidirectional trading on nugt returned 130%
nugt is a psar-psearch superstar. over the preceding 52 weeks, simulated reversal trading on the psar signals using my psar-search settings made $12,979 in 36 trades that each bought or shorted $10,000 worth of nugt - almost 130% gain and that's without reinvesting the profits from preceding trades. 

to get long on nugt i bought a call spread by simultaneously buying the july 46 calls and selling the july 51 calls. i paid $2.29 for this spread and by eod it was trading for $2.75. i am targeting $3.70 which is about a 57% gain and about 50% of the maximum profit possible in this $5 wide spread.

want my psar settings for nugt? come to the psar-psearch page where, for a modest fee, you can buy optimized settings for the acceleration factor/limit input parameters to the standard psar indicator. you can use those parameters in any trading platform that provides the psar indicator or in my sdi_psarstgy (free), pictured above, on the thinkorswim platform, which will provide an on-going back-test analysis as well as the indicator.

Sunday, July 6, 2014

how i'm trading psar-psearch

in this crazy market the implied volatility is nearing record lows and seems like it will be there forever ... or at least longer than my sanity can hold out. when iv gets this low the direction-neutral credit strategies stop being a good reward for the risk. i feel that i need to choose directions in this market and i am not good at that and i am worse at recognizing when to change directions. this is why i latched on to the psar-psearch idea because it gives me a reasonable way to pick direction and when might be good time to re-evaluate.

now, one can trade the psar-search optimized signals as a pos (plain-old-stock) trade but i prefer the option debit spread because it is a more efficient allocation of capital. in a debit spread one is usually buying an itm option and selling an otm option and paying upfront for it. here's how i pick strikes and manage the entry:

  1. look for a 70'ish delta strike to buy. the range is flexible it can be 60, it can be 80 but a strike or two in the money. the expiration can be 2 weeks to 2 months away. note the extrinsic value of this option.
  2. look for a theta neutalizing option to sell. i look for an otm option that prices closest to the extrinsic value of the long strike. this is usually a strike that is about 30 delta.
  3. buy the spread for 50% of the strike width. i buy the spread if it prices for something like half of the distance between the strikes. a percent or two on either side is fine but more than that means i need to pick different strikes.
  4. 1% per trade. i size the trade to be at most 1% of my available option buying power. this is probably less than an optimal kelly-size but i need to sleep at night.
when executed properly i have a position that is approximately equivalent to owning or shorting about 40 shares of the underlying equity per spread but purchased for far less. this is because .4 is roughly the difference in delta between the long strike and the short strike and each option controls 100 shares of stock. to be sure, the upside is capped but i will almost always realize a large percentage gain in the spread long before i would see the same percentage move in the underlying.

managing the trade is simple:
  1. target 50% max gain. i rest a gtc order to sell the spread when it appreciates to 50% of the maximum possible gain. this should be a price that is about 75% of the distance between the two strikes.
  2. stop out on a psar reversal. don't go against the psar! it may or may not be chop, you just don't know. if one is looking at the psar when the market is open then the the psar stop that is in effect is on the previous candle to the forming candle.
  3. maybe reload the trade. if i made the target and the move is young and the psar dots are doing their parabolic thing and are something like an average-true-range away then i think about reloading the trade but i would hate to give back any part of a 50% gain chasing money left on the table.
  4. maybe take a reverse direction trade. reversing direction is a case-by-case decision. in this bulls-on-parade market i wait for confirmation to take a bearish reverse. by confirmation i mean i wait for a candle that undercuts the low of the reversal candle. fyi, this is how the acceleration part of the psar works, the psar stop gets more aggressive only when there is extension of range in the trade (and only up to the acceleration limit.) 
  5. two stop-outs and done. if i am stopped out twice in a row then i look for a different equity to trade. something is changing to cause excessive choppiness and it is best to let that sort itself out. possibly, the psar-search acceleration parameters are in flux as well. i could conceivably switch back to a neutral strategy but i would need to see the iv sufficiently high (>30% in my experience) to make that work.

Tuesday, June 17, 2014

jcp: psar-psearch superstar!

liz and jenny of tastytrade mentioned that jcp was one of their better wheel-of-fortune trades, so i ran it through the psar-search optimizer and found these settings that show that jcp was also a superstar for long/short trading by the parabolic-sar method. pictured above is p&l of 165% return on trading capital of $10k deployed in 40 simulated trades over the last year. during that same time buy 'n hold turned $10k into $5k and dollar-cost averaging only lost $700. want the acceleration factor/limit settings i found? come to the psar- psearch page where for a modest fee you can have these parameters for jcp and 9 other equities of your choosing.

Sunday, June 15, 2014

psar trading on apol returns 62%

pictured above is the most recent sim-trading on apol by the parabolic stop and reverse method with parameters assigned by my psar search program. the floating PL shows a 62% return on trading capital by this method on trades simulated by my sdi_psarstgy study over the course of the last year. the simulated trades are each sized to deploy $10K worth of capital and the results do not take into account reinvestment of profits. the lower graph shows the growth of a $10K investment in apol over the same time period of 1 year via the buy 'n hold method and via dollar-cost-averaging (scaling $10K into apol by periodic purchases every 21 trading days) as shown by my sdi_passive study.

Thursday, June 12, 2014

psar psearch wins big on twtr

my psar search examines all 4950 setting combinations of acceleration factor and acceleration limit at a resolution of .01 and spits out the most profitable setting. here's what it found for twtr:
10k traded on twtr  via psar with optimized settings vs. 10k invested via buy 'n hold and dollar cost averaging
passive investing via buy 'n hold turned $10,000 into $8,770. dollar-cost averaging was slightly worse. trading $10,000 via parabolic stop-and-reverse with psar psearch settings made $7,000 and that is without reinvesting profits. now, admittedly, i couldn't have picked these particular psar settings at the ipo but here's twtr from the ipo with the standard aggressive stop managment settings of 1/1 for acceleration factor/limit, resp.
10k traded on twtr via psar with aggressive 1,1 stop settings
a respectable 57% return on trading capital. 

Wednesday, June 11, 2014

psar psearch

i wrote a program that searches for optimal psar input parameters. these input parameters are called acceleration factor and acceleration limit. in my previous post i show one such setting found by the  psar psearch program for amzn. psar psearch evaluates the p&l of every legitimate setting of acceleration factor and acceleration limit at the resolution of .01, almost 5000 combinations, and picks out the most profitable one for an individual equity.

if you are using or contemplating the use of the parabolic stop-and-reverse strategy then you need to use non-default settings for the input parameters otherwise your trades will lose money during choppy periods. 

i'm sensing that perhaps there's a business opportunity in providing psar psearch optimized acceleration parameters so here's the deal: i will provide the current psar psearch acceleration factor/limit parameters for 10 stocks for $10. the optimization is performed looking back on 1 year of daily prices. what you get is perhaps some of the best hind/insight into long/short trading particular stocks and, in as much as the past has continuity with the future, is an excellent guide to trading individual equities. click the buy now button to get started.

* * *
new 7dec2014 - i deliver your psar psearch parameters in a customized version of sdi_psarstgy_nq100. that is to say, you get the nasdaq100 stock optimizations plus your choice of 10 other stocks in a more convenient format. 

Enter 10 stock symbols:

Monday, June 9, 2014

best psar settings on amzn

amzn p&l trading 10k using sdi_psarstgy with acc. factor=.01 and acc. limit=.12
i wrote a program that hunts for good psar settings in specified stocks. unfortunately the program is not the sort of thing that one would implement in thinkscript. i am finding settings that produce these 50% profits in one year quite frequently so every once in a while i will share 1 or 2 of them. however, be forewarned the optimal settings drift over time so a month or two down the line these settings may not look so favorable.

Wednesday, June 4, 2014

thinkscript included: sdi_psarstgy rev. 1.1.0

this release of sdi_psarstgy, a study that simulates trading the parabolic stop-and-reverse indicator, includes an improvement and a bug fix. the improvement is a chart label that reports the win% and the number of trades evaluated. the fix is a correction for trade price when a stock gaps through the psar price. 

here's the picture of this new revision at work:
sdi_psarstgy on dks which gapped below the psar price on earnings and then gapped above the psar on 5/30
previously, when a stock gapped above or below the psar price, sdi_psarstgy would simulate a reversal trade at the psar price. this was incorrect because equities often never trade at the psar price on a gap day. now, when an equity gaps through the psar price the reverse trade is simulated at the open price instead of the psar price.

as always, the updates to scripts are maintained on the original post for the script which you can find here.

Friday, May 30, 2014

what i see

"trade what you see," is the admonishment i read from many a financial advice column. the tools at thinkorswim and my smalldoginvestor tools are geared for just that. here is the picture i have and outlook for june:
spy $10k seasonal buy and 20 trading day hold,  with projection channels
spy has been on an unseasonal bull run. the purple regression channel takes us up to the top of the blue, longer-term channel by mid-month...provided that the market continues a straight-line march. over the last 10 years, a june 20 trading-day buy & hold on spy has not once been profitable. will 2014 break the streak or conform to the decade-long norm? 

i can't build a case for buying based on proximity to a support level, yet, i can't build a strong case for selling either since we are not close enough to channel resistance levels. volatility levels are way down which takes the benefit out of trading neutral, premium-selling strategies. i feel stymied and have moved 90% to cash. i am trading some new ideas but in extremely small, test-the-water, 1-lots. i will post some of these soon.

Saturday, May 24, 2014

thinkscript included: sdi_seasonalstgy rev:1.2.0 & next 4 day hold on spy

i am hearing from this or that news outlet that the 4-day week following memorial day is bearish. so i am using this opportunity to show to you the best data i can muster regarding this and to improve the study i use to evaluate seasonality. so here is the picture:
p&l of $10k worth of spy buy 'n hold for next 4 days, over last 20 years. 
there are a number of improvements in this version of the study:

  1. the study allows for the input of specific target trading days instead of just the current.
  2. the study defaults to evaluating the next trading day of the year instead of the current. this reduces the influence of open positions on the p&l graph.
  3. the strategy reports on the chart the trading day it bought-to-open a position and the number of trading days it held it when it sold-to-close.
  4. the chart label reports the percentage wins and the number of trades.
  5. the chart label reports the average p&l per trade.
as always i maintain the revised studies on the original release blog here.

Friday, May 16, 2014

thinkscript included: sdi_psarstgy - simulate trading the parabolic-stop-and-reverse signal

i was listening to swimlessons on thinkorswim today and i heard jeff bierman promoting the psar (parabolic-stop-and-reverse) strategy. so i was wondering how this strategy really performs when you add up the wins and losses. this is the inspiration for my new sdi_psarstgy thinkscript strategy and here is what i find with the standard recommended settings of .02 for acceleration factor and .2 for acceleration limit:
p&l of $10k traded by the psar strategy (using standard .02 acceleration-factor and .2 acceleration-limit parameters) on spy compared with growth of  $10k buy 'n hold (bottom green) and dollar-cost-averaging (bottom blue)
the psar strategy lost $746 while buy 'n hold made $1,269 and dollar-cost-averaging made $678 - not exactly a happy picture but jeff did say you need to adjust the acceleration parameters. by tweaking the input parameters to my sdi_psarstgy one can instantly evaluate the effect a modification has to the p&l. here's a setting that turns the above frown upside down:
p&l of psar strategy with acceleration factor of 1.0 and acceleration limit of 0.3

this p&l is nearly the same as buy 'n hold and handily beats dollar-cost-averaging. the acceleration factor of 1.0 says to the psar formula to skip the pretty parabolic movement of the stop and go immediately to the straight-line movement set more aggressively at 0.3

here's the code (install instructions here):
# sdi_psarstgy:
#hint:Strategy to evaluate trading parabolic-stop-and-reverse signals rev:1.1.0
# author: allen everhart
# date: 16may2014
# revisions:
#    4jun2014-added %win label, corrected reverse price on gaps
input dollarsPerTrade = 10000;
#hint dollarsPerTrade: trades vary in share size in order to keep the invested dollars constant to create a fair comparison to passive strategies. rev: 1.1.0
input accelerationFactor = 0.02;
#hint accelerationFactor: controls how steep a parabola is traced by the stop.
input accelerationLimit = 0.2;
#hint accelerationLimit: after the limit is reached the stop moves up in a straight line.

def psar = ParabolicSAR( "acceleration limit" = accelerationLimit, "acceleration factor" = accelerationFactor);
def buySig = close crosses above psar;
def sellSig = close crosses below psar;
def shareSize = round(dollarsPerTrade/psar,0) ;
def buyPrice=#psar;
    if open[-1]>psar then open[-1]
    else psar;
def sellPrice= #psar;
    if open[-1]<psar then open[-1]
    else psar;
AddOrder(OrderType.BUY_AUTO, buySig[-1], price = buyPrice, tradeSize=shareSize, name = "buy");
AddOrder(OrderType.SELL_AUTO, sellSig[-1], price = sellPrice, tradeSize=shareSize, name="short");
plot parSAR = psar;

def longPrice=compoundValue(1,
    if !longPrice[1] && buySig[-1] then buyPrice
    else if longPrice[1] && sellSig[-1] then 0
    else longPrice[1]
#plot lp=longPrice;
def shortPrice=compoundValue(1,
    if !shortPrice[1] && sellSig[-1] then sellPrice
    else if shortPrice[1] && buySig[-1] then 0
    else shortPrice[1]
#plot sp=shortPrice;

def wincntr= compoundValue(1,
    if longPrice[1] && sellSig[-1] && sellPrice>longPrice[1] then wincntr[1]+1
    else if shortPrice[1] && buySig[-1] && shortPrice[1]>buyPrice then wincntr[1]+1
    else wincntr[1]
def winNum=if isnan(wincntr) then winNum[1] else wincntr ;
def losscntr= compoundValue(1,
    if longPrice[1] && sellSig[-1] && sellPrice<=longPrice[1] then losscntr[1]+1
    else if shortPrice[1] && buySig[-1] && shortPrice[1]<=buyPrice then losscntr[1]+1
    else losscntr[1]
def lossNum=if isnan(lossCntr) then lossNum[1] else lossCntr ;

    concat( "win: ", 
    concat( round( 100*winNum/(winNum+lossNum),1),
    concat( "% of ", winNum+lossNum))),