Plot line on intraday at percentage of previous day close


Category:
0
0

Hi Pete,

Is there a way that I can include in my chart a dotted line or just a line that will show me 20% from previous close when I open a 1-minute chart.

Thanks in advance.

RESOLVED
Marked as spam
Posted by (Questions: 7, Answers: 16)
Asked on January 4, 2019 12:58 pm
74 views
0

When you say “previous close”. Are you referring to the close of the previous daily candle? Or something else?

( at January 4, 2019 6:42 pm)
0

Yes that’s right Pete.

( at January 4, 2019 8:18 pm)
0
Private answer

I updated your question title to make is much easier for new visitors to understand the context of your question.

I was not sure if you wanted the line to be 20% above previous day close or 20% below previous day close. So I included both. Also notice I provide two user inputs to adjust the percentage value used to compute the upper and lower lines.

input plusPercent = 20.0;
input minusPercent= 20.0;
def prevDailyClose = close(period = AggregationPeriod.DAY)[1];
plot upper = prevDailyClose * (1 + (plusPercent * 0.01));
plot lower = prevDailyClose * (1 - (minusPercent * 0.01));

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 5, 2019 8:50 am
0

20% above previous day close.

Pete, there’s two “plot lower” in the code. I’m not sure if I should add the last code also.

( at January 5, 2019 10:01 am)
0

Sorry that was a typo. I have corrected it in my answer so you can use the entire code without error.

( at January 5, 2019 1:44 pm)
0

Thanks Pete for your great work and big help as always!

( at January 6, 2019 12:13 pm)