[amibroker] Timer delay function [1 Attachment]

 
[Attachment(s) from poo1971@yahoo.com.au [amibroker] included below]

Hello all.
I hope somebody who is a bit smarter than me might be able to help work this code out.
I'm chasing a function which basically puts itself in a loop for 20 seconds and halts the flow of code whilst it's doing so. I'm chasing this so once IBC controller has fired off a bunch of orders I need the program to wait for 20 seconds odd so that TWS has time to fill all the positions and the call ibc.GetPositionList(); has time to catch up and return a correct list of positions.

So I had a crack at knocking up a timer function here is the code below


function Timer(initset,endtm )
{
 starttm =GetPerformanceCounter()/1000;
 elapsed = GetPerformanceCounter()/1000;
 
 if (initset == 0)
   {
     StaticVarSet("starttime", starttm);
     endtm = StaticVarGet("starttime") + 20;
     StaticVarSet("endtime", endtm);
    
     _TRACE(" ### statics set ######") ;
     _TRACE(" initset " + initset);
     _TRACE(" starttime in if statement = " + StaticVarGet("starttime"));
     _TRACE(" endtime in if statement = " + StaticVarGet("endtime"));
     }
initset == 1; 
 _TRACE(" elasped " + elapsed);
  _TRACE(" static var endtime = " + StaticVarGet("endtime"));
_TRACE(WriteIf(((elapsed) < (StaticVarGet("endtimetime"))), "before while is True", "before while is False"));
 
 while( elapsed < StaticVarGet("endtimetime") ) 
   {
     _TRACE(WriteIf(elapsed < StaticVarGet("endtimetime"), "True", "False"));
     _TRACE(" starttime in while loop = " + StaticVarGet("starttime"));
     _TRACE(" endtime in while loop = " + StaticVarGet("endtime"));
     _TRACE(" elasped " + elapsed);
     _TRACE(" initset " + initset);
     }
     
   _TRACE(" finished " + elapsed); 
 
}
Timer (0,0);

It's got more trace lines than a fisherman's tackle box LOL.

the code is storing the start number, adding 20 seconds and storing the end number correctly. The problem seems to be the while statement keeps coming up false. If you look at the photo of debug view line 5 gives us an elapsed time of 31869.2, line 6 static variable endtime is 31889.2. Line 7 is telling us that the statement elapsed time < static variable endtime is false. So 31869.2 < 31889.2 is false?
That bits got me stumped!!!


Any help from some Smarties would be sweet!

Cheers

Brent.


__._,_.___

Attachment(s) from poo1971@yahoo.com.au [amibroker] | View attachments on the web

1 of 1 Photo(s)


Posted by: poo1971@yahoo.com.au
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic ()

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___

Related Posts


EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng
:lv