minutesWithin() or who to know time elapsed inside a bar

Posted By: Cheulmen

minutesWithin() or who to know time elapsed inside a bar - 05/08/18 22:47

Hi, I'm trying to know, while I'm using tick(), how many minutes has been since the bar started. Probably what I need is minutesWithin(), but I'm not using it correctly, I think. If I have BarPeriod=2, and I call minutesWithin from inside a tick() function , I should get (AFAIK) only values of 0, 1 or 2 as much. But I get the following values, depending on the parameters:

printf("n %f", minutesWithin(0));
results in a range from 377.424653 to 1.522134

I don't understand this value of 377 (as I'm using Barperiod=2 it shouldn't be higher than that).

I want just to calculate inside a tmf() or a tick() if in the next minute is going to run() a new bar. So for example I want, If I have a BarPeriod=120, and a tick is called repeated times during that bar, knowing if it is the minute 119 inside that bar.

I guess that minutesAgo() could be of help also, but I don't get how to use it.
Posted By: jcl

Re: minutesWithin() or who to know time elapsed inside a bar - 05/09/18 09:22

Aside from minutesWithin(), you can also simply get the current time inside the tick() function, and subtract the time from one bar before.

For obvious reasons, no matter how small your bar period, minutesWithin() can, and often will, return ranges of up to about 3000 minutes. BarPeriod=2 gives only the MINIMUM length of a bar.
Posted By: Cheulmen

Re: minutesWithin() or who to know time elapsed inside a bar - 05/09/18 16:36

Do you mean saying that BarPeriod=2 gives the minimum length, that it could be bigger because the use of TimeFrame?
Posted By: Spirit

Re: minutesWithin() or who to know time elapsed inside a bar - 05/09/18 19:38

A bar is at least as long as the time between 2 price ticks.
© 2024 lite-C Forums