TextPosition import & export issue in NinjaTrader 8

In case you use an indicator that contains Draw.TextFixed() or similar code, that depends on the enum TextPosition, and if you try to export it as compiled DLL, then you will have a problem. Because, when you later try to import that exported file, you might get this error:

The type or namespace name 'TextPosition' could not be found

This issue probably won’t be fixed (because NT support don’t recognise this as a problem). So, I have tried to solve this myself and finally found a “workaround”. The problem happens when you have that property as INPUT argument for indicator:

[Display(GroupName="Parameters",  Order=2,   Name="My Text Position")]
public TextPosition myPosit

As you see, this property will be included in NT platform as an input for that indicator, and after compiling it as DLL, the TextPosition namespace becomes lost. So, 2 possible solutions:
1) just remove the [NinjaScriptProperty] and try to export that then!
2) Try to qualify it with full name: NinjaTrader.NinjaScript.DrawingTools.TextPosition 

p.s. If you really need to include that property as input, then you should better to create a string property instead, and then in the Configure state, convert it to private enum field (with Enum.Parse or manually).

Leave a Reply

Your email address will not be published.