Passing values to external DLLs

Questions about MultiCharts .NET and user contributed studies.
User avatar
michal
Posts: 5
Joined: 10 Aug 2018

Passing values to external DLLs

Postby michal » 28 Sep 2018

Hi all, I've been having problems with using external DLLs. Basically I'm trying to put everything I can into an outside DLL and leave in PLStudies2010 only the bare minimum which is strategy logic and calls to the DLL. Then the DLL would take care of position sizing, pre-entry checks, order management, risk management, exit, monitoring and store common classes and methods used by strategies from PLStudies2010. To do that I'm trying to pass objects like SignalObject which is a signal or Bars which is a data series but somehow I can't seem to make it work. An example would be this piece of code which returns an error on the marked line. The bars object can't be reached because it has been optimized away.

Code: Select all

using System;
using PowerLanguage;

namespace Resources.Analysis
{
public static class CandleAnalysis
{
public static CandleColor Color(IInstrument bars, int candleOffset)
{
if (bars == null || bars.CurrentBar <= candleOffset) // <<<<HERE
throw new ArgumentException("Candle color analysis refers to incorrect arguments");
double bar_body = bars.Close[candleOffset] - bars.Open[candleOffset];
if (PublicFunctions.DoubleLess(bar_body, 0.00))
return CandleColor.Red;
if (PublicFunctions.DoubleGreater(bar_body, 0.00))
return CandleColor.Green;
return CandleColor.Dash;
}
}
}
Code optimization is set to off in my project in VS but it's impossible to switch it off in PLEditor compiler. Has anyone successfully connected an external DLL that refers to Multicharts objects like studies, data series, accounts etc? Can you give an example on how you pass Multicharts objects to the DLL?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Passing values to external DLLs

Postby Henry MultiСharts » 02 Oct 2018

Hello michal,

Please have a look at the example attached to this post.

RonS
Posts: 21
Joined: 16 Sep 2018
Has thanked: 7 times
Been thanked: 3 times

Re: Passing values to external DLLs

Postby RonS » 27 Oct 2018

I want to pass iSeries parameters to a DLL member. I have HelperMethod added as a Assembly Reference and it works for simple integers. I am unable to find the source code for ExampleUsingPlTypes (that generates the DLL). I will need to pass BarsOfData(n).xxx to the DLL from Indicators and Signals.

I am a C# newbie. I see the ExampleUsingPlTypes Indicator created a MyEx = new Example(); I haven't tried using "new" yet.

Any help is appreciated!

Ron

RonS
Posts: 21
Joined: 16 Sep 2018
Has thanked: 7 times
Been thanked: 3 times

Re: Passing values to external DLLs

Postby RonS » 28 Oct 2018

I found the ExamplesUsingPlTypes.sln and so can make some progress now.
Ron


Return to “MultiCharts .NET”