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);