# MTF 8EMA / Price % Label

#### trout

##### New member
I'm trying to figure out how to show a label with the percentage difference between the 15min 8ema from the current price (shown as positive or negative, and rounded two digits after decimal). Thank you

Solution
something like this:
Code:
``````input agg = AggregationPeriod.FIFTEEN_MIN;
def data = close(period = agg);
def EMA_8_agg = MovAvgExponential(price = data, length = 8);
def label_value = round(((close - EMA_8_agg) / EMA_8_agg) * 100, 2);
AddLabel(yes, "   " + label_value + " %  ", if label_value > 0 then color.green else color.red);``````

to walk through the code,
input the aggregation period you want to compare to the current close,
define the data holder to be the close price on the aggregation period you selected,
calculate the EMA for 8 bars of the data holder,
the label value is calculated as a percentage
and the label is added to the plot.

-mashume
something like this:
Code:
``````input agg = AggregationPeriod.FIFTEEN_MIN;
def data = close(period = agg);
def EMA_8_agg = MovAvgExponential(price = data, length = 8);
def label_value = round(((close - EMA_8_agg) / EMA_8_agg) * 100, 2);
AddLabel(yes, "   " + label_value + " %  ", if label_value > 0 then color.green else color.red);``````

to walk through the code,
input the aggregation period you want to compare to the current close,
define the data holder to be the close price on the aggregation period you selected,
calculate the EMA for 8 bars of the data holder,
the label value is calculated as a percentage
and the label is added to the plot.

-mashume

MultitimeFrame MTF LinearRegAdjEMA Study Questions 1
MTF 12hr Label Questions 2
Relative Momentum Index MTF Questions 2
MTF PriceOsc Questions 2
multiple MTF High Low Questions 0

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