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

Re: [amibroker] How to use (ole) Retrieve() Quotations from C# ??



PureBytes Links

Trading Reference Links

You need to pass SAFEARRAYS in arguments .
Google for SAFEARRAY and C#

To access quotations one by one you should iterate through Quotations collection.

If you are not very proficient in programming, you should rather EXPORT data
to text file from AFL level which can be actually faster than OLE.
http://www.amibroker.com/kb/2006/03/04/how-to-export-quotations-from-amibroker-to-csv-file/


Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "tiedemj" <home@xxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Friday, May 02, 2008 9:22 AM
Subject: [amibroker] How to use (ole) Retrieve() Quotations from C# ??


> So close, but not yet there... Hi - I've been trying to use Retrieve
> () from Quotations in C# using the description found here:
> 
> http://groups.google.com/group/microsoft.public.dotnet.framework.inter
> op/msg/010238fcb89f94ee
> 
> Below is the code. The ole call goes fine - but it only returns the
> initialized values in the parameters going in - not the actual quotes.
> 
> Anybody knows how to use Retrieve() from c#? I've seen a number of
> posts with the same question - but not yet found an answer. Thought I
> got it made below - but so far no cigar...
> 
> Any help (really, really) appreciated!
> 
> Best regards
> Jens Tiedemann
> 
> 
> 
> 
> 
> public void GetQuotations(
> string ticker,
> object stocks)
> {
> // Set up the parameter array for the InvokeMethod call.
> // Initialize each element (to avoid nonInitialized compiler error).
> object[] ParamArray = new object[8];
> ParamArray[0] = (long) 1;
> ParamArray[1] = DateTime.Now;
> ParamArray[2] = (float) 0;
> ParamArray[3] = (float) 0;
> ParamArray[4] = (float) 0;
> ParamArray[5] = (float) 0;
> ParamArray[6] = (float) 0;
> ParamArray[7] = (float) 0;
> 
> // Set up the ParameterModifier array.
> // There are 8 parameters. Note that
> // the ParameterModifier constructor is given the number of
> // parameters
> // in the method. The indexer is used to specify which
> // parameters are out parameters.
> 
> ParameterModifier[] ParamMods = new ParameterModifier [1];
> ParamMods[0] = new ParameterModifier (8);
> // inititialize with number of method parameters
> ParamMods[0][0] = false; // Set the 1st param to be an out param
> ParamMods[0][1] = true; // set the 2nd param to be an out param
> ParamMods[0][2] = true; // set the 3rd param to be an out param
> ParamMods[0][3] = true; // set the 4th param to be an out param
> ParamMods[0][4] = true; // set the 5th param to be an out param
> ParamMods[0][5] = true; // set the 6th param to be an out param
> ParamMods[0][6] = true; // set the 7th param to be an out param
> ParamMods[0][7] = true; // set the 8th param to be an out param
> 
> // Set the call up - amiMethod/getAmiProperty do what they indicate
> // and are well tested
> object stock = amiMethod(stocks, "Item", ticker);
> object quotations = getAmiProperty(stock, "Quotations");
> string methodName = "Retrieve";
> 
> // Call the version of InvokeMember that
> // accepts a ParameterModifier array.
> long ReturnValue = 0;
> try
> {
> 
> ReturnValue = (long)quotations.GetType().InvokeMember(
> methodName, // method name
> BindingFlags.Default | BindingFlags.InvokeMethod,
> null,
> quotations, // obj being called
> ParamArray, // argument list
> ParamMods, // ParameterModifier array
> null,
> null);
> }
> catch (Exception ex)
> {
> setError("amiMethod: " + methodName + " failed!", ex);
> }
> // "Unpack" the byRef received values
> float Date = Convert.ToDateTime(ParamArray[1]);
> float Open = Convert.ToSingle(ParamArray[2]);
> float High = Convert.ToSingle(ParamArray[3]);
> float Low = Convert.ToSingle(ParamArray[4]);
> float Close = Convert.ToSingle(ParamArray[5]);
> float Volume = Convert.ToSingle(ParamArray[6]);
> float OpenInt = Convert.ToSingle(ParamArray[7]);
> 
> }
> 
> 
> 
> 
> 
> ------------------------------------
> 
> Please note that this group is for discussion between users only.
> 
> To get 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
> 
> 
> 

------------------------------------

Please note that this group is for discussion between users only.

To get 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/