TDAmeritrade StrategyDesk Formula To Exclude First 10 Minutes
I got a great question via email the other day, thought I’d share the topic. It’s been quite a while since I’ve written about (or used) TDAmeritrade StrategyDesk, and it’s now up to v1.3.
When I use StrategyDesk anymore, it’s solely for backtesting. Back in the Spring it was too slow (the updates were sometimes minutes late) to use for hair-trigger daytrading.
This question was specifically for a formula related to daytrading, however. The reader wanted a formula which would show all stocks which are up more than 3%, but only after 9:40 EST, the reasoning being that it would give the market time to “settle out” a bit and not trigger any bad trades during that wild first few minutes.
The following should eliminate all results for the 09:30-09:39:59 period:
((Bar[Hour,10] = 9) * (Bar[Minute,10] = 30) = 0)
The 3% part just goes like this: (Last > (Bar[Close,D,1]*1.03))
So all we do is connect them with an “AND” to get the final version for our screener:
(Last > (Bar[Close,D,1]*1.03)) AND ((Bar[Hour,10] = 9) * (Bar[Minute,10] = 30) = 0)
P.S.For any new visitors looking for more formulas, there’s also the StrategyDesk Formula Reference I wrote months back, before Ameritrade came out with decent user documentation. Enjoy.

StratD Guy said,
September 13, 2007 @ 4:23 pm
Nice info. Can you help me with this:
What is a formula for the following:
After at least one week, sell when the the stock has risen at least 3%.
(ie: dont sell within the first week)
Thanks a lot!
Will said,
September 13, 2007 @ 9:28 pm
StratD Guy,
The only way I know to specify that at least a week has passed is as follows:
Bar[Close,D,1] <> EntryPrice AND Bar[Close,D,2] <> EntryPrice AND Bar[Close,D,3] <> EntryPrice AND Bar[Close,D,4] <> EntryPrice AND Bar[Close,D,5] <> EntryPrice AND Bar[Close,D,6] <> EntryPrice AND Bar[Close,D,7] <> EntryPrice
It’s tedious, but hey, welcome to StrategyDesk. Also, please note that this formula assumes that NO OTHER DAY CLOSES AT EXACTLY THE SAME PRICE AS YOUR ENTRY DAY. If, by some fateful coincidence, the price closes on day 5 (or day 105) at EXACTLY the same price as the day you bought, StrategyDesk will start counting from zero all over. Exercise much caution.
Aside from that, all you’d have to do is add an “AND” and either a “Last” or “Bar[Close]” is greater than 1.03. For example:
(Last > EntryPrice * 1.03) AND Bar[Close,D,1] <> EntryPrice AND Bar[Close,D,2] <> EntryPrice AND Bar[Close,D,3] <> EntryPrice AND Bar[Close,D,4] <> EntryPrice AND Bar[Close,D,5] <> EntryPrice AND Bar[Close,D,6] <> EntryPrice AND Bar[Close,D,7] <> EntryPrice
Hope this helps!
StratD Guy said,
September 13, 2007 @ 9:40 pm
That actually helps a lot, nice job. I can write some pretty advanced trading strategies with Strategy Desk, but for some reason my brain quit on me for this one. Thanks a lot! Great site.
doc40 said,
September 20, 2007 @ 11:19 am
StratD Guy:
There’s a thing called “bad print” where a large tick appears in the SD data stream. Sometimes these are errors that have not been corrected or just one-time trades. I’ve been adding a 1-min ATR to my formulas to prevent triggering on these events. I’ve set the ATRs threshold to 0.1 but may change that as I gain experence using it.
I’ve been backtesting and realtime testing strategies using SD since April and although I now have a strategy I want to use for automatic trading I still don’t trust the data.