# TEMA custom colored candles

A

#### arod49

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

P

#### Pensar

##### Active member
VIP
@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
A

#### arod49

##### New member
Thank you very much !

H

#### henry1224

##### Member
VIP
@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

• Pensar and RickAns
S

#### Schminga

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