You can do this.
I get the
year as an
integer and
convert it to a
string and then add the text on the label. I was not able to get the day. There is a variable called
dayofmonth, but that seems to be another thing.
code:
Code: Select all
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CanYouCatchMe
//@version=4
study("date pivot points", overlay=true)
prd = input(defval = 20, title="Pivot Point Period", minval = 10, maxval = 50)
float ph = na, float pl = na //If there is no pivit points. Default value
ph := pivothigh(prd, prd)
pl := pivotlow(prd, prd)
date = tostring(year) + "-" + tostring(month)
if (ph) //If 20 days ago was a pivot point
label.new(bar_index-prd, ph, date, yloc=yloc.abovebar, color=color.green) //NOTE: bar_index-prd, becuse it occured 20 days ago
if (pl)
label.new(bar_index-prd, pl, date, yloc=yloc.belowbar, color=color.red)