Do you still use the 2,6,10min for spx and amazon or just stick to the 10min? @HypoluxaYou’re welcome!
No, I’ve never tried a timeframe that high. To be honest, I finally made myself move up to 10 mins just a couple of months ago. Lol
Hello, thank you so much for this indicator, it’s very accurate.This indicator (most people called it MACD BB) plots MACD along with the Bollinger Bands as a lower study on your ThinkorSwim chart. The usage is fairly simple and up for interpretation. You can use it to identify short term trends or search for squeeze.
thinkScript Code
Code:# TS_MACD_BB # By Eric Purdy, ThinkScripter LLC # http://www.thinkscripter.com # [email protected] # Last Update 07 Feb 2011 declare lower; input price = close; input BBlength = 10; input BBNum_Dev = 1.0; input MACDfastLength = 12; input MACDslowLength = 26; input MACDLength = 5; def MACD_Data = MACD(fastLength = MACDfastLength, slowLength = MACDslowLength, MACDLength = MACDLength); plot MACD_Dots = MACD_Data; plot MACD_Line = MACD_Data; plot BB_Upper = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).UpperBand; plot BB_Lower = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).Lowerband; plot BB_Midline = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).MidLine; BB_Upper.SetDefaultColor(Color.GRAY); BB_Lower.SetDefaultColor(Color.GRAY); BB_Midline.SetDefaultColor(Color.GRAY); BB_Midline.SetStyle(Curve.SHORT_DASH); MACD_Line.SetDefaultColor(Color.WHITE); MACD_Dots.SetStyle(Curve.POINTS); MACD_Dots.SetLineWeight(2); MACD_Dots.AssignValueColor(if MACD_Line > MACD_Line[1] then Color.White else Color.DARK_RED); plot zero = 0; zero.AssignValueColor(if MACD_Line < 0 then Color.RED else Color.GREEN); zero.SetLineWeight(2);
Shareable Link
https://tos.mx/fK5Zaj
Note: The default Bollinger Bands indicator in ThinkorSwim uses the 20 Simple Moving Average with 2.0 Standard Deviation. If you want to keep it that way make sure you adjust the settings for this indicator.
Got it, thank you!@CaptainCrunch input price = close; Is a standard line in TOS studies. Thus when customizing a study, it will usually show up.
If you are eliminating unneeded lines in a study that you are using. Feel free to attempt to cut that code, if you get no error msgs then it was extraneous. If an error msg occurs, paste it back in. I did most of my learning of scripting in this matter.
Can anyone show me those lines ( For a put...I wait until all 3 have crossed below the bottom line of the Bollinger band and for a call all 3 need to be above the top line of the Bollinger band, ) ..Ben...you're a genius with this indicator! I've been testing it for a week or so and put it to use this week. I've tweaked it with different timeframes 2/6/10 and each has a different setting since it needs to adjust for those timeframes - 2min is 20, 6min is 15 and the 10min is 12. For a put...I wait until all 3 have crossed below the bottom line of the Bollinger band and for a call all 3 need to be above the top line of the Bollinger band, I also use the MACD histogram for additional confirmation - that is set to 48/104/36 on each timeframe.
I'm 3 for 3 this week for $7500 profit. This indicator has made me become very patient, by waiting for the "perfect" moment when they have all crossed over.
Thank you for having the ability to see that indicators like this would be helpful!
Take a look at the strategy I posted back in January. I use these bands, but made adjustments to it.Can anyone show me those lines ( For a put...I wait until all 3 have crossed below the bottom line of the Bollinger band and for a call all 3 need to be above the top line of the Bollinger band, ) ..
Can anyone show me those lines ( For a put...I wait until all 3 have crossed below the bottom line of the Bollinger band and for a call all 3 need to be above the top line of the Bollinger band, ) ..
@BenTen. Hi Ben, I have been wandering in this forum for some time. This MACDBB is simple enough for me to understand 90% of it. There is one line I don't understand, i.e.
"MACD_Dots.AssignValueColor(if MACD_Line > MACD_Line[1] then Color.White"
This condition statement is important for interpretation. What is the meaning of MACD_Line[1] in trading?
From the coding standpoint, MACD_Data is taken from MACD_Data, and MACD_Data is an array returned from the MACD subroutine. So MACD_Line[1] would be the first element of the array. Would MACD_Line[1] change from time to time if I change time range?
Thanks!
def MACD_Data = MACD(fastLength = MACDfastLength, slowLength = MACDslowLength, MACDLength = MACDLength);
plot MACD_Dots = MACD_Data;
plot MACD_Line = MACD_Data;
Hi @RickK thank you so much for posting this! Adding the color settings really helped me. I've been actively day trading this algorithm and it assists me on my exits (which saved me a lot of money in the long run!) I was wondering if there is a way to paint the candle sticks the same color as the MACD line? Meaning if the BollingerBandMACD indicator is showing red/gray/green, the candle sticks could reflect that as well?Thank you very much @BenTen for posting this and @Hypoluxa for sharing your strategy. It looks pretty solid.
I've been monkeying around with it today and became inspired. I'm generally a scalper, so I modified the color settings in the script a bit to guide me. Possibly it could help you or someone else here. It has a bit of a "don't diddle in the middle" vibe.
Edit: Since I posted this, I've made another addition. It is a cloud that displays when there is a standard bollinger/kelter squeeze (aka ttm_squeeze) going on. Just another confirm/deny layer. The new code is now displayed below but it is not displayed in the image shown.
Code:# TS_MACD_BB # By Eric Purdy, ThinkScripter LLC # http://www.thinkscripter.com # [email protected] # Last Update 07 Feb 2011 # modification to color scheme by Rick_K 12/26/20. declare lower; input price = close; input BBlength = 10; input BBNum_Dev = 1.0; input MACDfastLength = 12; input MACDslowLength = 26; input MACDLength = 5; def MACD_Data = MACD(fastLength = MACDfastLength, slowLength = MACDslowLength, MACDLength = MACDLength); plot MACD_Dots = MACD_Data; plot MACD_Line = MACD_Data; plot BB_Upper = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).UpperBand; plot BB_Lower = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).Lowerband; plot BB_Midline = reference BollingerBands(price = MACD_Line, length = BBlength, Num_Dev_Dn = -BBNum_Dev, Num_Dev_Up = BBNum_Dev).MidLine; BB_Upper.SetDefaultColor(Color.CYAN); BB_Lower.SetDefaultColor(Color.CYAN); #BB_Midline.SetDefaultColor(Color.GRAY); #BB_Midline.SetStyle(Curve.SHORT_DASH); #MACD_Line.AssignValueColor(if MACD_Line > MACD_Line[1] then color.green else color.red); MACD_Line.AssignValueColor(if MACD_Line > MACD_Line[1] and MACD_Line >= BB_Upper then Color.GREEN else if MACD_Line < MACD_Line[1] and MACD_Line >= BB_Upper then Color.DARK_GREEN else if MACD_Line < MACD_Line[1] and MACD_Line <= BB_Lower then Color.RED else if MACD_Line > MACD_Line[1] and MACD_Line <= BB_Lower then Color.DARK_RED else Color.GRAY); MACD_Line.SetLineWeight(1); #MACD_Dots.AssignValueColor(if MACD_Line > MACD_Line[1] then Color.green else Color.RED); MACD_Dots.AssignValueColor(if MACD_Line > MACD_Line[1] and MACD_Line > BB_Upper then Color.GREEN else if MACD_Line < MACD_Line[1] and MACD_Line > BB_Upper then Color.DARK_GREEN else if MACD_Line < MACD_Line[1] and MACD_Line < BB_Lower then Color.RED else if MACD_Line > MACD_Line[1] and MACD_Line < BB_Lower then Color.DARK_RED else Color.GRAY); MACD_Dots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS); MACD_Dots.SetLineWeight(2); plot zero = 0; zero.SetDefaultColor(Color.WHITE); zero.SetStyle(Curve.SHORT_DASH); zero.SetLineWeight(1); ## end original (modified) code ######Add Squeeze Cloud########## ###### Keltner Channels input displace = 0; input factor = 1.5; input length = 20; input averageType = AverageType.EXPONENTIAL; input trueRangeAverageType = AverageType.EXPONENTIAL; def shift = factor * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), length); def average = MovingAverage(averageType, price, length); def Avg = average[-displace]; def Upper_Band = average[-displace] + shift[-displace]; def Lower_Band = average[-displace] - shift[-displace]; ######## Bollinger Bands input BBLength2 = 20; input Num_Dev_Dn = -2.0; input Num_Dev_up = 2.0; input bb_averageType = AverageType.SIMPLE; def sDev = StDev(data = price[-displace], length = BBLength2); def MidLine = MovingAverage(bb_averageType, data = price[-displace], length = BBLength2); def LowerBand = MidLine + Num_Dev_Dn * sDev; def UpperBand = MidLine + Num_Dev_up * sDev; ### end of script AddCloud(if UpperBand <= Upper_Band and LowerBand >= Lower_Band then BB_Upper else BB_Lower, BB_Lower, Color.yellow); ### END
# ########################################################
DefineGlobalColor("LabelGreen", CreateColor(0, 165, 0)) ;
DefineGlobalColor("LabelRed", CreateColor(225, 0, 0)) ;
input paintbar = yes ;
AssignPriceColor(
if !paintbar then Color.CURRENT else
if MACD_Line > BB_Upper then GlobalColor("LabelGreen") else
if MACD_Line < BB_Lower then GlobalColor("LabelRed") else
Color.gray);
Interesting strategy.Ben...you're a genius with this indicator! I've been testing it for a week or so and put it to use this week. I've tweaked it with different timeframes 2/6/10 and each has a different setting since it needs to adjust for those timeframes - 2min is 20, 6min is 15 and the 10min is 12. For a put...I wait until all 3 have crossed below the bottom line of the Bollinger band and for a call all 3 need to be above the top line of the Bollinger band, I also use the MACD histogram for additional confirmation - that is set to 48/104/36 on each timeframe.
I'm 3 for 3 this week for $7500 profit. This indicator has made me become very patient, by waiting for the "perfect" moment when they have all crossed over.
Thank you for having the ability to see that indicators like this would be helpful!
Zero line plays a huge part, if you want good trade that moves it have to be over the zero line and under for puts.Interesting strategy.
One question: does the zero line play any part in this?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.