Change Candle Fill Color But Not Outline?

mak

New member
Is this the correct page for the "Impulse" indicator on ThinkorSwim? The one described at this link: https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/G-L/Impulse

I love this indicator, however, I wanted to see if there is a way to paint only the body of the candle so that the original color of the candle can still be identified by the border. Since the option to distinguish between border and body (fill) exists in "Appearance" under "Chart Settings", I figured there must be a way to accomplish this by adding to the "Impulse" code.

Can anyone please help provide a piece of code that could be added to the following script or edit the script so that either the color of the body/fill of the candle or the border color would change, but NOT both. This way, for example, if the original candle was green/red but was designated neutral/green/red by the indicator, you would still be able to see both the original color as the border or fill AND the repainted color as the border or fill. Hope that makes sense. Please, let me know if you need me to clarify. Thank you for your help!

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

Screenshot 2025-08-06 132719.png
 
Last edited by a moderator:
Solution
Is this the correct page for the "Impulse" indicator on ThinkorSwim? The one described at this link: https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/G-L/Impulse

I love this indicator, however, I wanted to see if there is a way to paint only the body of the candle so that the original color of the candle can still be identified by the border. Since the option to distinguish between border and body (fill) exists in "Appearance" under "Chart Settings", I figured there must be a way to accomplish this by adding to the "Impulse" code.

Can anyone please help provide a piece of code that could be added to the following script or edit the script so that either the color of the body/fill of the candle...
@mak Your concept of changing only the candle body and not the outline and wicks is not possible via Thinkscript as there is no Function to perform this task - so the answer is No...
 
Is this the correct page for the "Impulse" indicator on ThinkorSwim? The one described at this link: https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/G-L/Impulse

I love this indicator, however, I wanted to see if there is a way to paint only the body of the candle so that the original color of the candle can still be identified by the border. Since the option to distinguish between border and body (fill) exists in "Appearance" under "Chart Settings", I figured there must be a way to accomplish this by adding to the "Impulse" code.

Can anyone please help provide a piece of code that could be added to the following script or edit the script so that either the color of the body/fill of the candle or the border color would change, but NOT both. This way, for example, if the original candle was green/red but was designated neutral/green/red by the indicator, you would still be able to see both the original color as the border or fill AND the repainted color as the border or fill. Hope that makes sense. Please, let me know if you need me to clarify. Thank you for your help!

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

View attachment 25374

[Edited to include wicks]
Using the unsupported addchart() function the candle border,including wicks, can reflect the original color of the candle. Regrettably, we cannot control the thickness of the border.

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

#
 

Attachments

  • Screenshot 2025-08-20 124142.png
    Screenshot 2025-08-20 124142.png
    85.7 KB · Views: 16
Last edited:
Solution
@SleepyZ Yeah, I didn't bother mentioning AddChart() due to it's lack of documentation and the fact that while it can change the border color it cannot change the color of the wicks... I keep a couple example scripts kicking around so I don't have to retrain myself how the function works every time there is a need for some AddChart() code...
 
The body, body outline, upper wick, and lower wick can all be changed independently. But, a lot of it can not be changed dynamically within the function's parameters. You have to overlay the function over itself multiple times, and for more complex things, you can mix components of bar and candle style.

2ro2nOi.png
 
@SleepyZ Yeah, I didn't bother mentioning AddChart() due to it's lack of documentation and the fact that while it can change the border color it cannot change the color of the wicks... I keep a couple example scripts kicking around so I don't have to retrain myself how the function works every time there is a need for some AddChart() code...
I forgot to include wick coloring, which are now in the above code
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
354 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