Add price line for prior year close


Category:
0
0

I would like to know how to add a line to my charts that start at close on 20201231 so I can see that on the chart (just a plain white line) and use in a scan (close at/above or below). The plan would be to update next year for the end of this year. Thanks!

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on March 5, 2021 9:21 pm
46 views
0
Private answer

Here is the one line of code for the chart study:

plot data = close(period = AggregationPeriod.YEAR)[1];

You cannot use this for scan because scans do not allow secondary aggregation periods.

The following will work as a scan set to daily time frame:

rec trackYearlyClose = if GetYear() <> GetYear()[1] then close[1] else trackYearlyClose[1];
plot scan = close > trackYearlyClose;

There is no need to "update" anything from year to year.

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on March 6, 2021 5:31 pm
0
Thank you! This is exactly what I needed. For the study (not the scan), is there a way to get that to also work on mobile? Thank you again!
( at March 6, 2021 7:52 pm)
0
No I do not believe this will work on the mobile app. You should try it out and let us know.
( at March 6, 2021 8:09 pm)