Announcement

Collapse
No announcement yet.

main not being called once per bar when not in streaming mode?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • main not being called once per bar when not in streaming mode?

    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===

  • #2
    update

    OK done some further testing and research of this (esignal 10.6.1879.975 incidentally).

    The EFS doco says that API getValue() http://kb.esignal.com/display/2/kb/a....aspx?aid=2108 indicates that parameter 2 is required (the bar index) and in my original snippet I supplied this as the result of getCurrentBarIndex().

    If you omit getValue() required parameter 2 altogether then getValue() returns the correct result and there are no missed bars when not in streaming mode.



    chris

    Comment


    • #3
      Chris,

      in fact the second parameter of getValue() function define not absolute barIndex but relative, which is the offset from current bar processed by main function.
      If we load your original script for (DELL, 1) on TimeTemplate 5 bars we can see such results

      PHP Code:
      Time [Tue May 03 2011 19:59:00 GMT-0400], idx [0state [0]
      Time [Tue May 03 2011 19:57:00 GMT-0400], idx [-1state [0]
      Time [Tue May 03 2011 19:55:00 GMT-0400], idx [-2state [0
      The scheme of bar processing is shown on screen bellow.

      If you want to get time value for bar, processed by main, you should use getValue("time",0) or getValue("time").

      Thank you for bringing this issue to our attention, some clarification will be added in documentation.
      Attached Files
      Last edited by eSignal_VladimirS; 05-04-2011, 02:52 AM.

      Comment


      • #4
        on screen bellow is a typo. Of course, getValue("time",-1) points 1 bar back, not 2 bars back

        Comment

        Working...
        X