I am developing quite complex tool. Solutions consists of lot of file which are
partial public partial class Golem: Strategy
I want to hide source code - so I am thinking to export it to dll.
But there is other think. I need to be able to run code like this, which customer can write himself code is like:
using GolemApp;
using GolemApp.Entity;
namespace NinjaTrader.NinjaScript.Strategies
{
public partial class Golem: Strategy
{
/// <summary>
/// Limitní vstup
/// </summary>
/// <param name="filter"></param>
/// <returns></returns>
public FilterResult Filter_fil1ec4b04dfc3(Filter filter)
{
int bipFilter = filter.BarsArrayIndex;
string placeTo = filter.GetParamValue<string>(0);
int offset = filter.GetParamValue<int>(1);
bool toLastCandle = filter.GetParamValue<bool>(2);
bool counterLastCandle = filter.GetParamValue<bool>(3);
double entryPrice = double.MinValue;
if (placeTo == "close")
{
entryPrice = Closes[bipFilter][lastCandleEntry];
}
Helpers.Enum_CandleDirection lastDirection = h.CandleDirection(bipFilter, lastCandleEntry);
Helpers.Enum_CandleDirection tradeDirection = Helpers.Enum_CandleDirection.Undefined;
// Vstup ve směru poslední svíčky
if (toLastCandle) {
if (lastDirection != Helpers.Enum_CandleDirection.Doji)
{
tradeDirection = lastDirection;
}
}
// Vstup proti směru poslední svíčky
if (counterLastCandle)
{
if (lastDirection == Helpers.Enum_CandleDirection.Long)
{
tradeDirection = Helpers.Enum_CandleDirection.Short;
}
if (lastDirection == Helpers.Enum_CandleDirection.Short)
{
tradeDirection = Helpers.Enum_CandleDirection.Long;
}
}
if (tradeDirection == Helpers.Enum_CandleDirection.Long)
{
// Vstup na low poslední svíčky
if (placeTo == "hi_lo")
{
entryPrice = Lows[bipFilter][lastCandleEntry];
}
entryPrice = entryPrice - offset * TickSize;
}
if (tradeDirection == Helpers.Enum_CandleDirection.Short)
{
// Vstup na high poslední svíčky
if (placeTo == "hi_lo")
{
entryPrice = Highs[bipFilter][lastCandleEntry];
}
entryPrice = entryPrice + offset * TickSize;
}
FilterResult result = new FilterResult();
result.State = Helpers.Enum_ResultState.Undefined;
result.AddPair("TradeDirection", tradeDirection.ToString());
result.AddPair("EntryPrice_Expected", entryPrice.ToString());
result.AddPair("OrderLong", "EnterLongLimit");
result.AddPair("OrderShort", "EnterShortLimit");
return result;
}
}
}
Or is there other way, to move logic out of partial Golem Strategy?
Thanks a lot for any advices
Paul

Comment