Skip to content

Commit

Permalink
HBS-3908: add close_<1|30|365>_days_back fields
Browse files Browse the repository at this point in the history
  • Loading branch information
arylkou committed Oct 30, 2023
1 parent de0a3a4 commit 11cc555
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions links/bond_yield.pine.link
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,17 @@ float change_percent = na
if not(bond_price[1] < 0) and not(bond_price > 0)
change_percent := change_abs / bond_price[1] * 100
plot(change_percent, title="Bond.Change.%")

// Bond Yield 1 | 30 | 365 days
dayYield = 1
monthYield = 30
yearYield = 365
dayAgoYield = timenow - 1000 * 60 * 60 * 24 * dayYield
monthAgoYield = timenow - 1000 * 60 * 60 * 24 * monthYield
yearAgoYield = timenow - 1000 * 60 * 60 * 24 * yearYield
countOfBars1DayAgoBond = fastSearchN(time, dayAgoYield, dayYield)
countOfBars1MonthAgoBond = fastSearchN(time, monthAgoYield, monthYield)
countOfBars1YearAgoBond = fastSearchN(time, yearAgoYield, yearYield)
plot(close[countOfBars1DayAgoBond], title="close_1_days_back")
plot(close[countOfBars1MonthAgoBond], title="close_30_days_back")
plot(close[countOfBars1YearAgoBond], title="close_365_days_back")

0 comments on commit 11cc555

Please sign in to comment.