plot vertical lines on 1st open day of the month  [SOLVED]

Questions about MultiCharts and user contributed studies.
paul.robillard
Posts: 30
Joined: 22 Mar 2012
Location: Western Europe
Has thanked: 6 times

plot vertical lines on 1st open day of the month

Postby paul.robillard » 20 Nov 2015

Hi,
I've come up with the following code trying to plot a vertical line on 1st open day of every month. I fail to see what i am missing as it's not plotting right. Can someone please point out the coding error ?

Thank you

---------------
{insert vertical bars every 1st open day of the month}

variables:
txtID (0), // print text on graph
TLID (0), // the vertical line
fday(0), // set fday
d1(0), // debugging in output
third(0),
chkdate(0); //set date of vertical line

once cleardebug;
d1 = dayofweek(date);

if (dayofweek(date) = 0) then // if 1st Day of Month is a Sunday draw vertical line the next Monday
fday=2
else if (dayofweek(date) = 6) then // if 1st Day of Month is a Saturday draw vertical line the next Monday
fday=3
else fday = 1; // else 1st Day of Month is 1 draw vertical line same day


if dayofmonth(date) = fday then
begin
print(d1); // print output
chkdate=date;
TLID =
tl_new(chkdate,900,0,chkdate,900,low-100);
tl_SetColor(TLID, white);
tl_setstyle(TLID, 1);
txtID = Text_New(chkdate, Time, low-50, text(fday));
end;

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: plot vertical lines on 1st open day of the month

Postby TJ » 20 Nov 2015

Hi,
I've come up with the following code trying to plot a vertical line on 1st open day of every month. I fail to see what i am missing as it's not plotting right. Can someone please point out the coding error ?
Thank you
---------------
{insert vertical bars every 1st open day of the month}
variables:
txtID (0), // print text on graph
TLID (0), // the vertical line
fday(0), // set fday
d1(0), // debugging in output
third(0),
chkdate(0); //set date of vertical line
once cleardebug;
d1 = dayofweek(date);
if (dayofweek(date) = 0) then // if 1st Day of Month is a Sunday draw vertical line the next Monday
fday=2
else if (dayofweek(date) = 6) then // if 1st Day of Month is a Saturday draw vertical line the next Monday
fday=3
else fday = 1; // else 1st Day of Month is 1 draw vertical line same day
if dayofmonth(date) = fday then
begin
print(d1); // print output
chkdate=date;
TLID =
tl_new(chkdate,900,0,chkdate,900,low-100);
tl_SetColor(TLID, white);
tl_setstyle(TLID, 1);
txtID = Text_New(chkdate, Time, low-50, text(fday));
end;
You are overthinking it.
All you need is this:

Code: Select all


if MONTH( date ) <> MONTH( date )[1] then
begin

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: plot vertical lines on 1st open day of the month  [SOLVED]

Postby TJ » 20 Nov 2015

ps.
[FAQ] How to Post Codes (... so that people can read)
viewtopic.php?f=16&t=11713

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: plot vertical lines on 1st open day of the month

Postby TJ » 20 Nov 2015

See also this post:

Daily vertical time line
viewtopic.php?f=1&t=49108


Return to “MultiCharts”