Help editing code to base actions on Smoothed Heiken Aishi instead of Impulse MACD

hey

New member
VIP
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:
#
# 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:
Solution
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:
#
# 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)...
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:
#
# 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);

#
Enjoy!


Code:
# --- Smoothed Heiken Ashi (SHA) Candle Logic ---
# Logic: Colors dictated by SHA, Body/Fill dictated by actual Price
# COMPILER FIX: Hard-coded ChartType and Constant Colors

input shaLength = 10;
input paintBars = yes;

# 1. SHA CALCULATION (Recursive)
def avgOpen = ExpAverage(open, shaLength);
def avgHigh = ExpAverage(high, shaLength);
def avgLow = ExpAverage(low, shaLength);
def avgClose = ExpAverage(close, shaLength);

def haClose = (avgOpen + avgHigh + avgLow + avgClose) / 4;
def haOpen = CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (avgOpen + avgClose) / 2);

# 2. TREND DEFINITIONS
def isSHABull = haClose > haOpen;
def isSHABear = haClose < haOpen;
def isPriceGreen = close > open;
def isPriceRed = open > close;

# 3. GLOBAL COLORS
DefineGlobalColor("SHA_Up", Color.UPTICK);
DefineGlobalColor("SHA_Dn", Color.DOWNTICK);

# 4. BASE WICK COLORING
AssignPriceColor(if !paintBars then Color.CURRENT
                 else if isSHABull then GlobalColor("SHA_Up")
                 else if isSHABear then GlobalColor("SHA_Dn")
                 else Color.GRAY);

# 5. CUSTOM CHART OVERLAYS

# --- Case: Price Green / SHA Bullish ---
AddChart(growColor = GlobalColor("SHA_Up"), fallColor = GlobalColor("SHA_Up"),
         high = if isPriceGreen and isSHABull then high else Double.NaN,
         low = low, open = close, close = open, type = ChartType.CANDLE);

# --- Case: Price Green / SHA Bearish ---
AddChart(growColor = GlobalColor("SHA_Dn"), fallColor = GlobalColor("SHA_Dn"),
         high = if isPriceGreen and isSHABear then high else Double.NaN,
         low = low, open = close, close = open, type = ChartType.CANDLE);

# --- Case: Price Red / SHA Bullish ---
AddChart(growColor = GlobalColor("SHA_Up"), fallColor = GlobalColor("SHA_Up"),
         high = if isPriceRed and isSHABull then high else Double.NaN,
         low = low, open = open, close = close, type = ChartType.CANDLE);

# --- Case: Price Red / SHA Bearish ---
AddChart(growColor = GlobalColor("SHA_Dn"), fallColor = GlobalColor("SHA_Dn"),
         high = if isPriceRed and isSHABear then high else Double.NaN,
         low = low, open = open, close = close, type = ChartType.CANDLE);
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Enjoy!


Code:
# --- Smoothed Heiken Ashi (SHA) Candle Logic ---
# Logic: Colors dictated by SHA, Body/Fill dictated by actual Price
# COMPILER FIX: Hard-coded ChartType and Constant Colors

input shaLength = 10;
input paintBars = yes;

# 1. SHA CALCULATION (Recursive)
def avgOpen = ExpAverage(open, shaLength);
def avgHigh = ExpAverage(high, shaLength);
def avgLow = ExpAverage(low, shaLength);
def avgClose = ExpAverage(close, shaLength);

def haClose = (avgOpen + avgHigh + avgLow + avgClose) / 4;
def haOpen = CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (avgOpen + avgClose) / 2);

# 2. TREND DEFINITIONS
def isSHABull = haClose > haOpen;
def isSHABear = haClose < haOpen;
def isPriceGreen = close > open;
def isPriceRed = open > close;

# 3. GLOBAL COLORS
DefineGlobalColor("SHA_Up", Color.UPTICK);
DefineGlobalColor("SHA_Dn", Color.DOWNTICK);

# 4. BASE WICK COLORING
AssignPriceColor(if !paintBars then Color.CURRENT
                 else if isSHABull then GlobalColor("SHA_Up")
                 else if isSHABear then GlobalColor("SHA_Dn")
                 else Color.GRAY);

# 5. CUSTOM CHART OVERLAYS

# --- Case: Price Green / SHA Bullish ---
AddChart(growColor = GlobalColor("SHA_Up"), fallColor = GlobalColor("SHA_Up"),
         high = if isPriceGreen and isSHABull then high else Double.NaN,
         low = low, open = close, close = open, type = ChartType.CANDLE);

# --- Case: Price Green / SHA Bearish ---
AddChart(growColor = GlobalColor("SHA_Dn"), fallColor = GlobalColor("SHA_Dn"),
         high = if isPriceGreen and isSHABear then high else Double.NaN,
         low = low, open = close, close = open, type = ChartType.CANDLE);

# --- Case: Price Red / SHA Bullish ---
AddChart(growColor = GlobalColor("SHA_Up"), fallColor = GlobalColor("SHA_Up"),
         high = if isPriceRed and isSHABull then high else Double.NaN,
         low = low, open = open, close = close, type = ChartType.CANDLE);

# --- Case: Price Red / SHA Bearish ---
AddChart(growColor = GlobalColor("SHA_Dn"), fallColor = GlobalColor("SHA_Dn"),
         high = if isPriceRed and isSHABear then high else Double.NaN,
         low = low, open = open, close = close, type = ChartType.CANDLE);
Thank you, greatly, however, I input the code and it is painting the entire candle the color of the Smoothed heiken aishi and is not coloring the inside of the candles the original colors of the candle's direction as the original code which I posted was able to do. I even tried changing the "yes" to "no" when it asked about painting the bars and it is still doing the same thing. Do you have any suggestions?
 
Thank you, greatly, however, I input the code and it is painting the entire candle the color of the Smoothed heiken aishi and is not coloring the inside of the candles the original colors of the candle's direction as the original code which I posted was able to do. I even tried changing the "yes" to "no" when it asked about painting the bars and it is still doing the same thing. Do you have any suggestions?
Enjoy #2!


Code:
# --- Smoothed Heiken Ashi (SHA) Candle Logic ---
# Logic: Colors dictated by SHA, Body/Fill dictated by actual Price
# COMPILER FIX: Hard-coded ChartType and Constant Colors

input shaLength = 10;
input paintBars = yes;

# 1. SHA CALCULATION (Recursive)
def avgOpen = ExpAverage(open, shaLength);
def avgHigh = ExpAverage(high, shaLength);
def avgLow = ExpAverage(low, shaLength);
def avgClose = ExpAverage(close, shaLength);

def haClose = (avgOpen + avgHigh + avgLow + avgClose) / 4;
def haOpen = CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (avgOpen + avgClose) / 2);

# 2. TREND DEFINITIONS
def isSHABull = haClose > haOpen;
def isSHABear = haClose < haOpen;
def isPriceGreen = close > open;
def isPriceRed = open > close;

# 3. GLOBAL COLORS
DefineGlobalColor("SHA_Up", Color.UPTICK);
DefineGlobalColor("SHA_Dn", Color.DOWNTICK);

# 4. BASE WICK COLORING
AssignPriceColor(if !paintBars then Color.CURRENT
                 else if isSHABull then GlobalColor("SHA_Up")
                 else if isSHABear then GlobalColor("SHA_Dn")
                 else Color.GRAY);

# 5. CUSTOM CHART OVERLAYS
input charttype = ChartType.CANDLE;

# --- Other Visuals ---
plot Bullish = isPriceGreen;
plot Neutral = !isPriceGreen and !isPriceRed;
plot Bearish = isPriceRed;

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

# --- Case: Open < Close ---

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

# --- Case: Open > Close ---

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);
 
Once again, I thank you for the work you've put in on my behalf...but there is only one issue.....this time the borders were painted, but it is the opposite of what I'm trying to achieve. The code makes the inside of the candles reflect the smooth heiken aishi colors and the borders and wicks to reflect the actual price up or price down color. If there is any way for you to reverse it so that the inside body of the candle reflects the price up and down colors and the outside borders and wicks reflect the smooth heiken aishi, I would be much appreciative.
 
Once again, I thank you for the work you've put in on my behalf...but there is only one issue.....this time the borders were painted, but it is the opposite of what I'm trying to achieve. The code makes the inside of the candles reflect the smooth heiken aishi colors and the borders and wicks to reflect the actual price up or price down color. If there is any way for you to reverse it so that the inside body of the candle reflects the price up and down colors and the outside borders and wicks reflect the smooth heiken aishi, I would be much appreciative.
Enjoy 3!

Flopped the growcolor and fallcolor in the addcharts.


Code:
# --- Smoothed Heiken Ashi (SHA) Candle Logic ---
# Logic: Colors dictated by SHA, Body/Fill dictated by actual Price
# COMPILER FIX: Hard-coded ChartType and Constant Colors

input shaLength = 10;
input paintBars = yes;

# 1. SHA CALCULATION (Recursive)
def avgOpen = ExpAverage(open, shaLength);
def avgHigh = ExpAverage(high, shaLength);
def avgLow = ExpAverage(low, shaLength);
def avgClose = ExpAverage(close, shaLength);

def haClose = (avgOpen + avgHigh + avgLow + avgClose) / 4;
def haOpen = CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (avgOpen + avgClose) / 2);

# 2. TREND DEFINITIONS
def isSHABull = haClose > haOpen;
def isSHABear = haClose < haOpen;
def isPriceGreen = close > open;
def isPriceRed = open > close;

# 3. GLOBAL COLORS
DefineGlobalColor("SHA_Up", Color.UPTICK);
DefineGlobalColor("SHA_Dn", Color.DOWNTICK);

# 4. BASE WICK COLORING
AssignPriceColor(if !paintBars then Color.CURRENT
                 else if isSHABull then GlobalColor("SHA_Up")
                 else if isSHABear then GlobalColor("SHA_Dn")
                 else Color.GRAY);

# 5. CUSTOM CHART OVERLAYS
input charttype = ChartType.CANDLE;

# --- Other Visuals ---
plot Bullish = isPriceGreen;
plot Neutral = !isPriceGreen and !isPriceRed;
plot Bearish = isPriceRed;

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

# --- Case: Open < Close ---

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.red, fallColor = Color.green, neutralColor = Color.GRAY, high = h1, low = l1, open = c1, close = o1, type = charttype);

# --- Case: Open > Close ---

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.green, fallColor = Color.RED, neutralColor = Color.GRAY, high = h2, low = l2, open = c2, close = o2, type = charttype);
 
Enjoy 3!

Flopped the growcolor and fallcolor in the addcharts.


Code:
# --- Smoothed Heiken Ashi (SHA) Candle Logic ---
# Logic: Colors dictated by SHA, Body/Fill dictated by actual Price
# COMPILER FIX: Hard-coded ChartType and Constant Colors

input shaLength = 10;
input paintBars = yes;

# 1. SHA CALCULATION (Recursive)
def avgOpen = ExpAverage(open, shaLength);
def avgHigh = ExpAverage(high, shaLength);
def avgLow = ExpAverage(low, shaLength);
def avgClose = ExpAverage(close, shaLength);

def haClose = (avgOpen + avgHigh + avgLow + avgClose) / 4;
def haOpen = CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (avgOpen + avgClose) / 2);

# 2. TREND DEFINITIONS
def isSHABull = haClose > haOpen;
def isSHABear = haClose < haOpen;
def isPriceGreen = close > open;
def isPriceRed = open > close;

# 3. GLOBAL COLORS
DefineGlobalColor("SHA_Up", Color.UPTICK);
DefineGlobalColor("SHA_Dn", Color.DOWNTICK);

# 4. BASE WICK COLORING
AssignPriceColor(if !paintBars then Color.CURRENT
                 else if isSHABull then GlobalColor("SHA_Up")
                 else if isSHABear then GlobalColor("SHA_Dn")
                 else Color.GRAY);

# 5. CUSTOM CHART OVERLAYS
input charttype = ChartType.CANDLE;

# --- Other Visuals ---
plot Bullish = isPriceGreen;
plot Neutral = !isPriceGreen and !isPriceRed;
plot Bearish = isPriceRed;

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

# --- Case: Open < Close ---

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.red, fallColor = Color.green, neutralColor = Color.GRAY, high = h1, low = l1, open = c1, close = o1, type = charttype);

# --- Case: Open > Close ---

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.green, fallColor = Color.RED, neutralColor = Color.GRAY, high = h2, low = l2, open = c2, close = o2, type = charttype);
Once again; I thank you. We are one step closer. The only problem now is that it is painting the borders red when the Smoothed Heiken aishi should be green (when the trend is up) and it is painting the borders green when it is in downtrend). As before, your help is appreciated.
 
Once again; I thank you. We are one step closer. The only problem now is that it is painting the borders red when the Smoothed Heiken aishi should be green (when the trend is up) and it is painting the borders green when it is in downtrend). As before, your help is appreciated.
Hey. Hope this is it. Confirmed that when SHA Bull the borders are green and SHA Bear the borders are red.


Code:
# --- Smoothed Heiken Ashi (SHA) Candle Logic ---
# Logic: Colors dictated by SHA, Body/Fill dictated by actual Price
# COMPILER FIX: Hard-coded ChartType and Constant Colors

input shaLength = 10;
input paintBars = yes;

# 1. SHA CALCULATION (Recursive)
def avgOpen = ExpAverage(open, shaLength);
def avgHigh = ExpAverage(high, shaLength);
def avgLow = ExpAverage(low, shaLength);
def avgClose = ExpAverage(close, shaLength);

def haClose = (avgOpen + avgHigh + avgLow + avgClose) / 4;
def haOpen = CompoundValue(1, (haOpen[1] + haClose[1]) / 2, (avgOpen + avgClose) / 2);

# 2. TREND DEFINITIONS
def isSHABull = haClose > haOpen;
def isSHABear = haClose < haOpen;
def isPriceGreen = close > open;
def isPriceRed = open > close;

# 3. GLOBAL COLORS
DefineGlobalColor("SHA_Up", Color.UPTICK);
DefineGlobalColor("SHA_Dn", Color.DOWNTICK);

# 4. BASE WICK COLORING
AssignPriceColor(if !paintBars then Color.CURRENT
                 else if isSHABull then GlobalColor("SHA_Up")
                 else if isSHABear then GlobalColor("SHA_Dn")
                 else Color.GRAY);

# 5. CUSTOM CHART OVERLAYS
input charttype = ChartType.CANDLE;

# --- Other Visuals ---
plot Bullish = isPriceGreen;
plot Neutral = !isPriceGreen and !isPriceRed;
plot Bearish = isPriceRed;

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

# --- Case: Open < Close ---

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

# --- Case: Open > Close ---

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.green, neutralColor = Color.GRAY, high = h2, low = l2, open = c2, close = o2, type = charttype);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
698 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top