Reputation: 1
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
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)
Upvotes: 1