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?