Hello, part of the indicator that I'm writing includes a background via AddCloud that colors itself based on the strength of the trend (roughly: "weak bullish", "strong bullish", "weak bearish", "strong bearish", or "none").
The cloud takes into account whether MACD is > 0 or not, the MACD diff, and what the ADX is.
The issue I'm trying to solve is: when the trend changes (most commonly from the MACD diff flipping +/-), AddCloud leaves a gap between the previous cloud and the new cloud. Why is that? What's the best way to fill the gap? I've tried a few things unsuccessfully, so I'm asking for help here.
If you look closely, the gap is between candles, when one of the conditions changes (easiest to see when MACD line crosses the signal line).
Here's the relevant code:
Related: I've also seen similar uses of AddCloud where the transition between the different values has a "triangular" look to it instead of just cutting off abruptly:
I cannot figure out how to replicate this either.
Any help would be much appreciated!
The cloud takes into account whether MACD is > 0 or not, the MACD diff, and what the ADX is.
The issue I'm trying to solve is: when the trend changes (most commonly from the MACD diff flipping +/-), AddCloud leaves a gap between the previous cloud and the new cloud. Why is that? What's the best way to fill the gap? I've tried a few things unsuccessfully, so I'm asking for help here.

If you look closely, the gap is between candles, when one of the conditions changes (easiest to see when MACD line crosses the signal line).
Here's the relevant code:
Code:
declare lower;
input OverboughtOversold = 0.8;
def macd = MACD(fast_length = 12, slow_length = 26, macd_length = 9);
def adx = ADX(14);
def bulltrend = macd().Diff < 0 and macd > 0 and adx > 20;
def beartrend = macd().Diff > 0 and macd < 0 and adx > 20;
def strongbulltrend = macd().Diff > 0 and macd > 0 and adx > 20;
def strongbeartrend = macd().Diff < 0 and macd < 0 and adx > 20;
def bullcloudL = if bulltrend then OverboughtOversold else Double.NaN;
def bullcloudH = if bulltrend then -OverboughtOversold else Double.NaN;
AddCloud(bullcloudL, bullcloudH, Color.DARK_GREEN, Color.DARK_RED, yes);
def bearcloudL = if beartrend then OverboughtOversold else Double.NaN;
def bearcloudH = if beartrend then -OverboughtOversold else Double.NaN;
AddCloud(bearcloudL, bearcloudH, Color.DARK_RED, Color.DARK_GREEN, yes);
def strongbullcloudL = if strongbulltrend then OverboughtOversold else Double.NaN;
def strongbullcloudH = if strongbulltrend then -OverboughtOversold else Double.NaN;
AddCloud(strongbullcloudL, strongbullcloudH, Color.GREEN, Color.RED, yes);
def strongbearcloudL = if strongbeartrend then OverboughtOversold else Double.NaN;
def strongbearcloudH = if strongbeartrend then -OverboughtOversold else Double.NaN;
AddCloud(strongbearcloudL, strongbearcloudH, Color.RED, Color.GREEN, yes);
Related: I've also seen similar uses of AddCloud where the transition between the different values has a "triangular" look to it instead of just cutting off abruptly:

I cannot figure out how to replicate this either.
Any help would be much appreciated!