o Just ahead of the close, calculate the 5-day Average True Range of SPY.

o If it’s greater than than the value 10 days ago:

o Multiply the current ATR(5) value by 0.4, and add that to the closing price.

o Buy at EOD if at, or above, that value.

o Sell at the close, very next TD.

I was curios if you’ve written an algorithm for this system of trading that could be used on quantopian. I would love to give it a go.

Thanks! ]]>

I think the formula listed above is off.

Can you check your ATR(1) for 4/10 and for 4/13.

If I run through ThinkOrSwim and calculate the ATR(5) for 4/13/17 it is also 1.7061. So ToS is in sync with your platform.

Next thing I tried was ATR(1) – just to make sure the formula is solid since there’s some smoothing going on with longer time periods

Here are the ToS ATR(1) vs. my calculated ATR(1). I checked with the Yahoo data – it seems even for a single day there’s something wrong on certain days.

Date/TOS/Mine

4-13/1.98/1.98

4-12/1.29/1.29

4-11/2/2

4-10/1.52/1.06

4-7/1.36/0.8

The recent values are in sync but the older ones are strange.

If I manually calculate TR for 4/10 based on Yahoo I get

.92 (H-C)/1.06(H-prevC)/.47(PrevC-L)

The max of this is 1.06.

ThinkOrSwim ATR(1) for 4/10 is 1.52

1.52 is High-Low but not High-Close

Are you using High-Low in your calculations for ATR or strictly the formula listed in your reply?

Are you having trouble getting the ATR to work, or the actual system?

]]>Not that it matters since it doesn’t trade that much but do you know if this is using dividend adjusted data from yahoo or just the regular data – I’m using dividend adjusted – wondering if that make the difference (shouldn’t since SPY only has a quarterly dividend).

]]>