Label to show number $1 gains and declines


Category:
0
0

Hi Pete!

In reference to the below thread, could you please help me with adding two labels to the chart. One showing the days its net change is “$1 Days” in green while the other “-$1 Days” in red.

Custom column showing $1 Gains/Declines

Thank you so much again!

Marked as spam
Posted by (Questions: 20, Answers: 27)
Asked on September 15, 2020 8:51 am
49 views
0
Private answer

I copied the code from the previous post, added both of the plot statements and changed them from plot to def. Last step was to add two new lines to display the labels:

input priceThreshold = 1.0;
input numberOfDays = 21;
def dailyChange = close - close[1];
def countGain = Sum(dailyChange > priceThreshold, numberOfDays);
def countDecline = Sum(dailyChange < -priceThreshold, numberOfDays);
AddLabel(yes, Concat("$ Gains: ", countGain), Color.GREEN);
AddLabel(yes, Concat("$ Declines: ", countDecline), Color.RED);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 15, 2020 10:29 am
0
Thank you Pete! I made another contribution for your help & patience!
( at September 15, 2020 1:02 pm)