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

Plugin dll



PureBytes Links

Trading Reference Links

Tomacz,

is it possible that you give us some more example of plugin dlls, 
today I want to write a dll with two "arrays"
myatr(array, K)
where array is close ot low or..
and K is a numeric value in fact an atr value.

with the relation below :

(float) stop ;
if(L[i] < prev1)
(float) stop= SrcArray[i] - k ;
else
(float) stop= prev1;
if((SrcArray[i] - k) > prev2)
(float) stop= SrcArray[i] - k;
else
(float) stop=prev3;



/******************full code**************************/
AmiVar VMyAtr( int NumArgs, AmiVar *ArgsTable )
{
int i,j,k;
float prev1,prev2,prev3,stop;
AmiVar result;

result = gSite.AllocArrayResult();

int nSize = gSite.GetArraySize();

float *L = ArgsTable[ 0 ].array;
float *SrcArray = ArgsTable[ 1 ].array;

int nRange = (int) ArgsTable[ 1 ].val;

j = SkipEmptyValues( nSize, SrcArray, result.array );

for( i = j; i < nSize; i++ )
{
////////////////////////////
// check if there is enough data to calculate average
// skip elsewhere
////////////////////////////
if( i < j + nRange ) 
{
result.array[ i ] = EMPTY_VAL;
continue;
}
for( k = 0; k < nRange; k++ )
////////////////////////////////
// calculate Stop
////////////////////////////////
{
prev1=0;
prev2=0;
prev3=0;

(float) stop ;
if(L[i] < prev1)
(float) stop= SrcArray[i] - k ;
else
(float) stop= prev1;
if((SrcArray[i] - k) > prev2)
(float) stop= SrcArray[i] - k;
else
(float) stop=prev3;

prev3 = prev2;
prev2 = prev1;
prev1 = stop;
}
/////////////////////////////////
result.array[ i ] = (float) stop;
}
return result;
}