find holidays, missing trading days, on a chart.
..draw a vertical line and/or a bubble
..the text includes the name of the missing day and the date after it.
..works on any timeframe. on smaller times, will need the expansion area set to a big number.
sometimes i forget about a holiday and end up holding a trade over it.
i wanted somthing on the chart, to remind me about future holidays.
i have been working on and off on some ideas for awhile. but they involve typing in dates, which gets messy and long, with all of the comparisons.
then today i was using dayofweek for something and i came up with this.
if references the first bar of the day.
now that it is done, i see i could have referenced the dayend variable and compared to a future value [-1] , and probably come up with the date of the missing day... but it's late and this will work for me.
WMT day chart expansion area = 300
hal_hol
..draw a vertical line and/or a bubble
..the text includes the name of the missing day and the date after it.
..works on any timeframe. on smaller times, will need the expansion area set to a big number.
sometimes i forget about a holiday and end up holding a trade over it.
i wanted somthing on the chart, to remind me about future holidays.
i have been working on and off on some ideas for awhile. but they involve typing in dates, which gets messy and long, with all of the comparisons.
then today i was using dayofweek for something and i came up with this.
if references the first bar of the day.
now that it is done, i see i could have referenced the dayend variable and compared to a future value [-1] , and probably come up with the date of the missing day... but it's late and this will work for me.
Ruby:
# dow_holidays_01
# halcyonguy
# 22-04-06
# check if a trading day is skipped, holidays
# compare 2 day of week #'s to see if a date was skipped
# dow 1 = monday , 5 = friday
# mobius
def data = getYYYYMMDD();
def year = Round(data/10000, 0);
def month = Round((data % 10000) / 100, 0);
def day = (data % 100);
#addLabel(1, "date: " + month + "/" + day + "/" + AsPrice(year), color.white);
def bn = barnumber();
def lastbar = !isnan(close[0]) and isnan(close[-1]);
def lastcls = if !isnan(close) and !lastbar then close else if lastbar then close else lastcls[1];
def DOW = GetDayOfWeek(GetYYYYMMDD());
def daystart = if GetDay() != GetDay()[1] then 1 else 0;
#def dayend = if GetDay() != GetDay()[-1] then 1 else 0;
# if no skip = 99
def dayskipped;
if bn == 1 then {
dayskipped = 99;
} else if (daystart and dow == 2 and dow[1] != 1) then {
dayskipped = 1;
} else if (daystart and dow == 3 and dow[1] != 2) then {
dayskipped = 2;
} else if (daystart and dow == 4 and dow[1] != 3) then {
dayskipped = 3;
} else if (daystart and dow == 5 and dow[1] != 4) then {
dayskipped = 4;
} else if (daystart and dow == 1 and dow[1] != 5) then {
dayskipped = 5;
} else {
dayskipped = 99;
}
input show_bubble = yes;
addchartbubble(show_bubble and dayskipped != 99, lastcls,
(if dayskipped == 1 then "Monday"
else if dayskipped == 2 then "Tuesday"
else if dayskipped == 3 then "Wednesday"
else if dayskipped == 4 then "Thursday"
else if dayskipped == 5 then "Friday"
else "") + "\n" +
"skipped\n" +
"before\n" +
( month + "/" + day + "/" + AsPrice(year) )
, color.cyan, no);
input show_vertical_line = yes;
addverticalline(show_vertical_line and dayskipped != 99,
(if dayskipped == 1 then "Monday"
else if dayskipped == 2 then "Tuesday"
else if dayskipped == 3 then "Wednesday"
else if dayskipped == 4 then "Thursday"
else if dayskipped == 5 then "Friday"
else "") + " skipped before " + ( month + "/" + day + "/" + AsPrice(year)) , color.cyan);
# ---------------------------------------------------------
input test1_dow = no;
AddChartBubble( test1_dow, lastcls, dow , color.yellow, no);
#
WMT day chart expansion area = 300
hal_hol