StrategyDesk Formula for Highest Close of Last 5 Days

I haven’t touched StrategyDesk in quite a few days. I’m just burned out on it; I think coding an Apple II in BASIC to do this stuff would be easier. In fact, I know it would. At least we could use the word “IF”, which is apparently too advanced for TDAmeritrade to include in StrategyDesk.

Then this evening I got an email asking about a formula for the highest close of the last “x” days, or the highest open. The PriceRangeChannels function won’t give us that, because it only gives Upper, Lower, and Mid (for whatever the hell good “Mid” is). In other words, highest high, not highest close. Big difference.

I doodled for a few minutes, and here’s what I came up with (it’s getting scary how fast I can spit this junk out now):

(Bar[Close,D] * (Bar[Close,D] > Bar[Close,D,1] AND Bar[Close,D] > Bar[Close,D,2] AND Bar[Close,D] > Bar[Close,D,3] AND Bar[Close,D] > Bar[Close,D,4])) + (Bar[Close,D,1] * (Bar[Close,D,1] > Bar[Close,D] AND Bar[Close,D,1] > Bar[Close,D,2] AND Bar[Close,D,1] > Bar[Close,D,3] AND Bar[Close,D,1] > Bar[Close,D,4])) + (Bar[Close,D,2] * (Bar[Close,D,2] > Bar[Close,D] AND Bar[Close,D,2] > Bar[Close,D,1] AND Bar[Close,D,2] > Bar[Close,D,3] AND
Bar[Close,D,2] > Bar[Close,D,4])) + (Bar[Close,D,3] * (Bar[Close,D,3] > Bar[Close,D] AND Bar[Close,D,3] > Bar[Close,D,1] AND Bar[Close,D,3] > Bar[Close,D,2] AND Bar[Close,D,3] > Bar[Close,D,4])) + (Bar[Close,D,4] * (Bar[Close,D,4] > Bar[Close,D] AND Bar[Close,D,4] > Bar[Close,D,1] AND Bar[Close,D,4] > Bar[Close,D,2] AND Bar[Close,D,4] > Bar[Close,D,3]))

That will give you the highest close of the last 5 days. Do a “find and replace” on it with “open” replacing “close”, and voila, highest open of the last 5 days (much less useful than highest close, but someone may want it).

To find the highest open or close of the last 10 days, copy the above formula and follow its pattern to make a formula which is two million characters long instead of one million. Email me if you need help, or better yet, post questions in the comments to this, um, post, and we’ll hash it out with the help of all our fellow StrategyDesk haters fans.


3 Comments

  1. BNJ said,

    April 11, 2007 @ 9:53 am

    Now isn’t that just a pain in the ass? And God forbid that you might have to reference that quantity more than once in your formula. You’d end up copying and pasting the whole goddamn thing, because God forbid that they let you store anything in variables.

    But anyway….

    I don’t want to bust *too* much on SD, because it still:

    1. Allows backtesting against a fairly complete database of intraday historical data,

    2. Allows you to place orders and automate trades,

    3. And is free.

    And apparently maintained at least to *some* extent. Sooner or later, when I get a bit more money and a lot more time, I’ll probably bail in favor of TradeStation, but in the meantime, SD is a better tool than I had previously.

  2. BNJ said,

    April 13, 2007 @ 6:02 pm

    Say, I don’t know if you’ve noticed or not, but StrategyDesk 1.2 is out. I’m not sure what all the chages are (have they ever heard of release notes?) but one thing I *have* noticed is that all the forumulas and strategies are now stores as xml rather than their proprietary format. That’s something, I guess. I’ll take what I can get.

  3. Will said,

    April 13, 2007 @ 8:47 pm

    BNJ - Yep, got the email, and from the looks of that, they’ve specifically (coincidentally?) addressed some of the problems we’ve published publicly. I’m going to download it and try it out tomorrow.

RSS feed for comments on this post