Dear all,

I have a simple problem:
I have a script with BarPeriod = 1, and I want to get the exact closetime of another timeframe's previous bar.
For example I want to get the time of the 5th bar of the TimeFrame 60 (in Unix timestamp format).

In the documentation of Time and Calendar Functions page:
Quote

The offset parameter is affected by TimeFrame, f.i. when TimeFrame is 6 and offset is 3, the time of 3*6 = 18 bars ago is returned.


So I have this script:
Code
	...
	BarPeriod = 1;

	int currentTimeStamp;

	TimeFrame = 1;
	currentTimeStamp = utm(wdate(0));
	printf("\n TIME1: %d", currentTimeStamp);

	TimeFrame = 60;
	currentTimeStamp = utm(wdate(0));
	printf("\n TIME2: %d", currentTimeStamp);

	printf("\n-----");
	...


And I have this result:

Code
...
 TIME1: 1505149200
 TIME2: 1505149200
-----
 TIME1: 1505149260
 TIME2: 1505149260
-----
 TIME1: 1505149320
 TIME2: 1505149320
-----


I expected that the two amounts will not be the same, the second one should change in every 60th run. So it seems the wdate is not affected by TimeFrame.

Of course I could do the math for the 5th bar of TimeFrame 60 like:
Code
utm(wdate(60*5 - minute(0)))

or something, but I guess the TimeFrame should do the trick.

Is it a bug, or am I missing something?
Is there a standard way to do that?

Thank you!

Last edited by NorbertSz; 06/08/23 15:14.