Chart label showing percent change from yesterday’s close to today’s open


Category:
0
0

Hello ,

 

how does one go about creating a chart label that shows %change from yesterday’s close to today’s open price  on the 1 minute intraday chart .

 

color effects

If % change is greater than 47% make label green

If % change is greater than 50% add additional green label saying “overextend”

 

if % is negative , display %change and make label red

 

everything else white

 

how is this done ? Please advise

Marked as spam
Posted by (Questions: 7, Answers: 3)
Asked on February 25, 2020 6:38 am
130 views
0
Private answer

First, let's show everyone how to do the most basic form, which is described in the title of your question:

input timeFrame = AggregationPeriod.DAY;
def percentChange = 100 * (open(period = timeFrame) / close(period = timeFrame)[1] - 1);
AddLabel(yes, Concat(percentChange, "%"), Color.WHITE);

Since we are working from an intraday chart we use the secondary aggregation parameter of the open and close to read those data points from the daily time frame.

The rest of your specifications provide for a solution with an EXTREMELY narrow scope. Which means these values are only useful for a very small microcosm of the markets. For instance these values will never be applicable to any stocks in the S&P 500, the NSDAQ 100, or the Russel 2000.

As you know this forum is not here for one-off solutions that benefit only a single individual. So I always cringe when I see posts that use hard coded values instead of using something that is able to adapt to a wide range of stocks. So for my solution I will add user inputs to permit the rest of our viewers to easily adjust these values to fit whatever basket of stocks they are trading.

An ideal solution would apply the use of the Average True Range. Then compute a percent of the average true range to determine when a stock is "over extended". Hard coded values such as 47% and 50% are completely inflexible and should be avoided at all cost.

Nevertheless, here is your solution:

input timeFrame = AggregationPeriod.DAY;
input percentOver = 50.0;
input percentMax = 47.0;
input percentMin = 0.0;
def percentChange = Round(100 * (open(period = timeFrame) / close(period = timeFrame)[1] - 1), 1);
AddLabel(percentChange > percentOver, "Over Extended", Color.GREEN);
AddLabel(yes, Concat(percentChange, "%"), if percentChange < percentMin then Color.RED else if percentChange > percentMax then Color.GREEN else Color.WHITE);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 25, 2020 10:31 am
0
This is perfect , the only thing I need to know now is how do I add the word “Gap” in front Of the % calculation . I tired a few ways and got syntax errors :(
( at February 26, 2020 7:28 am)