LR Bands for Think Or Swim

I've been reading some of the discussions lately on the TTM forum about different types of reversion to the mean stock strategies. One strategy I've been playing around with a bit was suggested by John Carter and expanded upon by Gary_P on the forum. The basic idea is that you buy on pullbacks to the +/- 1 or 2 Std Deviations from the linear regression curve . He was kind enough to provide some Tradestation snippets and I have gone ahead and translated them to TOS for your charting pleasure. Enjoy.



So in the example above, You would have entered on 11/29 at 1168 ~ 1175. Your target would have been 1230 with a stop at 1120 or so. Did I make this trade? No. I had my entry a couple of points too low. C'est La Vive.

#hint:atbLR Bands\nThis script plots the historical values of the Linear Regression channel. A big thanks to the TS code written by Garp_P\n

#hint Length: Length of Channel
#hint NumDevs: Width of Channel in Stdevs.

input Length = 38;
input NumDevs = 2.0;

def SDev = stdev(close,Length) * NumDevs;
plot LR = Inertia(close, Length);

LR.SetDefaultColor(Color.Green);

plot UpperBand = LR + SDev;
UpperBand.SetDefaultColor(Color.Cyan);
UpperBand.SetLineWeight(2);

plot LowerBand = LR - SDev;
LowerBand.SetDefaultColor(Color.Cyan);
LowerBand.SetLineWeight(2);


5 comments:

Unknown said...

Your code for the reversion bands, where you do copy and paste the code so it can be seen on the underlying chart?

Thanks =)

Argus said...

Here is a link that will help you get started: http://team.thinkorswim.com:7001/manual/dark/studies/basic%20operations/preparing.html
From that screen, click NEW and then cut and paste the code.

Call or Put? said...

Andy, thanks so much for this posting. I'm not a code person so this was so helpful. I wonder if there is a similar code for Metastock that is available? Thanks again.

Argus said...

@Henry, I'm not sure about Metastock. I haven't used that product.

jaceemacari said...

Casino, Hotels, & Gaming | MapYRO
Search for Casino, Hotels & 김제 출장마사지 Gaming in Las Vegas, NV. Get 익산 출장안마 directions, reviews and information for Casino, Hotels 원주 출장안마 & Gaming 광명 출장샵 in Las Vegas, NV. 공주 출장마사지