top of page
Search

Percent Change of Day on Tradingview


This indicator aims to effectively show us the percentage change of the price within the time frame we have chosen

First of all, let's understand How to Calculate Percent Change?


The difference between the old and new value of a quantity given in percentages is known as a percent change. It's rather simple to calculate the % difference between two given quantities.


The formula is given by;


Example

The price of a kilo of rice went from 10$ to12.5$, what is the percentage change?

Explanation

· The old value of sugar = $ 10

· New value = $12.5

· Now apply the percent change formula;

· Percentage change = [(New Value − Old Value)/ Old Value] ×100%

= [(12.5 -10)/10] x 100%

= (2.5/10) x 100%

= 25%

In this case, the percent change is positive and therefore, it is an increase.

How Is Percentage Change Used in Finance?

In the world of finance, percentage change is frequently used to analyze changes in the value of stocks and crypto market indexes over time.

What is the purpose of this indicator?

This indicator shows how the price changes for each bar at different time frames we have chosen. By examining the percentage change in different time periods, we can easily look at the change in the face of the market during the time interval.

Also if the price is above or below the value of 0 during the specified time, the color of our percentage line changes.

Percent Change of Day

What can you change in the settings panel?

tradingview setting panel

We can set time frame setting of the percentage change from place number 1

We are able to adjust the changing color if the percentage change is above or below zero from place 2 and 3



Pine script Codes:

(Dont forget copy //@version=5 code)


//@version=5
indicator('Percent Change of Day [ilovealgotrading]', overlay=false, max_labels_count = 500)
// author = Baby_whale_to_moon

TimeFrame = input.timeframe('D')
more_then0 = input.color(defval =color.rgb(37, 128, 60) ,title = "Line Colour More 0" )
less_then0 = input.color(defval =color.rgb(185, 60, 60) ,title = "Line Colour Less 0" )

is_new_day = ta.change(time(TimeFrame)) != 0 ? 1 : 0

var float per_change = 0

bar_per_change = math.round_to_mintick(ta.roc(close,1))

per_change := is_new_day ? bar_per_change : per_change + bar_per_change

color_per_change = color(na)
if (math.round_to_mintick(ta.roc(close,1))) >= 0
    color_per_change := color.lime
    color_per_change
else
    color_per_change := color.red
    color_per_change
    
bgcolor(is_new_day ? color.new(#f5ff3c, 42) : na)
plot(per_change, 'Daily Percent Change', per_change >= 0 ? more_then0 : color.rgb(185, 60, 60), linewidth = 2)
plot(math.round_to_mintick(ta.roc(close,1)), color = color_per_change, style=plot.style_columns)



If you have any problem send message from Telegram

0 comments
bottom of page