Monday, April 27, 2015

souping thinkorswim: run two instances.

you can run two instances of the thinkdesktop from the same computer. that is, i run a second thinkdesktop and log-in twice. two is permitted by the tda servers but i think a 3rd instance will trigger a failure.  i just tried this today from a single laptop and it worked great. on one instance i had all my normal gadgets, watchlists w. custom columns, charts, studies and strategies running. on the second instance i deleted all gadgets, watchlists and displayed no charts - but i ran the shadow trader presentation from this second instance.

previously, i ran all this stuff including the shadow trader presentation from a single instance and was getting pesky long pauses when the garbage collector ran. my observations of the task manager during these gc-pauses revealed that one of my dual cpu's was running flat-out while the other one was idle - giving the misimpression of a non-constrained cpu resource (50% idle.) research on oracle's website revealed some interesting facts about the java garbage collecter that led me to this dual- instance experiment:

  1. the java heap does not maintain a linked-list of free memory blocks. free memory is one contiguous block that is doled out as requested.
  2. the more objects in use the longer the gc takes to run. this is because there is no freelist. instead, the gc performs a tree-search of live objects, marking them as it sweeps through the list, then, infers that anything not marked as 'alive' is trash. the more live objects there are, the longer this takes.
  3. trash compaction is part of every gc run. again, because there is no free-list, all live objects are moved around so that the free memory is one contiguous space at the end of a gc run. this might put a write-load on the page-file but that is why i went with the solid state disk.
  4. the garbage collector is single threaded. no matter how many concurrent threads the application codes for, the gc is mostly a single threaded affair that puts all application threads into suspension while it runs. this explains why i see one cpu pinned-out while the other is idle.
so now, with the dual tos instances, i have two heaps and the possibility of dual garbage collection with fuller cpu utilization. each heap has fewer live objects to contend with, so the gc-pauses are much smaller - and at least i can listen to brad agunas while i am waiting.


Saturday, April 25, 2015

thinkscript included: sdi_advmLabel - average dollar volume in millions label

some people claim you should select only stocks that trade a million shares a day. however, there are plenty of penny-stocks that trade a million shares for which it is prudent to stay away from. also, there are worthwhile high priced stocks that trade fewer than a million shares. it is my contention that this million-share selection criterion is an approximation for average dollar-volume (adv) or the average price multiplied by the average share-volume. so i wrote a chart label that displays this value. here's what this looks like:
spy with sdi_advmLabel
the 'M' in the label stands for millions. so the spy etf represents how 20 billion dollars changes hands per day, on average, over the last 20 days. if you use a $10 price minimum in conjunction with the 1million share criterion then what you are really looking for is a stock that has an average-dollar-volume of 10 million, so why not just look for that?

here's the code:

Wednesday, April 1, 2015

how now dow/gold?

the dow/gold ratio expresses the value of the dow in terms of a commodity that has a relatively fixed store of value. economists look at the dow/gold to get an idea of how the economy is doing ex-inflation and ex-monetary policy. here's how this looks:



we are channeling to the upside but just revisiting a resistance level from 2008. the larger picture of this has formed a large cup as in the cup 'n handle pattern which you can see in this big-picture. if we are following that pattern we should see a break above 15.2, perhaps to 16ish, followed by a shallow pullback. the break of that 16ish resistance should produce a rally to higher levels which technical analysis would predict to be around 26. all this means: dow up, gold down.