Still struggling with this! Is there an object overview (methods and properties) available on IB Controller - as with "AmiBroker's OLE Automation Object Model" overview?
Best regards Jens --- In amibroker@yahoogroups.com, "tiedemj" <h...@...> wrote: > > Really excellent information Jules - thank you for taking time out to > explain! I does look a bit involved - but if thats what it takes, I will go > that route. > > Only one last question to Tomasz before diving in - would you suggest an > alternative approach? - or do you have additional hints in regards to IB > Controller since Jules example is for AmiBroker? > > Best regards > Jens > > > > --- In amibroker@yahoogroups.com, "jooleanlogic" <jooleanl@> wrote: > > > > > > > > If you've never worked with com before Jens, then no it's probably not > > trivial. At least it wasn't for me. > > I haven't used the IB interface at all and am no com expert, but I've > > managed to interface with Amibroker so will outline how I went about it. > > > > Here's a useful tute on it > > http://www.relisoft.com/win32/auto.html > > all done with OO and strict resource management. That's where I started and > > then it took me a lot of testing and googling from there. > > > > Here's the basic steps and I've put some of my code to match below. It's > > based on objects used from the tute above. > > > > 1. Initialise/Uninitialise COM. This is done using ::OleInitialize and > > ::OleUnInitialize which I have as constructor and destructor calls in the > > ComClass used below. > > 2. Get the ClassID for the com object you want. "BrokerIB.Application" as > > paultsho said. > > 3. Get IDispatch interface to object using a call to ::CoCreateInstance. > > This call is wrapped in the constructor of DispObject. > > 4. Use DispObject.GetProperty to access properties and functions of the com > > object. COM data types are passed via the VARIANT union data type. > > 5. I don't know if the IB interface has child objects but to access a > > different com object, you get a VARIANT.pdispVal to it via > > DispObject.GetProperty and then pass that VARIANT into the DispObject > > constructor. I.e. you access other com objects from existing ones. This is > > shown below when getting the Amibroker Stocks object from the Application > > object. > > > > // Basic wrapper code > > > > // 1. Initialises OLE. > > ComClass comClass; > > > > // 2. Retrieve Class ID. > > CLSID clsIdAmibroker; > > HRESULT hr = ::CLSIDFromProgID (L"Broker.Application", &clsIdAmibroker); > > > > // 3. Get IDispatch interface to Amibroker Application object. > > // This calls ::CoCreateInstance internally > > DispObject amibroker(clsIdAmibroker); > > > > // 4. Get the Version property of the Application object > > VARIANT varResult; > > amibroker.GetProperty(L"Version", varResult); > > // Convert VARIANT datatype to a normal string > > string version(_bstr_t(varResult.bstrVal)); > > > > // 5. Access Stock object IDispatch interface using existing Application > > interface > > ::VariantInit(&varResult); > > amibroker.GetProperty(L"Stocks", varResult); > > DispObject stocks(varResult); > > > > There's plenty more to it but I wouldn't want to spoil the fun for you. > > > > Here's some useful links > > VARIANT Data Type > > http://msdn.microsoft.com/en-us/library/ms221627.aspx > > > > IDispatch Interface > > http://msdn.microsoft.com/en-us/library/ms221608.aspx > > > > COM string conversions > > http://www.codeguru.com/cpp/cpp/string/conversions/article.php/c5639/ > > > > Most of what you'll need can be found at msdn by just following the links > > from one function to another. > > > > Hope that helps a bit. > > > > Jules. > > > > > > > > --- In amibroker@yahoogroups.com, "tiedemj" <home@> wrote: > > > > > > > > > Hello Tomasz > > > > > > I would be nowhere without the simplicity - yet unparalleled power of > > > AFL. > > > > > > However, over time, refinement of "checks and balances" deployed for a > > > (real money) automated trendline trading system had grown quite complex. > > > Long story short - in order to improve entegrity of the system I went > > > from "procedural" to "real oo" (abstraction using classses, inheritance > > > etc.), by moving some functionability into plugin (thus using C++ to > > > provide the OO aspects). > > > > > > For the TWS link, I'm quite happy with IB Controller, and in particular > > > the "window" into what goes on between AmiBroker and TWS - but I'm > > > unhappy with my (own) interface to IB Controller (from plugin through AFL > > > and feedback to plugin again - since plugin has a static part keeping > > > track of real trades - that have dynamic exit points - so they need to be > > > "managed" throughout the trade). > > > > > > So if you can give me some hints on how to interface with IB Controller > > > (a COM object - right?) so that methods and attributes are exposed in C++ > > > plugin (I'm using visual studio 2008), I would be very grateful indeed! > > > > > > Regards > > > > > > Jens > > > > > > > > > > > > > > > --- In amibroker@yahoogroups.com, Tomasz Janeczko <groups@> wrote: > > > > > > > > Hello, > > > > > > > > First and foremost: why would you like to do that ?? (it is possible, > > > > but why make things harder when you can do this > > > > from AFL?) > > > > > > > > Best regards, > > > > Tomasz Janeczko > > > > amibroker.com > > > > > > > > On 2010-04-09 19:03, tiedemj wrote: > > > > > Tx, but nothing in TWSAPI forum about how to call IB Broker interface > > > > > directly from a C++ Amibroker plugin. Also, not possible to call user > > > > > defined functions (in afl) from C++ Amibroker plugin using > > > > > gSite.CallFunction() - so I'm stuck... > > > > > > > > > > Anybody? > > > > > > > > > > Best regards > > > > > Jens Tiedemann > > > > > > > > > > --- In amibroker@yahoogroups.com, "reefbreak_sd"<reefbreak_sd@> > > > > > wrote: > > > > > > > > > >> There is a Yahoo! discussion group TWSAPI that talks about the IB > > > > >> TWS interface. > > > > >> > > > > >> > > > > >> > > > > >> --- In amibroker@yahoogroups.com, "tiedemj"<home@> wrote: > > > > >> > > > > >>> > > > > >>> bump - anybody? > > > > >>> > > > > >>> I've seen this question asked before - but can't find any answers. > > > > >>> Can somebody just give a hint (if the explanation is not trivial...) > > > > >>> > > > > >>> best regards > > > > >>> > > > > >>> Jens Tiedemann > > > > >>> --- In amibroker@yahoogroups.com, "tiedemj"<home@> wrote: > > > > >>> > > > > >>>> Assume it's possible to call IB Controller directly from an > > > > >>>> AmiBroker c++ plugin. Can anybody show how to do it in native c++? > > > > >>>> > > > > >>>> Best regards > > > > >>>> > > > > >>>> > > > > >>> > > > > >> > > > > > > > > > > > > > > > > > > > > ------------------------------------ > > > > > > > > > > **** 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/ > > > > > > > > > > Yahoo! Groups Links > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >