Hi,
I am trying to write a script that will tell me the number of bars between my current bar and a bar representing some future date and time. I have the following test code snippet:
var futureDate = new Date(2008, 11, 31); //Dec 31, 2008 at 00:00:00
var currentBarDate = rawtime(0)*1000; // in milli seconds
var difference = futureDate.getTime()-currentBarDate;
If I had a specific time on the future date, I can add that to the futureDate variable by using getHour(), getMinute(), getSecond(), ...
Here is my issue:
I know there is 86400000 milliseconds in a day so if I am running intraday, say 5 min bars, getInterval() will return 5 and I can figure out how to get the number of bars from my current bar to my future date bar. If I am running day bars, getInterval() should return D and I can figure out the number of bars. LIkewise for weekly charts as there are 7 day in a week.
My question is, how is this handled for Monthly charts (since the number of days in a month varies, is there 4 or 5 weeks in a month), tick charts, second charts and volume bar charts? (Basically all the charts possible in eSignal.)
Perhaps someone knows a clean solution to this problem. Any insight and help would be greatly appreciated. Thank you very much in advance.
Also, very happy holidays and all the best into the New Year to all the staff of eSignal and all the members of this and other eSignal forums.
Regards,
Jane
I am trying to write a script that will tell me the number of bars between my current bar and a bar representing some future date and time. I have the following test code snippet:
var futureDate = new Date(2008, 11, 31); //Dec 31, 2008 at 00:00:00
var currentBarDate = rawtime(0)*1000; // in milli seconds
var difference = futureDate.getTime()-currentBarDate;
If I had a specific time on the future date, I can add that to the futureDate variable by using getHour(), getMinute(), getSecond(), ...
Here is my issue:
I know there is 86400000 milliseconds in a day so if I am running intraday, say 5 min bars, getInterval() will return 5 and I can figure out how to get the number of bars from my current bar to my future date bar. If I am running day bars, getInterval() should return D and I can figure out the number of bars. LIkewise for weekly charts as there are 7 day in a week.
My question is, how is this handled for Monthly charts (since the number of days in a month varies, is there 4 or 5 weeks in a month), tick charts, second charts and volume bar charts? (Basically all the charts possible in eSignal.)
Perhaps someone knows a clean solution to this problem. Any insight and help would be greatly appreciated. Thank you very much in advance.
Also, very happy holidays and all the best into the New Year to all the staff of eSignal and all the members of this and other eSignal forums.
Regards,
Jane
Comment