# TEMA custom colored candles

#### arod49

##### New member
I'm looking for candles to be painted blue if TEMA 21 AND TEMA 50 ARE ABOVE TEMA 200? thanks

@arod49 Here is a simple code that plots three TEMA's and colors the price blue when TEMA 21 and TEMA 50 are above TEMA 200.

Code:
``````# Triple TEMA with PriceColor
# base code by TD Ameritrade IP Company, Inc. (c) 2009-2020

input price = close;
input length1 = 21;
input length2 = 50;
input length3 = 200;

def ema1_1 = ExpAverage(price, length1);
def ema2_1 = ExpAverage(ema1_1, length1);
def ema3_1 = ExpAverage(ema2_1, length1);
plot TEMA1 = 3 * ema1_1 - 3 * ema2_1 + ema3_1;
TEMA1.SetDefaultColor(color.yellow);

def ema1_2 = ExpAverage(price, length2);
def ema2_2 = ExpAverage(ema1_2, length2);
def ema3_2 = ExpAverage(ema2_2, length2);
plot TEMA2 = 3 * ema1_2 - 3 * ema2_2 + ema3_2;
TEMA2.SetDefaultColor(color.green);

def ema1_3 = ExpAverage(price, length3);
def ema2_3 = ExpAverage(ema1_3, length3);
def ema3_3 = ExpAverage(ema2_3, length3);
plot TEMA3 = 3 * ema1_3 - 3 * ema2_3 + ema3_3;
TEMA3.SetDefaultColor(color.red);

AssignPriceColor(if TEMA1 > TEMA3 and TEMA2 > TEMA3 then color.blue else color.current);

# the end``````

• RickAns
Thank you very much !

@arod49 Here is a simple code that plots three TEMA's and colors the price blue when TEMA 21 and TEMA 50 are above TEMA 200.

Code:
``````# Triple TEMA with PriceColor
# base code by TD Ameritrade IP Company, Inc. (c) 2009-2020

input price = close;
input length1 = 21;
input length2 = 50;
input length3 = 200;

def ema1_1 = ExpAverage(price, length1);
def ema2_1 = ExpAverage(ema1_1, length1);
def ema3_1 = ExpAverage(ema2_1, length1);
plot TEMA1 = 3 * ema1_1 - 3 * ema2_1 + ema3_1;
TEMA1.SetDefaultColor(color.yellow);

def ema1_2 = ExpAverage(price, length2);
def ema2_2 = ExpAverage(ema1_2, length2);
def ema3_2 = ExpAverage(ema2_2, length2);
plot TEMA2 = 3 * ema1_2 - 3 * ema2_2 + ema3_2;
TEMA2.SetDefaultColor(color.green);

def ema1_3 = ExpAverage(price, length3);
def ema2_3 = ExpAverage(ema1_3, length3);
def ema3_3 = ExpAverage(ema2_3, length3);
plot TEMA3 = 3 * ema1_3 - 3 * ema2_3 + ema3_3;
TEMA3.SetDefaultColor(color.red);

AssignPriceColor(if TEMA1 > TEMA3 and TEMA2 > TEMA3 then color.blue else color.current);

# the end``````
I have changed up the code to show 3 colors for the bars Green "Long" "yellow"for Neutral" and "Red" for short
I also changed the colors of the TEMA's Green, Magenta, and Blue
I also recommend shorter Lengths for the TEMA's 21,34,55

# Triple TEMA with PriceColor
# base code by TD Ameritrade IP Company, Inc. (c) 2009-2020

input price = close;
input length1 = 21;
input length2 = 34;
input length3 = 55;

def ema1_1 = ExpAverage(price, length1);
def ema2_1 = ExpAverage(ema1_1, length1);
def ema3_1 = ExpAverage(ema2_1, length1);
plot TEMA1 = 3 * ema1_1 - 3 * ema2_1 + ema3_1;
TEMA1.SetDefaultColor(color.Green);
Tema1.SetLineWeight(3);
def ema1_2 = ExpAverage(price, length2);
def ema2_2 = ExpAverage(ema1_2, length2);
def ema3_2 = ExpAverage(ema2_2, length2);
plot TEMA2 = 3 * ema1_2 - 3 * ema2_2 + ema3_2;
TEMA2.SetDefaultColor(color.Magenta);
Tema2.SetLineWeight(3);
def ema1_3 = ExpAverage(price, length3);
def ema2_3 = ExpAverage(ema1_3, length3);
def ema3_3 = ExpAverage(ema2_3, length3);
plot TEMA3 = 3 * ema1_3 - 3 * ema2_3 + ema3_3;
TEMA3.SetDefaultColor(color.Blue);
Tema3.SetLineWeight(3);
AssignPriceColor(if TEMA1 > TEMA2 and TEMA2 > TEMA3 then Color.Green else if TEMA1 < TEMA2 and TEMA2 < TEMA3 then Color.Red else Color.Yellow );

# the end

• Beltrame1, Pensar and RickAns
[B]henry1224[/B]... is it possible that you can create a TOS watchlist that will simply show your candle colors (yellow, green and red)?

Need help creating Tema MACD Crossover Questions 22
TEMA CROSSOVER Questions 1
Paint candles if above or below TEMA? Questions 5
displaced TEMA Questions 2
Export Custom Study Value Questions 0

### Not the exact question you're looking for?

87k+ Posts
194 Online ## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?