Will anyone help me to edit this code to perform its current function (changing the colors on the borders and wicks of candles) based on the colors of the Smoothed Heiken Aishi instead of changing them based on the colors of the Impulse MACD.
Code:
Code:
Code:
#
# Charles Schwab & Co. (c) 2012-2025
#
input length = 13;
input paintBars = yes;
def EMA = ExpAverage(close, length);
def MACD = ExpAverage(close, 12) - ExpAverage(close, 26);
def MACDHist = MACD - ExpAverage(MACD, 9);
def GreenPrice = EMA > EMA[1] and MACDHist > MACDHist[1];
def RedPrice = EMA < EMA[1] and MACDHist < MACDHist[1];
plot Bullish = GreenPrice;
plot Neutral = !GreenPrice and !RedPrice;
plot Bearish = RedPrice;
Bullish.SetDefaultColor(Color.UPTICK);
Bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Bullish.SetLineWeight(3);
Bullish.hide();
Neutral.SetDefaultColor(Color.BLUE);
Neutral.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Neutral.SetLineWeight(3);
Neutral.hide();
Bearish.SetDefaultColor(Color.DOWNTICK);
Bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Bearish.SetLineWeight(3);
Bearish.hide();
DefineGlobalColor("Bullish", Color.UPTICK);
DefineGlobalColor("Neutral", Color.BLUE);
DefineGlobalColor("Bearish", Color.DOWNTICK);
AssignPriceColor(if !paintBars then Color.CURRENT else if GreenPrice then globalColor("Bullish") else if RedPrice then globalColor("Bearish") else globalColor("Neutral"));
input charttype = ChartType.CANDLE;
def o = open;
def h = high;
def l = low;
def c = close;
def na = double.nan;
def o1 = if o<c then c else na;
def c1 = if o<c then o else na;
def h1 = h;
def l1 = l;
AddChart(growColor = color.green, fallColor = Color.RED, neutralColor = Color.GRAY, high = h1, low = l1, open = c1, close = o1, type = charttype);
def o2 = if o>c then o else double.nan;
def c2 = if o>c then c else double.nan;
def h2 = h;
def l2 = l;
AddChart(growColor = color.red, fallColor = Color.RED, neutralColor = Color.GRAY, high = h2, low = l2, open = c2, close = o2, type = charttype);
#
Last edited by a moderator: