I added another moving average and ATR based bands to the TrendFusion indicator. There are trade signals if you turn them on. Default averages are 35 and 63, but feel free to change them to your favorite averages. The bands are based on the "maPeriod" average. Trade signals can also be adjusted by changing the dmiPeriod and adx levels. You can view long and short signals, or just turn on long or short in the settings under "tradeType". This is a good trend indicator that also gives you good areas where price could be extended. Here is a picture of /GC on the four hour chart.
Code:
# TrendFusion with Bands (ThinkScript Conversion)
# Assembled by Chewie 9/1/2025
declare upper;
#----------------------------
# Inputs
#----------------------------
input colorbar = yes;
input showsignals = no;
input bands = yes;
input maPeriod = 35;
input maPeriod2 = 63;
input maType = {default EMA, SMA, WMA, ZLEMA, LinReg};
input dmiPeriod = 7;
input adxSmoothing = 14;
input adxTrendLevel = 21;
input tradeType = {default LongAndShort, Long, Short};
#----------------------------
# Functions
#----------------------------
script ZLEMA {
input price = close;
input length = 35;
def lag = (length - 1) / 2;
def emaData = price + price - price[lag];
plot out = ExpAverage(emaData, length);
}
def ma;
switch (maType) {
case SMA:
ma = Average(close, maPeriod);
case EMA:
ma = ExpAverage(close, maPeriod);
case WMA:
ma = WMA(close, maPeriod);
case ZLEMA:
ma = ZLEMA(close, maPeriod);
case LinReg:
ma = Inertia(close, maPeriod);
}
def ma2;
switch (maType) {
case SMA:
ma2 = Average(close, maPeriod2);
case EMA:
ma2 = ExpAverage(close, maPeriod2);
case WMA:
ma2 = WMA(close, maPeriod2);
case ZLEMA:
ma2 = ZLEMA(close, maPeriod2);
case LinReg:
ma2 = Inertia(close, maPeriod2);
}
# DMI & ADX
def diPlus = DIPlus(dmiPeriod);
def diMinus = DIMinus(dmiPeriod);
def adx = ADX(adxSmoothing);
# Trend Conditions
def trendUp = adx > adxTrendLevel and diPlus > diMinus and ma > ma[1];
def trendDown = adx > adxTrendLevel and diPlus < diMinus and ma < ma[1];
#----------------------------
# Signals
#----------------------------
def isLong = trendUp and !trendUp[1] and tradeType != tradeType.Short;
def isShort = trendDown and !trendDown[1] and tradeType != tradeType.Long;
def isExitLong = trendUp[1] and !trendUp and tradeType != tradeType.Short;
def isExitShort = trendDown[1] and !trendDown and tradeType != tradeType.Long;
#----------------------------
# Plotting
#----------------------------
plot MAline = ma;
maline.setlineWeight(2);
maline.assignvalueColor(if close > maline then color.green else color.red);
plot MAline2 = ma2;
maline2.setlineWeight(2);
maline2.assignvalueColor(if close > maline2 then color.green else color.red);
AddCloud(ma2, ma, Color.DARK_RED, Color.CURRENT);
AddCloud(ma, ma2, Color.DARK_GREEN, Color.CURRENT);
plot long = if showsignals then islong else double.nan;
long.SetDefaultColor(Color.CYAN);
long.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_UP);
plot longE = if showsignals and isExitLong then high + ATR(60) / 2 else Double.NaN;;
longE.SetDefaultColor(Color.CYAN);
longE.SetPaintingStrategy(PaintingStrategy.POINTS);
plot short = if showsignals then isshort else double.nan;
short.SetDefaultColor(Color.magenta);
short.SetPaintingStrategy(PaintingStrategy.boolean_ARROW_down);
plot shortE = if showsignals and isExitShort then low - ATR(60) / 2 else Double.NaN;
shortE.SetDefaultColor(Color.magenta);
shortE.SetPaintingStrategy(PaintingStrategy.POINTS);
#Bands
input atrMultiplier1 = 2;
input atrMultiplier2 = 4;
input atrLength = 200;
def source = FundamentalType.CLOSE;
def src = Fundamental(source);
def ATR = atr(Length = ATRlength);
def emaup = MAline + (ATR*atrMultiplier1);
def emadw = MAline - (ATR*atrMultiplier1);
def emaup2 = MAline + (ATR*atrMultiplier2);
def emadw2 = MAline - (ATR*atrMultiplier2);
plot Up = if bands then emaup else Double.NaN;
plot Dn = if bands then emadw else Double.NaN;
plot Up2 = if bands then emaup2 else Double.NaN;
plot Dn2 = if bands then emadw2 else Double.NaN;
up.setdefaultColor(color.dark_orange);
up2.setdefaultColor(color.magenta);
dn.setdefaultColor(color.light_green);
dn2.setdefaultColor(color.cyan);
AssignPriceColor(if colorbar and close >up2 then color.magenta else if close < dn2 then color.cyan else if close > maline2 then Color.GREEN else if close < maline2 then color.red else Color.current);