Hello,
This is all about processes and OLE.
In Windows OLE automation is intended to control
one process from another process.
You are getting problems because you attempt to
control same process from
the same process and OLE calls are SYNCHRONOUS.
I.e. they WAIT for the completion
before returning control to the calling
process.
In short you need to run OLE calls from separate
process.
Here is example:
Save your script to a .JS file and use CSCRIPT
yourscript.js command line.
For example this:
AB = new
ActiveXObject("Broker.Application");
AA = AB.Analysis;
WScript.Echo("Before exploration");
AA.Explore();
WScript.Echo("After exploration");
WScript.Echo("Before backtest");
AA.Backtest();
WScript.Echo("After backtest");
Save it as test.js on the C:\ drive
Then from windows COMMAND LINE use
CSCRIPT C:\test.js
and you will see AmiBroker performing exploration
and then backtest, synchronously, i.e. you will
see that script WAITS for AmiBroker to complete. No
additional synchronization is needed as OLE
does that for you.
The above must be run from the script. Scripts can
be run periodically and/or non-stop using simple loop
inside script or windows scheduler. Not from the
indicator. Indicators are NOT the correct place for that.
All your problems come from the fact that you
insist to use indicator to drive all other things while
indicators are NOT correct place for
that. If you attempt to use indicator
to issue OLE commands you are essentially going for
chicken-and-egg problem, because
you attempt to issue synchronous (i..e LOCKING)
call from the same process.
What you are doing is attempting to raise the chair
you are sitting on. You can't do that - you will fall on the floor on
attempt of doing that.
Mike's example is workaround because it essentially
runs the script in separate process.
You would however have a lot less problems if you
do things correct way, i.e. using OLE from external script
only.
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: Herman
To: Mike
Sent: Sunday,
November 16, 2008 7:02 PM
Subject: Re:
[amibroker] Re: When does AmiBroker execute RefreshAll?
thank you Mike, sounds/looks good. I'll play with
that.
But I thought there was some reason why we cannot
launch AA operations from indicators?
Best regards,
herman
Sunday, November 16, 2008, 12:49:50 PM, you
wrote:
> Herman,
> You probably do not need to be running a
continuous batch file
> processor. Just include the script launching
behavior in your AFL.
> I know that more OLE is the last thing you
want. But, it may simplify
> your setup.
> e.g.
> Filename = "jstest.js";
> Handle = fopen(Filename, "w");
> fputs("WScript.Echo(\"Hello Herman.\");",
Handle);
> fclose(Handle);
> Shell =
CreateObject("WScript.Shell");
> Shell.Run(Filename, 0,
true);
> fdelete(Filename);
> The run command is defined here
http://msdn.microsoft.com/en-
> us/library/d5fk67ky(VS.85).aspx
> Mike
>
------------------------------------
> **** IMPORTANT ****
> This group is for the discussion between
users only.
> This is *NOT* technical support
channel.
> *********************
> TO GET TECHNICAL SUPPORT from AmiBroker
please send an e-mail directly to
> SUPPORT {at} amibroker.com
> *********************
> For NEW RELEASE ANNOUNCEMENTS and other news
always check DEVLOG:
>
http://www.amibroker.com/devlog/
> For other support material please check
also:
>
http://www.amibroker.com/support.html
> *********************************
> Yahoo! Groups Links
> <*> To visit your group on the web, go
to:
> http://groups.yahoo.com/group/amibroker/
> <*> Your email settings:
> Individual Email |
Traditional
> <*> To change settings online go
to:
> http://groups.yahoo.com/group/amibroker/join
> (Yahoo! ID required)
> <*> To change settings via
email:
> mailto:amibroker-digest@xxxxxxxxxxxxxxx
> mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
> <*> To unsubscribe from this group,
send an email to:
> amibroker-unsubscribe@xxxxxxxxxxxxxxx
> <*> Your use of Yahoo! Groups is
subject to:
> http://docs.yahoo.com/info/terms/
|