Announcement

Collapse
No announcement yet.

main() only being called once if I call getValue( "rawtime" ) or rawtime()

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

  • main() only being called once if I call getValue( "rawtime" ) or rawtime()

    I'm having some problems with a script.

    First, this is what I am trying to do: I have a C++ program that has information it pulls from a DB. The C++ program is in a DLL, and the EFS script's pre-main function builds a communications channel with the DLL.

    Now, in order to match data from the database with information on the charts, I tag the data in the database with timestamps in terms of seconds since midnight 1/1/1970. When I request OHLC prices from EFS, I attempt to get the rawtime() information for the bar. This way, I can view all the transactions in terms of a flat, linear "timespace." (The C++ program takes care of the conversions such that time zone shifts and such are accounted for.)

    However, when my code executes, it only runs through main() once. If I comment out all of the DLL calls, it's still the rawtime() function or getValue( "rawtime" ) that let's main run ONCE, and never again. I have checked the settings to make sure it works on a per-tick basis and not on the close. If I -remove- the call to the rawtime function or the getValue( "rawtime" ) function, then main() gets called multiple times.

    This is a stripped down snippet:

    PHP Code:

    //
    // Initial Entry Point
    //

    function main()
    {
      var 
    resultobi;
      var 
    obitime;
      var 
    numbars;
      
      if( 
    g_NoProcess )
        return 
    null;  

      
    obi getOldestBarIndex();
      
    obitime rawtimeobi );

      
    obitime getValue"rawtime"obi );
      
    debugPrint"Foo\n" );


    Foo gets printed only once if getValue( "rawtime", obi ) or getValue( "rawtime", obi, 1 ), or rawtime() is used. If I remove that line, then "Foo" gets printed once per bar and tick as is appropriate.

    How can I work around this such that I can retrieve the raw time and continue to have main() get called per tick?

  • #2
    fatrat
    I am not sure I understood correctly what you are trying to do but if you want to retrieve the rawtime of each bar then you would just use rawtime(0) or getValue("rawtime",0) and it should return the timestamp expressed as seconds from 00:00 of 1/1/1970 (see image below which is based on the enclosed revision of your code)
    Alex

    PHP Code:
    /
    // Initial Entry Point
    //

    function main()
    {
      var 
    resultobi;
      var 
    obitime;
      var 
    numbars;
      
      
    //if( g_NoProcess )
       // return null;  

      
    obi getOldestBarIndex();
      var 
    obitime1 rawtime);
      var 
    obitime2 getValue"rawtime");
      
    debugPrint(getCurrentBarIndex()+" "+obitime1+" "+obitime2+" Foo\n" );

    Comment

    Working...
    X