Hi
is there a function to obtain the close of a specific day?
Nuno
obtain the close of a specific day [SOLVED]
- Henry MultiСharts
- Posts: 9165
- Joined: Aug 25 2011
- Has thanked: 1264 times
- Been thanked: 2958 times
Hello Nuno,
For daily bars you can use this code:
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);
-
- Posts: 174
- Joined: Jan 31 2006
- Has thanked: 74 times
- Been thanked: 5 times
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
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
- ABC
- Posts: 731
- Joined: Dec 16 2006
- Location: www.abctradinggroup.com
- Has thanked: 126 times
- Been thanked: 415 times
- Contact:
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
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