- This topic has 0 replies, 1 voice, and was last updated 6 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
Optuma Forums › Optuma Scripting › BarDate() vs BarIndex()
For some situations (e.g. timecounts) it may be better to use the BarIndex() function instead of BarDate().
The key difference is that BarDate uses calendar days and BarIndex will count the number of bars available i.e. trading days on a daily chart.
BarDate counts the number of calendar days since December 31st 1899, so all charts will have the same BarDate value for the current bar (44,574 for January 13th 2022) whereas the BarIndex will count the number of bars available for that particular chart (i.e. 1,148 for APT:ASX vs 7,673 for CBA:ASX).
If you put the functions in a Show View below the chart you will see the values (note switching to a weekly timeframe will change the BarIndex values as there will be fewer bars on the screen, whereas BarDate will change to the value of the Friday of the current week):
So when looking to count trading days back from the current bar use the following in a Show Bar to highlight the bar 49 trading days ago:
1 2 3 4 |
V1 = BARINDEX(); V1 == LAST(V1)-49 |
For Calendar Days use BarDate:
1 2 3 4 |
V1 = BARDATE(); V1 == LAST(V1)-49 |
In this example the red Show Bar arrow highlights 49 trading days prior to the current bar, and the green shows 49 calendar days. These will move automatically as new data is added and the BarIndex and BarDate values increase:
Cookie | Duration | Description |
---|---|---|
cname | 14 days | This cookie is set by Optuma. The cookies is used to store the users campaign selection for selecting the correct version of Optuma to trial and is "Necessary". |
cookielawinfo-checbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |