Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the file. How To Ask Questions The Smart Way. (2004) Be precise and informative about your problem
We can't see your broken code.
datetime newDt= TimeCurrent()-PeriodSeconds(PERIOD_H1);
int n= iBarShift(_Symbol,PERIOD_M1, newDt, true);
Print(TimeToString(newDt), " - bar: ", IntegerToString(n));
but when you use "true" & this date is absent on this chart (e.g. week_end or the hole on the chart) - of course you will get -1 -- see iBarShift...
if you'd like to get vc.vs.datetime from bar_number - you do not need iBarshift
Please enable the necessary setting in your browser, otherwise you will not be able to log in.