Reputation: 257
new to pine. I can get the open/close of the previous trading day no problem as follows:
openprice = request.security(syminfo.tickerid, "D", open[1])
But what I want is the previous weeks open and close. So if today is Wednesday I'm looking for the close on the previous friday.
Upvotes: 2
Views: 776
Reputation: 21332
The second parameter of the security()
is tiemframe
.
timeframe (simple string) Timeframe of the requested data. To use the chart's timeframe, use an empty string or the timeframe.period variable. Valid timeframe strings are documented in the User Manual's Timeframes page.
So, you can pass "W"
for weekly data.
weekly_close = request.security(syminfo.tickerid, "W", close[1])
Upvotes: 2