Example of using DLL in Multicharts

Questions about MultiCharts and user contributed studies.
maxmax68
Posts: 163
Joined: 20 Nov 2012
Has thanked: 55 times
Been thanked: 48 times

Example of using DLL in Multicharts

Postby maxmax68 » 31 Jan 2017

Hello,
I just started learning VisualBasic to learn how to create Dll with Visual Studio for use with MC.
I'm just a novice and I'll probably be asking something stupid or wrong,
but I would be very grateful if some Dll experienced programmer would provide an example of a very basic open source code of how to draw a button in a chart of Multicharts and how to draw a horizontal trendline at close at pressing of the button.

A simple practical example sometimes helps a lot more than the references to textbooks,
I hope for a good Samaritan.

Thanks in advance
Best regards
Massimo

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

Re: Example of using DLL in Multicharts

Postby TJ » 31 Jan 2017


hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Re: Example of using DLL in Multicharts

Postby hughesfleming » 05 Feb 2017

Hi Massimo,

I am not sure that visual basic is the right tool for the job. You might as well switch your license to MC.net and use C# or VB.net. You might also consider Code Typhon 64 (Object Pascal) if you must create Dll's for Easylanguage Multicharts. Just import the SDK type library, write your code and then compile your DLL.

Here is an example of an Simple Moving Average that imports PLkit.dll. Code syntax is not that different from EasyLanguage.

Code: Select all

library smadll;

{$mode objfpc}{$H+}

uses
Classes, PLKit_1_0_TLB;


var price,sum: double;
var i: integer;

function SMAdll(pELObj : IEasyLanguageObject; period:integer): double; stdcall;

begin


if period < 1 then exit(0);


sum := 0;
for i := 0 to period-1 do
begin
Price := pELObj.CloseMD[data1].AsDouble[i];
sum := sum + price;
end;
result := sum / period;
end;

exports SMAdll;



begin
end.

Calling your DLL from Easylanguge:

Code: Select all


external: "smadll.dll", double, "SMAdll", IEasyLanguageObject {self},int {length};

CloseData1 = SMAdll(self,length);

maxmax68
Posts: 163
Joined: 20 Nov 2012
Has thanked: 55 times
Been thanked: 48 times

Re: Example of using DLL in Multicharts

Postby maxmax68 » 05 Feb 2017

Just import the SDK type library, write your code and then compile your DLL.
Hello hughesflemming,
thank you very much for the example, you were very kind.
I'm just the at first steps with the DLL,and not being a programmer at this moment I confess to being very confused.
The words "import SDK library" and "compile DLLs" are obscure for me at the moment.
I understand to be too far behind with the study so for now I thank you for the time you gave me and quit.

Any DLL guide for Dummies ?

Best regards
Massimo

hughesfleming
Posts: 275
Joined: 22 Apr 2014
Has thanked: 70 times
Been thanked: 72 times

Re: Example of using DLL in Multicharts

Postby hughesfleming » 05 Feb 2017

I don't think there is a Dll's made easy guide somewhere because it is not that easy. With that in mind, I do think that you should only consider taking the time to write dlls when you absolutely can't find any other way to solve the problem in EL. It is important to also know your limitations. Even if you do get comfortable in a couple of languages, your best investment will still be to consult a professional programmer. This is especially true with automated trading.

regards,

Alex


Return to “MultiCharts”