obtain the close of a specific day  [SOLVED]

Questions about MultiCharts and user contributed studies.
nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

obtain the close of a specific day

Postby nuno-online » 03 Jul 2016

Hi

is there a function to obtain the close of a specific day?

Nuno

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: obtain the close of a specific day

Postby Henry MultiСharts » 06 Jul 2016

Hello Nuno,

For daily bars you can use this code:

Code: Select all

inputs:
DesiredDate(1160606);
vars:
DDClose(0);
if date=DesiredDate then DDClose=close;
print("Desired Date's Close is ", DDClose);

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

Re: obtain the close of a specific day

Postby nuno-online » 06 Jul 2016

thanks Henry for this code

do you think it's possible to have the close of a day in 2015 for example?
and if the day is an holiday day or a week end, we look for the day before

User avatar
ABC
Posts: 720
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: obtain the close of a specific day  [SOLVED]

Postby ABC » 07 Jul 2016

nuno-online,

that is possible, but not as simple as the one liner Henry provided. For starters you will need to have a list of holidays (and probably weekends) you want to check for.
Now you can do something along the lines of:
1. Check if the current bar is not a holiday, weekend and what ever you want to exclude, too.
2. Track the closing of each daily bar that fulfills check 1..
3. The first time the date is greater or equal to your check date you'd save the tracked close.

Of course 3. needs to be located above 2. in your code. Otherwise you wouldn't get the close you are looking for.

4. A special case could arise when condition 3. is fulfilled before your code had the chance to track the close under step 2., so you need to decide on what to do when this happens.

You could also loop back through the bars when the date >= your check date until you find a bar that matches your condition, but the above seems easier to code.

Regards,

ABC


Return to “MultiCharts”