datetime of lastbar
datetime of lastbar
Is there a way in a study to obtain the datetime value of the last bar before the study starts to run through any of the historical data? It's easy enough to find it by waiting for LastBarOnChart_s to be True. I like to know its value at the beginning of the execution of the study, not after it has finished processing the historical data.
- JoshM
- Posts: 2195
- Joined: 20 May 2011
- Location: The Netherlands
- Has thanked: 1544 times
- Been thanked: 1565 times
- Contact:
Re: datetime of lastbar
`Symbol_DateTime` (undocumented) can return the DateTime value for any bar on the chart.
You'll need to use a negative index to access future bars (e.g., `Symbol_DateTime[-1]` gives the DateTime of the next bar).
If your index goes beyond the number of bars on the chart, MultiCharts triggers an error. You can prevent that from happening with `Symbol_Length` (returns all the bars on the chart) and `Symbol_CurrentBar` (returns the current bar's number).
You'll need to use a negative index to access future bars (e.g., `Symbol_DateTime[-1]` gives the DateTime of the next bar).
If your index goes beyond the number of bars on the chart, MultiCharts triggers an error. You can prevent that from happening with `Symbol_Length` (returns all the bars on the chart) and `Symbol_CurrentBar` (returns the current bar's number).