datetime of lastbar

Questions about MultiCharts and user contributed studies.
janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

datetime of lastbar

Postby janus » 21 Sep 2020

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.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: datetime of lastbar

Postby JoshM » 22 Sep 2020

`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).

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Re: datetime of lastbar

Postby janus » 22 Sep 2020

I use the SYMBOL keywords all the time to get around the maxbarsback issue. I didn't realize one could use it "in the future". Many thanks.


Return to “MultiCharts”