OLD Analysis vs NEW Analysisdocs in OLE

#1
The old analysis object is able to set the rangefromdate and rangetodate but it said that this object is obsolete. But the new automatic analysis is using "ANALYSISDOCS", however it seems that it does not contain the properties for specifying the range to scan or explore. Is that true? If yes, what is the new advantages of using the "ANALYSISDOCS", given that Old analysis is more flexible in settings. Thanks.

Analysis

This object is obsolete. It is provided only to maintain compatibility with old code. Analysis object always accesses OLD Automatic Analysis.

Properties:

RangeMode As Long
RangeN As Long
RangeFromDate As Date
RangeToDate As Date
ApplyTo As Long

Reference:
http://www.amibroker.com/guide/objects.html#AnalysisDocs
 

trash

Well-Known Member
#2
OLE is not multi-threading friendly. It is old Microsoft technology.

Old Analysis is not multi-threaded. New one is.

And in New analysis you can save project files (.apx) that save your AFL and save all settings and for example can call them from outside. And those apx files are of type XML. So they are easily readable/editable also.


Code:
Hello,

For what is worth - [b]it is highly discouraged to use OLE inside any AFL
formula including scripting parts because OLE is not multithreaded.[/b]


For popup windows there is one, easy, multi-threading friendly and script-less
method:

native AFL PopupWindow function
http://www.amibroker.com/f?popupwindow

Best regards,
Tomasz Janeczko
amibroker.com
etc. etc.
 
Last edited:

trash

Well-Known Member
#3
.............

Hello,

Could you please send your entire formula to support so we can actually run it ?
Plus send your settings too (go to the old Settings window and press "Save" and send .abs file).
Only then (after running actual formula that you use) things can be analyzed and proper answer can be given.

Generally speaking New Analysis window in 5.49 is way faster. On my end all explorations
run 10 times faster in New Analysis window.
I am not however, doing things that are inherently slow like inefficient use of OLE.

First you need to verify if you are really using 5.49.2. Earlier versions behave differently. Specifically
5.49.2 has specifically implemented a feature that guarantees that code that has
Status("stocknum")==0 statement run first symbol in one thread, WAITS until it is complete
and only then it runs other threads.

Secondly, you should strictly avoid calling CreateObject() and any OLE methods when NOT necessary.
Using OLE means that all threads calling it must STOP and wait for UI thread to handle any OLE call.
This is because of how Microsoft designed OLE, see:
http://blogs.msdn.com/b/oldnewthing/archive/2008/04/24/8420242.aspx
You need to keep in mind that OLE is very old technology and it is NOT multithreaded. Any OLE call
is always handled by one and only one UI (user interface) thread with additional overhead if you attempt to do that from
other (working) threads.


So if your code needs to do some OLE processing on very first symbol only, you should write

if( Status("stocknum") == 0 )
{
// do ANY OLE COM only if absolutely needed,
AB = CreateObject("Broker.Application");

AS = AB.Stocks;
count = AS.Count;


}

That will guarantee that other threads do not need to suffer from OLE deficiencies.

Calling OLE unconditionally - outside if statement - just adds unnecessary wait for UI thread
and it is slow and effectively prohibits multithreading.


Best regards,
Tomasz Janeczko
amibroker.com
 
Last edited:

mastermind007

Well-Known Member
#5
OLE is not multi-threading friendly. It is old Microsoft technology.

Old Analysis is not multi-threaded. New one is.

And in New analysis you can save project files (.apx) that save your AFL and save all settings and for example can call them from outside. And those apx files are of type XML. So they are easily readable/editable also.


Code:
Hello,

For what is worth - [b]it is highly discouraged to use OLE inside any AFL
formula including scripting parts because OLE is not multithreaded.[/b]


For popup windows there is one, easy, multi-threading friendly and script-less
method:

native AFL PopupWindow function
http://www.amibroker.com/f?popupwindow

Best regards,
Tomasz Janeczko
amibroker.com
etc. etc.
How do I disable my entire AFL from getting embedded into the .apx file. When formula is embedded, as I amend/update/fix errors in the AFL file, .apx file continues to refer to its own embedded copy which I cannot easily update
because all line feeds are replaced with \r\n
 

trash

Well-Known Member
#6
How do I disable my entire AFL from getting embedded into the .apx file. When formula is embedded, as I amend/update/fix errors in the AFL file, .apx file continues to refer to its own embedded copy which I cannot easily update
because all line feeds are replaced with \r\n
To update your APX file is pretty easy, IMO.

Click File>Open... and browse to your apx file and open it.
If the afl embedded in your apx file is equal to the afl in your formulas folder then nothing will happen (no pop up message will appear) and the analysis opens with your settings and embedded afl.

If your afl is not equal to the afl of your formulas folder then a pop up message will appear asking you whether you want to keep the afl that is part of your formulas folder or whether you want to overwrite that afl with the afl of your project file. So since you wanna keep the AFL of your formulas folder you click the first option of that pop up message. Then the analysis window opens and then go to File>Save. That's it and your updated AFl is now part of your project file.
 

mastermind007

Well-Known Member
#7
To update your APX file is pretty easy, IMO.

Click File>Open... and browse to your apx file and open it.
If the afl embedded in your apx file is equal to the afl in your formulas folder then nothing will happen (no pop up message will appear) and the analysis opens with your settings and embedded afl.

If your afl is not equal to the afl of your formulas folder then a pop up message will appear asking you whether you want to keep the afl that is part of your formulas folder or whether you want to overwrite that afl with the afl of your project file. So since you wanna keep the AFL of your formulas folder you click the first option of that pop up message. Then the analysis window opens and then go to File>Save. That's it and your updated AFl is now part of your project file.
Trash

Thanks for responding.

Unfortunately, it does not do that (or maybe I've got some setting wrong)

Suppose name of exploration afl is xyz.afl and name of analysis is xyz.apx. I run it thru WScript (.js) file. What it does is it creates another copy of AFL with name like xyz_imported.afl and continues to refer to it (as I keep editing and reediting afl and keep wondering how come none of my changes are appearing when I ran thru script.
 

trash

Well-Known Member
#8
Trash

Thanks for responding.

Unfortunately, it does not do that (or maybe I've got some setting wrong)

Suppose name of exploration afl is xyz.afl and name of analysis is xyz.apx. I run it thru WScript (.js) file. What it does is it creates another copy of AFL with name like xyz_imported.afl and continues to refer to it (as I keep editing and reediting afl and keep wondering how come none of my changes are appearing when I ran thru script.
No, it works for me. You are possibly doing something wrong.

Do the apx file update manually. Re-read my post.
 

Similar threads