What does ConvertDateToBar return with exactMatch = true yet exact date is not located?
Author: 4estCapital
Creation Date: 10/7/2015 7:33 AM
profile picture



The synchronization of bars between applications (on my end) and the wealth-lab becomes serious issue when the scale of strategies narrows down to intraday bars.

In that sense, I happen to use ConvertDateToBar function extensively while compiling my strategies.

So, my curiosity:

What does ConvertDateToBar returns when exactMatch is set to True yet exact date is not located?

I did not come up with a decent answer on wealthscript manual, and did not find anything related in the forum as well. And, the quickref also fell short of answering this question:

Thanks in advance for your help,

Aykut Sarıbıyık

QuickRef defines this function as follows:


int ConvertDateToBar(DateTime date, bool exactMatch);

Returns the bar number that matches the DateTime provided in the date parameter. If exactMatch is true, the precise DateTime value must be located in the Bars object. Otherwise, the first bar whose DateTime is greater than or equal to the specified date is returned.

profile picture



I believe that it should return -1.
profile picture


Please log in to see this code.
profile picture



Thank you both.

Kind regards,