[Solution] NinjaTrader Export Fails (Error compiling export sources)

Solution to NinjaTrader Export Failure

(applies to NT 7/8)

I’ve met a strange and interesting thing about NinjaTrader Export tool…  Most of you, who is familiar with NT7/NT8, probably met the ever-green problem while trying to export indicators/strategies, you might seen an error message Error compiling export sources. Please check your logs.

And in logs, you may have seen such error messages:

NinjaTrader.Indicator.Indicator does not contain a definition for ... NinjaTrader.Staretegy.Strategy does not contain a definition for...

 

Inconvenience caused by the error

Well, to “solve” the problem, you probably manually add those mentioned scripts (like SMA, MAX, MIN, RANGE ) in the export list, and exporting succeeds. But what about other people, whom you send the script, and explaining them about “do this or that…”? It’s very inconvenient I think.

The problem seems to lie in the coding-manner. Let’s say, you are trying to export “MyIndi” indicator (which causes the error). Probably it uses the above-mentioned scripts/indicators in this manner:

...
base.MIN(...);
...
base.SMA(...);
...

So, compiler seems to confuse when using them as a reference.

Solution to “AUTO-INCLUDE” all those required indicators (without a need to manually add them by hand into “EXPORT” window), is to mention those Indicator-Types anywhere in your indicator like:

public class MyIndi { 

    private Ninjatrader.Indicator.Indicator Max; 
    private Ninjatrader.Indicator.Indicator Min; 
    private Ninjatrader.Indicator.Indicator Range; 
    ..... 
}

And then, while trying to export your indi, you will no longer fail, instead, you will get “Auto-Include” question dialog:

BUT there remains one strange thing. It didnt work for SMA. Even if I declare SMA in my indi, I still get the export error, and I have to MANUALLY ADD that in the export list. I havent tested other indicators, probably there are other few exceptions.  If anyone knows a workaround, feel free to suggest.

2 thoughts on “[Solution] NinjaTrader Export Fails (Error compiling export sources)

  1. Perhaps this is a side-effect of using the “base.” prefix in a promiscuous manner?

    I don’t use the “base.” prefix unless it is truly necessary to resolve an ambiguity.

    1. I’ve had occasions when it does similar without any mention to “base”. For example, put “X” indicator under folder, and try to export other Y indicator which uses “X”. you will get warning.

Leave a Reply

Your email address will not be published. Required fields are marked *