Standard Deviation Bands Enhanced for ThinkorSwim

horserider

Well-known member
VIP
The idea is the deviations are 1.3 (65%)and 2(98%) of prices. Prices breaking into or above or below these zones (red and Green) are extended and may signal a reversal soon. There is a safe holding zone in light gray for buys and dark gray for sells. Can trade on breaks of 1.3 line or once you are in a move up or down you can hold till safe zones are exited. Threw in some arrows for all the arrow fans.

Just be careful when price closes outside the bands. Instead of reversing it may ride the bands up or down.

ofL6ISy.png


Code:
# Enhanced Standard Deviation Bands by Horserider 9/21/2019
# Two standard TD Ameritrade IP Company, Inc. (c) 2019 StandardDeviation studies      combined into one study with deviations being 1.3 and 2.0 . User changeable length, dev, and avg type to suit their trading.
#
# Inner bands
input length = 20;
input numDevDn = -1.3;
input numDevUp = 1.3;
input averageType = AverageType.EXPONENTIAL;

def avg = MovingAverage(averageType, close);
def expDev = ExpAverage(AbsValue(avg - close), length);

plot UpperBand = avg + numDevUp * expDev;
plot MidLine = avg;
plot LowerBand = avg + numDevDn * expDev;

UpperBand.SetDefaultColor(GetColor(1));
MidLine.SetDefaultColor(GetColor(1));
MidLine.SetStyle(Curve.SHORT_DASH);
LowerBand.SetDefaultColor(GetColor(1));

# Outer bands
input lengthob = 20;
input numDevDnob = -2.0;
input numDevUpob = 2.0;
input averageTypeob = AverageType.EXPONENTIAL;

def avgob = MovingAverage(averageTypeob, close);
def expDevob = ExpAverage(AbsValue(avgob - close), lengthob);

plot UpperBandob = avgob + numDevUpob * expDevob;
#plot MidLineob = avgob;
plot LowerBandob = avgob + numDevDnob * expDevob;

UpperBandob.SetDefaultColor(GetColor(1));
#MidLineob.SetDefaultColor(GetColor(1));
#MidLineob.SetStyle(Curve.SHORT_DASH);
LowerBandob.SetDefaultColor(GetColor(1));


# Clouds for safe zones Light gray for long, dark gray for short.
AddCloud (midline,upperbandob, Color.lIGHT_GRAY, Color.lIGHT_GRAY);
AddCloud(midline, lowerband, Color.GRAY, Color.GRAY);

# Clounds for areas of possible reversals. Green for longs, red for shorts.
AddCloud( upperband,upperbandob, Color.LIGHT_RED, Color.LIGHT_RED);
AddCloud( lowerband,lowerbandob, Color.LIGHT_GREEN, Color.LIGHT_GREEN);

# Plot arrows for close crosses of Deviation lines. Indside plum, Outside red/green Arrows included because many like arrows. I suggest being careful following any arrow signal.
plot UpSignalob =  close crosses below   lowerbandob ;
plot DownSignalob = close crosses above upperbandob;

plot UpSignal =  close crosses   lowerband ;
plot DownSignal = close crosses  upperband;

UpSignal.SetDefaultColor(Color.PLUM);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.PLUM);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

UpSignalob.SetDefaultColor(Color.UPTICK);
UpSignalob.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignalob.SetDefaultColor(Color.DOWNTICK);
DownSignalob.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
Last edited by a moderator:

Thomas

Active member
VIP
Hahaha,..just threw it together and with added arrows...........I tightened up the bands, with the reversal arrows,.......one more point, the reversal is not valid until AFTER a colored candle is created. I place an alert on top or bottom of the colored candle body, used as an "entry," when arrow generates up or down.
lKqEIFJ.jpg
 

Ramesh16

Member
VIP
Hahaha,..just threw it together and with added arrows...........I tightened up the bands, with the reversal arrows,.......one more point, the reversal is not valid until AFTER a colored candle is created. I place an alert on top or bottom of the colored candle body, used as an "entry," when arrow generates up or down.
lKqEIFJ.jpg
could u pl share the code-Thanks
 

Dom173

New member
VIP
The idea is the deviations are 1.3 (65%)and 2(98%) of prices. Prices breaking into or above or below these zones (red and Green) are extended and may signal a reversal soon. There is a safe holding zone in light gray for buys and dark gray for sells. Can trade on breaks of 1.3 line or once you are in a move up or down you can hold till safe zones are exited. Threw in some arrows for all the arrow fans.

Just be careful when price closes outside the bands. Instead of reversing it may ride the bands up or down.

ofL6ISy.png


Code:
# Enhanced Standard Deviation Bands by Horserider 9/21/2019
# Two standard TD Ameritrade IP Company, Inc. (c) 2019 StandardDeviation studies      combined into one study with deviations being 1.3 and 2.0 . User changeable length, dev, and avg type to suit their trading.
#
# Inner bands
input length = 20;
input numDevDn = -1.3;
input numDevUp = 1.3;
input averageType = AverageType.EXPONENTIAL;

def avg = MovingAverage(averageType, close);
def expDev = ExpAverage(AbsValue(avg - close), length);

plot UpperBand = avg + numDevUp * expDev;
plot MidLine = avg;
plot LowerBand = avg + numDevDn * expDev;

UpperBand.SetDefaultColor(GetColor(1));
MidLine.SetDefaultColor(GetColor(1));
MidLine.SetStyle(Curve.SHORT_DASH);
LowerBand.SetDefaultColor(GetColor(1));

# Outer bands
input lengthob = 20;
input numDevDnob = -2.0;
input numDevUpob = 2.0;
input averageTypeob = AverageType.EXPONENTIAL;

def avgob = MovingAverage(averageTypeob, close);
def expDevob = ExpAverage(AbsValue(avgob - close), lengthob);

plot UpperBandob = avgob + numDevUpob * expDevob;
#plot MidLineob = avgob;
plot LowerBandob = avgob + numDevDnob * expDevob;

UpperBandob.SetDefaultColor(GetColor(1));
#MidLineob.SetDefaultColor(GetColor(1));
#MidLineob.SetStyle(Curve.SHORT_DASH);
LowerBandob.SetDefaultColor(GetColor(1));


# Clouds for safe zones Light gray for long, dark gray for short.
AddCloud (midline,upperbandob, Color.lIGHT_GRAY, Color.lIGHT_GRAY);
AddCloud(midline, lowerband, Color.GRAY, Color.GRAY);

# Clounds for areas of possible reversals. Green for longs, red for shorts.
AddCloud( upperband,upperbandob, Color.LIGHT_RED, Color.LIGHT_RED);
AddCloud( lowerband,lowerbandob, Color.LIGHT_GREEN, Color.LIGHT_GREEN);

# Plot arrows for close crosses of Deviation lines. Indside plum, Outside red/green Arrows included because many like arrows. I suggest being careful following any arrow signal.
plot UpSignalob =  close crosses below   lowerbandob ;
plot DownSignalob = close crosses above upperbandob;

plot UpSignal =  close crosses   lowerband ;
plot DownSignal = close crosses  upperband;

UpSignal.SetDefaultColor(Color.PLUM);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.PLUM);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

UpSignalob.SetDefaultColor(Color.UPTICK);
UpSignalob.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignalob.SetDefaultColor(Color.DOWNTICK);
DownSignalob.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

looks awesome @horserider .. does this indicator repaint? I used to use a similar strategy with TriangularMA and ATR but it repainted which wasn't ideal.. see image below.. I used renko bars with a fast MA line.. when the price crossed the middle outer band, it signaled an entry. I also used PSAR to confirm reversals. Some other indicators also if you care to discuss. I haven't been able to recreate it in TOS yet. What are your thoughts?

2izeyWb.jpg
 

horserider

Well-known member
VIP
Not used Renko bars. That strategy is good if you are profitable using it. Not something I would like but that is just personal preference.
I looked at some renko charts. Trends show nicely. I may watch them a bit.
 

zeek

Active member
2019 Donor
I am playing around with this study today and trying different deviations on different timeframes, some interesting observations so far.
I really like it for scalping on 1min timeframe.
 

Dom173

New member
VIP
@Dom173 is that MT4 or MT5? If MT4 would you mind sharing the ex4 for the bands? I don't want to code them over (lazy I know)

Sure @tradebyday I don't mind sharing.. as long as you let me know how you get on.. @horserider you're welcome to have a look too so you can perhaps compare the triangular MA to the deviation bands... I also think you'll like renkos once you've had a chance to tweak them to a favorable setting.. (also note i was using this strategy to trade currencies originally)

I tend to use the following settings:
median renko 20.0 (0.2 retracement, 14 ATR period)
3 FastTMALine (ATR multipliers 1.5, 2, 2.5)
stoch color candles
MA (2)
TMA Half Length 100
TMA Price 0
TMA ATR Length 500
TMA ATR Multiplier 2.0


ENTER
MA (2) touches outer FastTMA line (ATR multiplier 2)

EXIT
MA (2) touches center FastTMA line

see the link for the .ex4 and .tpl files... let me know what you find and if you need anything else. I'm only on Mac at the time being so not able to load any of the files myself..

https://we.tl/t-fntPoDSZE5
 
Last edited:

tradebyday

Active member
@Dom173 appreciate the share, and I had never heard of WeShare but I will be keeping them in my back pocket as well haha. Two questions. 1) What do you mean by "as long as you let me know how you get on"? Just genuinely confused by the statement. 2) I noticed there was an EA in the file but as a .tpl format. So does that run, and if so, is it the entire strategy or just another piece of the puzzle?... Ok maybe that is technically three questions haha. But just to make you aware, I enjoy testing out new things, new ideas and searching for something that screams "I'm done!" So I am stockpiling indicators, ideas, and data overall that I hope leads to something truly worthwhile. MT4 has the added bonus of EA's (trading robots for others reading) which i am curious about applying to FX in the future
 

Dom173

New member
VIP
@Dom173 appreciate the share, and I had never heard of WeShare but I will be keeping them in my back pocket as well haha. Two questions. 1) What do you mean by "as long as you let me know how you get on"? Just genuinely confused by the statement. 2) I noticed there was an EA in the file but as a .tpl format. So does that run, and if so, is it the entire strategy or just another piece of the puzzle?... Ok maybe that is technically three questions haha. But just to make you aware, I enjoy testing out new things, new ideas and searching for something that screams "I'm done!" So I am stockpiling indicators, ideas, and data overall that I hope leads to something truly worthwhile. MT4 has the added bonus of EA's (trading robots for others reading) which i am curious about applying to FX in the future

No worries at all... "as long as you let me know how you get on" just meant keep me posted on your progress as I'm interested.. to answer your other questions, yes there was also an EA that was a part of the project I was working on. I can send you that file also if you're interested. I sent the template in hopes that it would allow you to load all the indicators but as I said I'm rusty on the mt4 stuff nowadays.. I too was in search of a holy grail strategy when I set out on this project...

Just FYI, the premise behind the strategy is just using the fast MA (2) and the renko bars and TMA lines. When the fast MA crosses the 2nd outer TMA lane, it signals an entry. Then for every 10 pips outside that entry, is another entry (averaging down) for as many times as you select. Then the exit is signaled either at the middle TMA line or the opposite side 1st outer band. The extra indicators, like the RSI and the w3a deviation were used to signal a good entry point by confirming the end of the trend and a reversal point to try and eliminate averaging down and just have 1 entry at the w3A "3" confirmation and when the RSI is overbought or oversold.

In hind sight, the TMA bands are gorgeous to look at but in real-time the downfall is that they repaint so they are not as accurate as they seem (hence my interest in this thread - a similar indicator that doesn't repaint, but it turns out is not as sexy). At the time I also tried bollinger bands and donchian channels. TMAs work great but not to perfection as it seems like it would when you look back at a chart. The EA may also not be the best to use, perhaps manually trading the strategy will work better but I haven't had time to test that theory. That is why I am willing to share this info and the files for free (I paid quite a fair amount originally to have the strategy coded and tested multiple rounds).

anyway, the indicators you need are the following:
1) renko bars
2) stochastic color candles
3) w3a deviation
4) triangularMA
5) MA (2)
6) ParabolicSAR
7) StochasticRSI

Here is a photo of the EA inputs:
C18uKIv.jpg


Here is a link to the EA:
https://we.tl/t-9oBYwn9oDY
Let me know how you make out or your thoughts & questions.. wouldn't mind screenshots also.. would be cool to see this work again
 

tradebyday

Active member
@Dom173 I'll check it out. Got the TMAcentered running and already off first glance I see a way to run a system with it alone. When I first load it it just as 1 center line and 1 outer line on each side like a basic channel. But what I noticed, on a 15min chart, if you entered when price hit one of the outer lines and then exit at center line, the win percentage is extremely high, and most losses are not very big or near break even. Now I don't know if the 15-50 pips approx 2 times a day on most pairs covers all the fees and slippage, but I was really impressed and want to make that an EA of its own to run for experimentation. Been taking on a lot of projects at once so I need to make a list and tackle each one individually but I will try to let you know how everything fairs
 

Dom173

New member
VIP
@Dom173 I'll check it out. Got the TMAcentered running and already off first glance I see a way to run a system with it alone. When I first load it it just as 1 center line and 1 outer line on each side like a basic channel. But what I noticed, on a 15min chart, if you entered when price hit one of the outer lines and then exit at center line, the win percentage is extremely high, and most losses are not very big or near break even. Now I don't know if the 15-50 pips approx 2 times a day on most pairs covers all the fees and slippage, but I was really impressed and want to make that an EA of its own to run for experimentation. Been taking on a lot of projects at once so I need to make a list and tackle each one individually but I will try to let you know how everything fairs

sounds good.. you can also tweak the EA I sent you and the work is done.. just set all the other inputs to "false".. dont forget to send screenshots. look forward to seeing the progress..

wonder if I can get someone here to code the TMA bands for TOS
 

tradebyday

Active member
@Dom173 I'll have to figure out how to get images up but definitely will do! The TMA bands would be a generally easy code to form. The main thing is having the math for the center line accurate, then just input a plot for something like "plot upperline = centerline + q" where q = ATR factor x ATR , then vice versa for lower line
 

Dom173

New member
VIP
@Dom173 I'll have to figure out how to get images up but definitely will do! The TMA bands would be a generally easy code to form. The main thing is having the math for the center line accurate, then just input a plot for something like "plot upperline = centerline + q" where q = ATR factor x ATR , then vice versa for lower line

awesome.. that's out of my depths a bit but if you or someone else is willing to help I'd appreciate that.

the tutorial to upload images by BenTen is here:
https://usethinkscript.com/threads/how-to-insert-image-in-a-post-thread.277/post-1609
 

Similar threads

Top