[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [amibroker] There are some AB users using Delphi to automated AB ?



PureBytes Links

Trading Reference Links

Hi Guys,

The easiest (and fastest, in terms of code) way of automating AmiBroker is to import the type-library, which will allow Delphi to use early binding.  You can use late binding, put there is a performance penalty for doing so, and I find it harder to find bugs as you can't use the Delphi IDE's type-checking features.  Once you import the type library, it can be saved in your Delphi environment (dclusr.dpk) and then can be used later by simply adding "broker_tlb" to your uses clause.

An example is included below.  Once the uses clause has broker_tlb, you can then define a variable of type TApplication, which is an instance of Amibroker.  By declaring a variable of the type, and the instantiating the object, you will be prompted with all the available methods and properties by the code-completion features built in to Delphi.  This can be a huge time-saver, which is why I say use the TLB.

Try the example and let me know if it make sense.  Both early and late binding are shown.  I uploaded the example to the Amibroker group at http://finance.groups.yahoo.com/group/amibroker/files/, under the name ABAutomation.zip.  

Daniel
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComObj, Broker_TLB, StdCtrls, Buttons, OleServer;

type
  TForm1 = class(TForm)
    btnEarlyBinding: TButton;
    btnLateBinding: TBitBtn;
    procedure btnEarlyBindingClick(Sender: TObject);
    procedure btnLateBindingClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnEarlyBindingClick(Sender: TObject);
var
  AFLFolder: string;
  AB, AA: OleVariant;
begin

  AFLFolder := 'C:\\Program Files\\AmiBroker\\AFL\\';

  AB := CreateOLEObject('Broker.Application');
  AA := AB.Analysis;

  AA.ClearFilters;
  AA.ApplyTo := 0;
  AA.RangeMode := 0;

  if AA.LoadFormula(AFLFolder + 'VolatilitySystem.afl') then begin
    AA.Backtest;
    AA.Report('C:\\report_export.htm');
  end;

  AB.Quit;

end;

procedure TForm1.btnLateBindingClick(Sender: TObject);
var
  AFLFolder: string;
  AB: TApplication;
  AA: Analysis;
  BacktestType: OleVariant;
begin
  AFLFolder := 'C:\\Program Files\\AmiBroker\\AFL\\';

  AB := TApplication.Create(nil);
  AA := AB.Analysis as Analysis;

  AA.ClearFilters;
  AA.ApplyTo := 0;
  AA.RangeMode := 0;

  BacktestType := 0;  // Use Portfolio backtester
  if AA.LoadFormula(AFLFolder + 'VolatilitySystem.afl') then begin
    AA.Backtest(BacktestType);
    AA.Report('C:\\report_export.htm');
  end;

  AB.Quit;
end;

end. 

  On Mon, 8 Nov 2004 10:09:31 -0500, dingo wrote:
>
> The delphi guys hang out on the DLL forum (amibroker-dll) for the
> most part. Read some of the archives there. Daniel Ervi seems to
> know his stuff.
>
> d
>
>
> _____
>
> From: tintin92 [mailto:tintin922002@xxxxxxxx]
> Sent: Monday, November 08, 2004 3:41 AM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] There are some AB users using Delphi to
> automated AB ?
>
>
> Hi,
>
> There are some AB users using Delphi to automated AB ?
> If yes, which means do you use ?
> OLE without TBL file,  OLE with TBL file,  DLL ?
>
> Tintin92
>
>
> Check AmiBroker web page at:
> http://www.amibroker.com/
>
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
>
> Yahoo! Groups Sponsor
>
> ADVERTISEMENT
>
> <http://us.ard.yahoo.com/SIG=1296nbb7p/M=294855.5468653.6549235.300117
> 6/D=gr
> oups/S=1705632198:HM/EXP=1099989645/A=2376776/R=0/SIG=11ldm1jvc/*
> http://prom otions.yahoo.com/ydomains2004/index.html> click here
>
> <http://us.adserver.yahoo.com/l?M=294855.5468653.6549235.3001176/D=gro
> ups/S= :HM/A=2376776/rand=739527189>
>
>
> _____
>
> Yahoo! Groups Links
>
>
> *        To visit your group on the web, go to:
> http://groups.yahoo.com/group/amibroker/
>
>
> *        To unsubscribe from this group, send an email to:
> amibroker-unsubscribe@xxxxxxxxxxxxxxx
> <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
>
>
> *        Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/> .
>
>
> [Non-text portions of this message have been removed]
>
>
> ------------------------ Yahoo! Groups Sponsor --------------------
> ~--> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
> Now with Pop-Up Blocker. Get it for free!
> http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
> --------------------------------------------------------------------
> ~->
>
> Check AmiBroker web page at:
> http://www.amibroker.com/
>
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html Yahoo!
> Groups Links
>
>
>




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> 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/