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

Re: plug-in's



PureBytes Links

Trading Reference Links

Thanks Tomasz,

I have the 'return result' working and will wait for 3.79 to return 
multiple variables using SetVar!!

Thanks again,

Cliff Elion

--- In amibroker@xxxx, "Tomasz Janeczko" <amibroker@xxxx> wrote:
> Hello Cliff,
> 
> The arguments are passed to the DLL "by-value"
> it means that you can not overwrite values of arguments.
> 
> There are actually two ways of returning results from your
> DLL. One is just use return value allocated via 
> 
> AmiVar VMyDLLFunction( int NumArgs, AmiVar *ArgsTable )
> {
> result = AllocArrayResult() 
> 
> ... calculate...
> 
> return result;
> }
> 
> and use it in AFL:
> 
> returned_value = MyDLLFunction( arguments, ... );
> 
> The second way is to store the results in the variables
> using GetVar / SetVar functions from the site interface 
> (will be available in 3.79)
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> 
> 
> ----- Original Message ----- 
> From: <cliffelion@xxxx>
> To: <amibroker@xxxx>
> Sent: 29 October, 2001 21:29
> Subject: [amibroker] Re: plug-in's
> 
> 
> 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/
> > >
> > >
> > >
> 
> 
> 
> 
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/