Reasonable_Drag
New member
Hi, I've amalgamated a custom study that gives me either a long or short signal whenever two conditions are met. I currently have it set up to add an up arrow and down arrow to the chart, but I'm trying to figure out a way to create a cloud overlay that shows either a green cloud if I've gotten a long signal and there has not been a subsequent short signal, or a red cloud for the opposite conditions. Can anyone help me?
I've posted the code below. And to clarify, I'm not wanting to create a cloud between the two different HMA lengths, but rather the signals that are generated from the different variables of the HMA lengths. Thanks in advance for any help that can be offered!
I've posted the code below. And to clarify, I'm not wanting to create a cloud between the two different HMA lengths, but rather the signals that are generated from the different variables of the HMA lengths. Thanks in advance for any help that can be offered!
Code:
############
# Second Derivative of HMA on 100 Length
############
input HMAprice = HL2;
input HMA_Length = 100;
input lookback = 2;
def HMA = HullMovingAvg(price = HMAprice, length = HMA_Length);
def delta = HMA[1] - HMA[lookback + 1];
def delta_per_bar = delta / lookback;
def next_bar = HMA[1] + delta_per_bar;
def concavity = if HMA > next_bar then 1 else -1;
def turning_point = if concavity[1] != concavity then HMA else double.nan;
def HMAsellSig = if turning_point and concavity == -1 then high else double.nan;
def HMAbuySig = if turning_point and concavity == 1 then low else double.nan;
def SlowHMABuy; if (HMABuysig) {SlowHMABuy = 1;} else if (HMASellSig) {SlowHMABuy = 0;} else {SlowHMABuy = SlowHMABuy [1];}
def SlowHMASell; if (HMASellSig) {SlowHMASell = 1;} else if (HMABuySig) {SlowHMASell = 0;} else {SlowHMASell = SlowHMASell[1];}
############
# Max and Min Point HMA on 22 Length
############
input HMA22price = HL2;
input HMA22_Length = 22;
input lookback22 = 2;
def HMA22 = HullMovingAvg(price = HMA22price, length = HMA22_Length);
def HMA22sellSig = if HMA22[-1] < HMA22 and HMA22 > HMA22[1] then HMA22 else Double.NaN;
def HMA22buySig = if HMA22[-1] > HMA22 and HMA22 < HMA22[1] then HMA22 else Double.Nan;
def HMA22Buy; if (HMA22Buysig) {HMA22Buy = 1;} else if (HMA22SellSig) {HMA22Buy = 0;} else {HMA22Buy = HMA22Buy [1];}
def HMA22Sell; if (HMA22SellSig) {HMA22Sell = 1;} else if (HMA22BuySig) {HMA22Sell = 0;} else {HMA22Sell = HMA22Sell[1];}
def HMABuy = (SlowHMABuy and HMA22Buy);
def HMASell = (SlowHMASell and HMA22Sell);
##########
# Orders #
##########
def up = HMABuy;
def down = HMASell;
def Hold_Up_Value = if up then 1 else if !down then Hold_Up_Value[1] else 0;
def Hold_Dn_Value = if down then 1 else if !up then Hold_Dn_Value[1] else 0;
#########
# Plots #
#########
plot Signal_Up = if up and Hold_Dn_Value[1] == 1 then low else Double.NaN;
Signal_Up.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Signal_Up.SetDefaultColor (color.GREEN);
Signal_Up.SetLineWeight(5);
plot Signal_Dn = if down and Hold_Up_Value[1] == 1 then high else Double.NaN;
Signal_Dn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Signal_Dn.SetDefaultColor (color.RED);
Signal_Dn.SetLineWeight(5);