MACD & Squeeze Hybrid?

JP782

Active member
Want to test out a theory and Ive been unsuccessful (in bold below) combining the MACD histo with the Squeeze histo (let alone also create one for MTF), in effect creating a hybrid oscillator of the two

Code:
MACD green and Squeeze Lt Blue =  Hybrid Lt Blue
MACD dark green and Squeeze Blue = Hybrid Blue
MACD red and Squeeze red = Hybrid Red
MACD dark red and Squeeze yellow = Hybrid Yellow
When theyre not in sync then light gray or maybe it would be better that no bar is painted
---------------------------------------------
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;
#Diff.SetDefaultColor(GetColor(5));
#Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#Diff.SetLineWeight(3);
#Diff.DefineColor("Positive and Up", Color.GREEN);
#Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
#Diff.DefineColor("Negative and Down", Color.RED);
#Diff.DefineColor("Negative and Up", Color.DARK_RED);
#Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
#####SQUEEZE
input Length = 20; # Length for Avg True Range & Std. Dev Calcs
def Price = Close; # type of price to use
def minPriceMove = 1; # for scaling
def priceIncrement = 0.01;

# -- Plot delta of price from Donchian mid line ----------
# Inertia = LinearRegValue
# scaling factor :
def LHMult = If (priceIncrement <> 0, (minPriceMove / priceIncrement), 0);
def LinearRegValue = Inertia(Price - ((Highest(high, Length) + Lowest(low, Length)) / 2 + ExpAverage(close, Length)) / 2, Length);
#Plot the Green Values
def LRVGreens = If (LinearRegValue >= 0, LinearRegValue, 0);
def BBSqueeze_Pos = LRVGreens * LHMult;
#BBSqueeze_Pos.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#BBSqueeze_Pos.AssignValueColor(if LRVGreens > LRVGreens[1] then CreateColor(0,255,255) else Createcolor(0,40,255));
#BBSqueeze_Pos.SetLineWeight(3);
#Plot the Red Values
def LRVReds = If (LinearRegValue < 0, LinearRegValue, 0);
def BBSqueeze_Neg = LRVReds * LHMult;
#BBSqueeze_Neg.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#BBSqueeze_Neg.AssignValueColor(if LRVReds < LRVReds[1] then Color.Red else CreateColor(255, 136, 97));#changed to orange bc hard to see yellow on white background REDCreateColor(255,95,95)
#BBSqueeze_Neg.SetLineWeight(3);
#0,255,255 Lt Blue #255,95,95 Red  #255,255,95 Yellow  #0,40,255 Blue
###HYBRID
plot test = Diff and BBSqueeze_Pos and BBSqueeze_Neg;
test.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

test.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] and LRVGreens > LRVGreens[1] then Color.cyan else  Color.blue else if Diff < Diff[1] and LRVReds < LRVReds[1] then Color.red else Color.yellow);
 
Solution
Want to test out a theory and Ive been unsuccessful (in bold below) combining the MACD histo with the Squeeze histo (let alone also create one for MTF), in effect creating a hybrid oscillator of the two

Code:
MACD green and Squeeze Lt Blue =  Hybrid Lt Blue
MACD dark green and Squeeze Blue = Hybrid Blue
MACD red and Squeeze red = Hybrid Red
MACD dark red and Squeeze yellow = Hybrid Yellow
When theyre not in sync then light gray or maybe it would be better that no bar is painted
---------------------------------------------
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff...
Want to test out a theory and Ive been unsuccessful (in bold below) combining the MACD histo with the Squeeze histo (let alone also create one for MTF), in effect creating a hybrid oscillator of the two

Code:
MACD green and Squeeze Lt Blue =  Hybrid Lt Blue
MACD dark green and Squeeze Blue = Hybrid Blue
MACD red and Squeeze red = Hybrid Red
MACD dark red and Squeeze yellow = Hybrid Yellow
When theyre not in sync then light gray or maybe it would be better that no bar is painted
---------------------------------------------
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;

def Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;
#Diff.SetDefaultColor(GetColor(5));
#Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#Diff.SetLineWeight(3);
#Diff.DefineColor("Positive and Up", Color.GREEN);
#Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
#Diff.DefineColor("Negative and Down", Color.RED);
#Diff.DefineColor("Negative and Up", Color.DARK_RED);
#Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
#####SQUEEZE
input Length = 20; # Length for Avg True Range & Std. Dev Calcs
def Price = Close; # type of price to use
def minPriceMove = 1; # for scaling
def priceIncrement = 0.01;

# -- Plot delta of price from Donchian mid line ----------
# Inertia = LinearRegValue
# scaling factor :
def LHMult = If (priceIncrement <> 0, (minPriceMove / priceIncrement), 0);
def LinearRegValue = Inertia(Price - ((Highest(high, Length) + Lowest(low, Length)) / 2 + ExpAverage(close, Length)) / 2, Length);
#Plot the Green Values
def LRVGreens = If (LinearRegValue >= 0, LinearRegValue, 0);
def BBSqueeze_Pos = LRVGreens * LHMult;
#BBSqueeze_Pos.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#BBSqueeze_Pos.AssignValueColor(if LRVGreens > LRVGreens[1] then CreateColor(0,255,255) else Createcolor(0,40,255));
#BBSqueeze_Pos.SetLineWeight(3);
#Plot the Red Values
def LRVReds = If (LinearRegValue < 0, LinearRegValue, 0);
def BBSqueeze_Neg = LRVReds * LHMult;
#BBSqueeze_Neg.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
#BBSqueeze_Neg.AssignValueColor(if LRVReds < LRVReds[1] then Color.Red else CreateColor(255, 136, 97));#changed to orange bc hard to see yellow on white background REDCreateColor(255,95,95)
#BBSqueeze_Neg.SetLineWeight(3);
#0,255,255 Lt Blue #255,95,95 Red  #255,255,95 Yellow  #0,40,255 Blue
###HYBRID
plot test = Diff and BBSqueeze_Pos and BBSqueeze_Neg;
test.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

test.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] and LRVGreens > LRVGreens[1] then Color.cyan else  Color.blue else if Diff < Diff[1] and LRVReds < LRVReds[1] then Color.red else Color.yellow);

your plot test = is treating 3 variables as boolean (using and), instead of as numbers

this plots a histogram , add all 3 and divide by 3
replace your plot line with this one
plot test = (Diff + BBSqueeze_Pos +BBSqueeze_Neg)/3;
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
519 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top