Candle color labels

ulle73

New member
I would love some help coding labels showing what color candle current candle have on each timeframes. Would love to have the option to turn some of the timeframes off as well.

5m, 15m, 1h, 4,h, daily, weekly, something like this below:

1111.jpg
 
Solution
I would love some help coding labels showing what color candle current candle have on each timeframes. Would love to have the option to turn some of the timeframes off as well.

5m, 15m, 1h, 4,h, daily, weekly, something like this below:

1111.jpg
hal_agg

EDIT 22-10-21 - fixed , sorry had some typos,

left out some ) on the ends
agg time should be plural , four_hours

----------------------------------------

Code:
input agg1 = AggregationPeriod.five_min;
input agg2 = AggregationPeriod.fifteen_min;
input agg3 = AggregationPeriod.Hour;
input agg4 = AggregationPeriod.four_Hours;
input agg5 = AggregationPeriod.day;
input agg6 = AggregationPeriod.week;
input agg7 = AggregationPeriod.month;

def agg1grn = (close(period =...
I would love some help coding labels showing what color candle current candle have on each timeframes. Would love to have the option to turn some of the timeframes off as well.

5m, 15m, 1h, 4,h, daily, weekly, something like this below:

1111.jpg
hal_agg

EDIT 22-10-21 - fixed , sorry had some typos,

left out some ) on the ends
agg time should be plural , four_hours

----------------------------------------

Code:
input agg1 = AggregationPeriod.five_min;
input agg2 = AggregationPeriod.fifteen_min;
input agg3 = AggregationPeriod.Hour;
input agg4 = AggregationPeriod.four_Hours;
input agg5 = AggregationPeriod.day;
input agg6 = AggregationPeriod.week;
input agg7 = AggregationPeriod.month;

def agg1grn = (close(period = agg1) > open(period = agg1));
def agg2grn = (close(period = agg2) > open(period = agg2));
def agg3grn = (close(period = agg3) > open(period = agg3));
def agg4grn = (close(period = agg4) > open(period = agg4));
def agg5grn = (close(period = agg5) > open(period = agg5));
def agg6grn = (close(period = agg6) > open(period = agg6));

def x = 1;
addlabel(x, " ", color.black);
addlabel(x, "5m", (if agg1grn then color.green else color.red));
addlabel(x, "15m", (if agg2grn then color.green else color.red));
addlabel(x, "Hr", (if agg3grn then color.green else color.red));
addlabel(x, "4Hr", (if agg4grn then color.green else color.red));
addlabel(x, "D", (if agg5grn then color.green else color.red));
addlabel(x, "W", (if agg6grn then color.green else color.red));
addlabel(x, " ", color.black);
#


well that was more difficult than it should have been.

i tried,
addlabel(x, "5m", (if (close(period = agg1) > open(period = agg1)) then color.green else color.red));

but that caused an error, different agg times in 1 formula.
i guess it considers all of the addlabel( ) code as 1 formula, and didn't like the x and the agg variables together.

i separated out the price comparison ( which uses a 2nd agg) and set it equal to a variable. then used the variable in the addlabel, then it worked.
def agg1grn = (close(period = agg1) > open(period = agg1));
addlabel(x, "5m", (if agg1grn then color.green else color.red));
 
Last edited:
Solution

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

i just typed this up on my cell, i think it will work.

Code:
input agg1 = AggregationPeriod.five_min;
input agg2 = AggregationPeriod.fifteen_min;
input agg3 = AggregationPeriod.Hour;
input agg4 = AggregationPeriod.four_Hour;
input agg5 = AggregationPeriod.day;
input agg6 = AggregationPeriod.week;
input agg7 = AggregationPeriod.month;

def x = 1;
addlabel(x, "5m",
(if close(period = agg1) > open(period = agg1) then color.green else color.red);

addlabel(x, "15m",
(if close(period = agg2) > open(period = agg1) then color.green else color.red);

addlabel(x, "Hr",
(if close(period = agg3) > open(period = agg1) then color.green else color.red);

addlabel(x, "4Hr",
(if close(period = agg4) > open(period = agg1) then color.green else color.red);

addlabel(x, "D",
(if close(period = agg5) > open(period = agg1) then color.green else color.red);

addlabel(x, "W",
(if close(period = agg6) > open(period = agg1) then color.green else color.red);
Awesome!! Thanks. Will try it out later today 😀🙏
 
I would love some help coding labels showing what color candle current candle have on each timeframes. Would love to have the option to turn some of the timeframes off as well.

5m, 15m, 1h, 4,h, daily, weekly, something like this below:
fixed my code today, sorry for typos
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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