BBob
BBob

Reputation: 1

How Do I Plot Horizontal Lines On My Chart For Previous Candles High And Low?

I'm having trouble plotting horizontal lines that extend using previous candles high and low. Would love to be bale to use multiple time frames (4hr, D, W, M) candles as reference. How do I go about editing this in pine script?

Upvotes: 0

Views: 766

Answers (1)

vitruvius
vitruvius

Reputation: 21121

To get data from different timeframes, you should use the request.security() function.

Then you can either use line or plot() to display this information.

Below code plots previous day's high and low.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vitruvius

//@version=5
indicator("My script", overlay=true)

d_h = request.security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
d_l = request.security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)

plot(d_h, style=plot.style_circles, color=color.green)
plot(d_l, style=plot.style_circles, color=color.red)

enter image description here

Upvotes: 1

Related Questions