PureBytes Links
Trading Reference Links
|
Heya Steve,
Thanks for providing this example, and I'd be very interested in working with C# through Amibroker! I've given this a go and it compiles but doesn't work as a plugin as-is. Did you have to implement the getplugininfo() functions for this to work?
--- In amibroker@xxxxxxxxxxxxxxx, Steve Wong <swstevewong38@xxx> wrote:
>
> Hello,
>
> below is my experimental c# code to illustrate the original VB IIR2 example and the VExampleMA from the ADK.
> from the Amibroker side the object creation in AFL will be:
>
> myobj = CreateObject("csharp.amlib1");
> //call method
> iir2 = myobj.IIR2(Close, 0.2,1.2,-0.4);
> //calling Windows Forms
> myobj.ShowDialog("AFL called me");
>
> // c# below
> using System;
> using System.Runtime.InteropServices;
> namespace ClassLibrary3
> {
> [
> Guid("16308AFC-FB7E-4cc6-9A3B-F47B99B7F18B"),
> InterfaceType(ComInterfaceType.InterfaceIsDual),
> ComVisible(true)
> ]
> public interface IMyAmPlugin1
> {
> [DispId(1)]
> string HelloAmibroker();
> [DispId(2)]
> int ShowDialog(string msg);
> [DispId(3)]
> object IIR2( object input, float f0, float f1, float f2);
> [DispId(4)]
> object MyExampleMA(object input, int range);
> };
> [
> Guid("4328EB81-CFFF-423b-B1B4-D5B1F1AC76B7"),
> ProgId("csharp.amlib1"),
> ClassInterface(ClassInterfaceType.None),
> ComDefaultInterface(typeof(IMyAmPlugin1)),
> ComVisible(true)
> ]
> public class Class1 : IMyAmPlugin1
> {
> private const float EMPTY_VAL = -1e10f;
> public string HelloAmibroker()
> {
> return "Hello Amibroker, I'm from C#";
> }
> public int ShowDialog(string msg)
> {
>
> System.Windows.Forms.MessageBox.Show(msg, "");
> return 0;
> }
> public object IIR2(object input, float f0, float f1, float f2)
> {
> object[] inputArray = (object[]) input;
> object[] outputArray = inputArray;
> outputArray[0] = inputArray[0];
> outputArray[1] = inputArray[1];
> for (int i = 2; i < inputArray.Length; i++)
> {
> outputArray[i] = f0 * Convert.ToSingle(inputArray[i]) +
> f1 * Convert.ToSingle(outputArray[i - 1]) + f2 * Convert.ToSingle(outputArray[i - 2]);
> }
> return outputArray ;
> }
> private int SkipEmptyValues(int nSize, object[] srcArray, object[] result)
> {
> int i;
> for (i = 0; i < nSize && (Convert.ToSingle(srcArray[i]) == EMPTY_VAL); i++)
> {
> result[i] = EMPTY_VAL;
> }
> return i;
> }
> public object MyExampleMA(object input, int range)
> {
> object[] inputArray = (object[]) input;
> int nSize = inputArray.Length;
> object[] result = new object[nSize];
> int j = SkipEmptyValues(nSize, inputArray, result);
> for (int i = j; i < nSize; i++)
> {
> if (i < j + range)
> {
> result[i] = EMPTY_VAL;
> continue;
> }
> float sum = 0.0f;
> for (int k = 0; k < range; k++)
> {
> sum += Convert.ToSingle(inputArray[i - k]);
> }
> result[i] = sum / range;
> }
> return result;
> }
> }
> }
>
> Regards
> SW
>
>
>
> ________________________________
> From: Yofa <jtoth100@xxx>
> To: amibroker@xxxxxxxxxxxxxxx
> Sent: Monday, May 4, 2009 4:06:32 AM
> Subject: Re: [amibroker] Amibroker Plugin C# template? Anyone?
>
>
>
>
>
> Hi Dan,
>
> 1. make the c# code a "COM visible" component.
> 2. Register it on the AB machine.
> 3. write c++ plugin to access it as a COM component. (Use ADK)
>
> Y
>
> ------------ --------- --------- --------- --------- --
> From: "ccr1der" <dan@xxxxxxxx com>
> Sent: Thursday, April 30, 2009 7:46 AM
> To: <amibroker@xxxxxxxxx ps.com>
> Subject: [amibroker] Amibroker Plugin C# template? Anyone?
>
> > Does anyone have a C# based template for AB plugins? Has anyone ever
> > compiled a C# plugin for AB? I have a very important piece of code in C#
> > that I need accessible from within AB, and while I'm not at all well
> > versed in C#, I'm willing to take a stab at trying to get this to work....
> > but I need some kind of a starting point?
> >
> > Any help would be greatly appreciated. Thanks.
> >
> > -Dan
> >
> >
> >
> >
> > ------------ --------- --------- ------
> >
> > **** 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
> >
> >
> >
> >
>
------------------------------------
**** 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
<*> 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/
|