TEMA custom colored candles

@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
 
@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
 

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
248 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