I have an indicator that uses Draw.Text to print a value next to the close of the price bar. The indicator works just fine but I run into trouble when I use the Export as Compiled Assembly.
First, the compiled assembly could not be imported. I got the message "Error compiling import assembly: c:\Users\Will\Documents\NinjaTrader 8\bin\Custom\ChangeFontB.cs(35,34) : error CS0246: The type or namespace name 'SimpleFont' could not be found (are you missing a using directive or an assembly reference?)".
I figured out how to work around this issue by changing all references to SimpleFont in the source code to the fully qualified NinjaTrader.Gui.Tools.SimpleFont. This included changing it the region "NinjaScript generated code. Neither change nor remove".
Second, once I imported the compiled assembly everything worked fine until I opened the Properties window for a drawing object. When I did that the Draw.Text froze. To unfreeze it I opened and closed the Indicators window on the chart. This only happens with the compiled version, not the source version. I haven't figured out how to fix this.
To replicate the two problems:
- Import SampleChangeFont from this post: http://ninjatrader.com/support/forum...ad.php?t=19170
- Use Export as Compiled Assembly to create a compiled version. Remove the original source version of the indicator.
- Attempt to import the compiled assembly. The import will fail.
- Go back to the original SampleChangeFont and make sure SimpleFont is fully qualified as NinjaTrader.Gui.Tools.SimpleFont everywhere in the code, including the NinjaScript generated code region.
- Use Export as Compiled Assembly again. Remove the original source version.
- Import the compiled assembly. This time it will work.
Now for the second problem:
- Add the compiled SampleChangeFont to the chart (not the source version).
- Add a horizontal line.
- Open the Properties window for the horizontal line. Note how the indicator freezes and no longer updates. This is most easily seen if you set it to update on each tick.
- Now open the Indicators window and close it. The indicator resumes normal functioning.
As I said, this freezing problem only happens with the compiled assembly, not the source code version of the indicator.
I suspect both problems have something to do with the compiler but don't know for sure. If there's a solution to the freezing Draw.Text please let me know.
Thanks and regards,
Will.
Comment