You know, after attempting to implement this myself, I have come to the conclusion that not only is it more efficient to calculate the BUY/SELL condition in the DLL, it is simpler also, because you don't have to pass a parameter to the DLL, and you don't have to determine if you are looking for a BUY signal or a SELL signal or write two seperate functions or any of that. Here's the formula I'd use:
[code:1:bd7b5ee67c]ExtFml( "MSXDll.MakeMyPosition" )[/code:1:bd7b5ee67c]
Here is the MSXNthFunction function:
[code:1:bd7b5ee67c]BOOL __stdcall MSXNthFunction(int a_iNthFunc, MSXFuncDef* a_psFuncDef)
{
BOOL l_bRtrn = MSX_SUCCESS;
switch(a_iNthFunc)
{
case 0:
strcpy(a_psFuncDef->szFunctionName, "MakeMyPosition");
strcpy(a_psFuncDef->szFunctionDescription, "MakeMyPosition Description");
a_psFuncDef->iNArguments = 0;
break;
default:
l_bRtrn = MSX_ERROR;
break;
}
return l_bRtrn;
}[/code:1:bd7b5ee67c]
Here's the MSXNthArg function:
[code:1:bd7b5ee67c]BOOL __stdcall MSXNthArg(int a_iNthFunc, int a_iNthArg, MSXFuncArgDef *a_psFuncArgDef)
{
// There are no args, this shouldn't be called
return MSX_ERROR;
}[/code:1:bd7b5ee67c]
This doesn't require any custom strings, so your MSXNthCustomString function can just always return MSX_ERROR, just like the MSXNthArg function.
Finally, your MakeMyPosition function as I posted some time ago:
[code:1:bd7b5ee67c]BOOL __stdcall MakeMyPosition(const MSXDataRec *a_psDataRec,
const MSXDataInforRecArgsArray *a_psDataInfoArgs,
const MSXNumericArgsArray *a_psNumericArgs,
const MSXStringArgsArray *a_psCustomArgs,
const MSXCustomArgsArray *a_psCustomArgs,
MSXResultRec *a_psResultRec)
{
// First, we're going to play a sound, not return any results, so zero
// out a_psResultRec via the iFirstValid and iLastValid fields in a_psResultRec.
a_psResultRec->psResultArray->iFirstValid = 0;
a_psResultRec->psResultArray->iLastValid = -1;
// Second, get the open and close value from the last bar in the input data.
// (You'll want to do some error checking here, like making sure that there is
// actually any data in the record, and making sure that the open and close
// data both end on the same record. For the sake of brevity and clarity, I
// haven't included that kind of error checking for this example.)
float open = a_psDataRec->sOpen.pfValue[a_psDataRec->sOpen.iLastValid];
float close = a_psDataRec->sClose.pfValue[a_psDataRec->sClose.iLastValid];
// Third, compare the open and close and play the appropriate file.
// (Note that there are three possibilities here. Open could be greater than
// close, open could be less than close, or open could be equal to close. You
// didn't say anything about doing something if they are equal, so here I test
// for the greater than and less than conditions, and do nothing for the equal
// condition.)
if(open > close)
{
// Insert your code to play Sell.wav here!
}
else if(open < close)
{
// Insert your code to play Buy.wav here!
}
// We're done, return
return MSX_SUCCESS;
}[/code:1:bd7b5ee67c]
Hope that helps,
Rich