Can't find function in .dll  [SOLVED]

Questions about MultiCharts and user contributed studies.
renochen
Posts: 6
Joined: 19 Jan 2016
Been thanked: 1 time

Can't find function in .dll

Postby renochen » 24 Oct 2016

Hi everyone,

I tried to use extension SDK of PL and was stuck in an error: Can't find function in .dll
My steps are as follows and hopefully could get some feedback.

1. The document http://www.TS.com/~/media/Fil ... on_SDK.pdf

2. Need to use "PLKit.dll" instead of "tskit.dll"

3. Need to check the version of your MC. 64bit can't read 32 bit .dll

4.
/* dll file */

Code: Select all

#include "stdafx.h"
#include <atlbase.h>
#import "C:\Users\Desktop\MC Util\PLKit.dll" no_namespace

double __stdcall MovAvg
(IEasyLanguageObject * pELObj, int iAvgLength)
{
double dMovAvg;
dMovAvg = 0;
// verify that sufficient bars have passed before back-referencing historical prices
if (pELObj->CloseMD[data1]->barsback > iAvgLength && iAvgLength > 0)
{
double dSum = 0.0;
for (int i = 0; i < iAvgLength; i++)
{
dSum += pELObj->CloseMD[data1]->AsDouble[i];
}
dMovAvg = dSum / iAvgLength;
}
return dMovAvg;
}
5.
/* Easy Language Script */

Code: Select all

DEFINEDLLFUNC: "C:\Users\Desktop\MC Util\test2\x64\Debug\test2.dll",
double, "MovAvg", IEasyLanguageObject {self}, int;

inputs: Length(NumericSimple);
variables: int MyELVar( 0 ) ;
m_test = MovAvg( self, Length ) ;
6. Run time error: "Can't find function "MovAvg" in dll.
Last edited by renochen on 24 Oct 2016, edited 1 time in total.

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Re: Can't find function in .dll

Postby TJ » 24 Oct 2016

see posts #1 and #2

[FAQ] How to Post Codes (... so that people can read)
viewtopic.php?f=16&t=11713

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Can't find function in .dll  [SOLVED]

Postby JoshM » 25 Oct 2016

6. Run time error: "Can't find function "MovAvg" in dll.
Whenever I come across that error, I either compiled the DLL incorrectly or used the wrong code inside the PowerLanguage code to declare the DLL function.

Besides the `DefineDLLFunc` you can also use `External` to see if declaring MovAvg like that helps. (I don't recall the difference between `DefineDLLFunc` and `External`, and when one should be used over the other.)


Return to “MultiCharts”