I caught an error "NinjaTrader.Indicators.CurrentDayOHL is a type but is used as a variable".
I use this indicator CurrentDayOHL() in my code in order to find the nearest StopLoss level. For example:
protected override void OnOrderUpdate(....) {
.....
if (order.IsLong) {
SetStopLoss("", CalculationMode.Price, CurrentDayOHL().CurrentLow[1], false);
}
if (order.IsShort) {
SetStopLoss("", CalculationMode.Price, CurrentDayOHL().CurrentHigh[1], false);
}
....
}
And this code works fine when I compile it from the source. There is not an error.
When I try to export my strategy via "Tools - Export - NinjaScript Add-On..." WITHOUT protect the code http://joxi.ru/1A5VKxLTDqzzMr - everything works fine too. Ninja just proposes me include an indicator @CurrentDayOHL.cs in NinjaScript Archive File http://joxi.ru/KAxaBopcZzvVLr. After that everything works fine.
But when I try to protect my code using this option "Protect compiled assembly" - I get an error "NinjaTrader.Indicators.CurrentDayOHL is a type but is used as a variable"
How should I rewrite my code to use CurrentDayOHL() indicator correctly in the case "Protect compiled assembly"?
I tried to define a variable 'curDayOHL' like a CurrentDayOHL type:
private CurrentDayOHL curDayOHL;
And then use it like this:
curDayOHL().CurrentLow[1] instead of CurrentDayOHL().CurrentLow[1] - get an error of compilation "The name 'curDayOHL' does not exist in the current context"
Try to use like this:
curDayOHL.CurrentLow[1] instead of CurrentDayOHL().CurrentLow[1] - compilation is successful. But I get an error during work 'Object reference not set to an instance of an object'
Could you help me to fix this issue?
Comment