PureBytes Links
Trading Reference Links
|
Hi Tomasz,
I have successfully been able to create an indicator by passing the
O,H,L,C as arrays to the C code. I cant figure out how to return more
than one result array to AFL.
In the following code I tried to pass an existing AFL array to the C
code and then change the values, but it did not seem to work OK.
return.result; works fine for SI as per your example
changing the values of the asi array does not work as expected
AmiVar VSwingIndex( int NumArgs, AmiVar *ArgsTable )
{
int i, j, L1;
double si, K1, R1, R2, R3, R;
AmiVar result;
result = gSite.AllocArrayResult();
int nSize = gSite.GetArraySize();
float *O = ArgsTable[ 0 ].array;
float *H = ArgsTable[ 1 ].array;
float *L = ArgsTable[ 2 ].array;
float *C = ArgsTable[ 3 ].array;
float *asi = ArgsTable[ 4 ].array;
j = SkipEmptyValues( nSize, C, result.array );
L1 = 3;
for( i = j; i < nSize; i++ )
{
K1 = max ( fabs( H[i] - C[i-1] ), fabs( L[i] - C[i-
1] ) );
R1 = fabs ( H[i] - C[i-1] );
R2 = fabs ( L[i] - C[i-1] );
R3 = fabs ( H[i] - L[i] );
if ( (R1 > R2) & (R1 > R3) )
R = fabs(H[i]-C[i-1])-.5*fabs(L[i]-C[i-1])
+.25*fabs(C[i-1]-O[i-1]);
else if ( (R2 > R1) & (R2 > R3) )
R = fabs(L[i]-C[i-1])-.5*fabs(H[i]-C[i-1])
+.25*fabs(C[i-1]-O[i-1]);
else if ( (R3 > R1) & (R3 > R2) )
R = fabs(H[i]-L[i])+.25*fabs(C[i-1]-O[i-1]);
si = C[i]-C[i-1] + 0.5*(C[i]-O[i]) + 0.25*(C[i-1]-O[i-
1]);
si = (50 * si / R) * (K1/L1);
result.array[i] = (float) si;
asi[i] = asi[i-1] + (float) si;
}
return result;
}
--- In amibroker@xxxx, "Tomasz Janeczko" <amibroker@xxxx> wrote:
> Dear Cliff Elion,
>
> Check out the ReadMe.html and the supplied examples in C++ and VB
> in the beta archive (Plugins/src subdirectory for C++ sample code).
>
> Best regards,
> Tomasz Janeczko
> amibroker.com
>
>
> ----- Original Message -----
> From: <cliffelion@xxxx>
> To: <amibroker@xxxx>
> Sent: Monday, October 29, 2001 4:16 PM
> Subject: [amibroker] plug-in's
>
>
> > Has anyone done any work with the plug-in's?
> >
> > I am looking at attempting my first plug-in. Where can I find
> > documentation or example of how to pass several arrays to the C
> > function. (ie H,L,C,O) and then return several arrays back to
Ami
> > such as (buy, buyprice .... ).
> >
> > Thanks for your help
> >
> > Cliff Elion
> >
> >
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
> >
|