I wrote a short snippet of code to check that main() is called once per bar for each historic bar and then once per trade in streaming mode.
I then run this against the 1min chart and expected to see a line of output per historic bar, but I only see 1 line of output for every 2 minutes until I am in streaming mode when I get lots of lines per minute (and assume I am printing one line per trade and not one line per 2 trades).
My question is: why do I only receive 1 line per 2 bars when not in streaming mode and how do I ensure I get one line per bar as I need to ensure that main() is being called for each bar as the EFS doco implies.
Code:
===CUT===
function preMain()
{
setPriceStudy(true);
}
function main()
{
var b = getCurrentBarIndex();
var t = getValue("time", b);
var state = getBarState();
debugPrintln("Time [" + t + "], idx [" + b + "] state [" + state + "]");
}
===CUT===
Sample output
===CUT===
Time [Tue May 03 2011 17:03:00 GMT+0100 (GMT Daylight Time)], idx [-12] state [0]
Time [Tue May 03 2011 17:05:00 GMT+0100 (GMT Daylight Time)], idx [-11] state [0]
Time [Tue May 03 2011 17:07:00 GMT+0100 (GMT Daylight Time)], idx [-10] state [0]
Time [Tue May 03 2011 17:09:00 GMT+0100 (GMT Daylight Time)], idx [-9] state [0]
Time [Tue May 03 2011 17:11:00 GMT+0100 (GMT Daylight Time)], idx [-8] state [0]
Time [Tue May 03 2011 17:13:00 GMT+0100 (GMT Daylight Time)], idx [-7] state [0]
Time [Tue May 03 2011 17:15:00 GMT+0100 (GMT Daylight Time)], idx [-6] state [0]
Time [Tue May 03 2011 17:17:00 GMT+0100 (GMT Daylight Time)], idx [-5] state [0]
Time [Tue May 03 2011 17:19:00 GMT+0100 (GMT Daylight Time)], idx [-4] state [0]
Time [Tue May 03 2011 17:21:00 GMT+0100 (GMT Daylight Time)], idx [-3] state [0]
Time [Tue May 03 2011 17:23:00 GMT+0100 (GMT Daylight Time)], idx [-2] state [0]
Time [Tue May 03 2011 17:25:00 GMT+0100 (GMT Daylight Time)], idx [-1] state [0]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [0]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
===CUT===
I then run this against the 1min chart and expected to see a line of output per historic bar, but I only see 1 line of output for every 2 minutes until I am in streaming mode when I get lots of lines per minute (and assume I am printing one line per trade and not one line per 2 trades).
My question is: why do I only receive 1 line per 2 bars when not in streaming mode and how do I ensure I get one line per bar as I need to ensure that main() is being called for each bar as the EFS doco implies.
Code:
===CUT===
function preMain()
{
setPriceStudy(true);
}
function main()
{
var b = getCurrentBarIndex();
var t = getValue("time", b);
var state = getBarState();
debugPrintln("Time [" + t + "], idx [" + b + "] state [" + state + "]");
}
===CUT===
Sample output
===CUT===
Time [Tue May 03 2011 17:03:00 GMT+0100 (GMT Daylight Time)], idx [-12] state [0]
Time [Tue May 03 2011 17:05:00 GMT+0100 (GMT Daylight Time)], idx [-11] state [0]
Time [Tue May 03 2011 17:07:00 GMT+0100 (GMT Daylight Time)], idx [-10] state [0]
Time [Tue May 03 2011 17:09:00 GMT+0100 (GMT Daylight Time)], idx [-9] state [0]
Time [Tue May 03 2011 17:11:00 GMT+0100 (GMT Daylight Time)], idx [-8] state [0]
Time [Tue May 03 2011 17:13:00 GMT+0100 (GMT Daylight Time)], idx [-7] state [0]
Time [Tue May 03 2011 17:15:00 GMT+0100 (GMT Daylight Time)], idx [-6] state [0]
Time [Tue May 03 2011 17:17:00 GMT+0100 (GMT Daylight Time)], idx [-5] state [0]
Time [Tue May 03 2011 17:19:00 GMT+0100 (GMT Daylight Time)], idx [-4] state [0]
Time [Tue May 03 2011 17:21:00 GMT+0100 (GMT Daylight Time)], idx [-3] state [0]
Time [Tue May 03 2011 17:23:00 GMT+0100 (GMT Daylight Time)], idx [-2] state [0]
Time [Tue May 03 2011 17:25:00 GMT+0100 (GMT Daylight Time)], idx [-1] state [0]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [0]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
Time [Tue May 03 2011 17:27:00 GMT+0100 (GMT Daylight Time)], idx [0] state [1]
===CUT===
Comment