Trying to access and compare the CalculationMethod of an andrewPitchfork draw object so that it can be changed on command. Since this will be a compiled assembly, the use of dynamic type is required. When the code is in it's non-compiled form, the indicator will bug out. "Unhandled exception: An unexpected exception occurred while binding a dynamic operation". Upon refreshing the indicator (F5), the indicator starts to behave as normal. In its compiled form, it always throws this error.
At first, I thought it had to do with comparing enums, however, the same method is used for the RiskReward tool to check the display unit, and that works 100% of the time. I also tried a different method of comparing the enums (list, dynamic list, direct comparison). Made sure to only add the elements to the lists when the chart is loaded.
I've checked to see if the method is spelled correctly and it is. Checked to make sure that it checks the object type via name and it's doing that correctly.
dynamic andrewsPitchfork = chartObjectToChange; andrewsPitchfork.CalculationMethod == NinjaTrader.NinjaScript.DrawingTools.AndrewsPitchfork.AndrewsPitchforkCalculationMethod.StandardPitchfork dynamic riskReward = chartObjectToChange; riskReward.DisplayUnit == NinjaTrader.NinjaScript.DrawingTools.ValueUnit.Price;
Exact same code but not compiled. (still using dynamic types)
When the code is not working before the refresh of the non-compiled version, it failes when it's retrieving the calculation method. I really don't know what's going on here.
Thanks

Comment