Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Problem exporting/importing a custom indicator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem exporting/importing a custom indicator

    I can't see this problem mentioned anywhere else, so I'll start from the beginning.

    I am currently using NT7.0.1000.10, because I read the warning about Interactive Brokers.

    I have created a custom indicator. It's very simple, just a modification of StdDev that divides by n-1 instead of n. I use it in a custom strategy. Everything works fine on my development machine that has access to all the source.

    I export the strategy as a compiled assembly, which forces the inclusion of my custom indicator. I import the assembly on another machine, which doesn't possess all the source code. This all works fine.

    Then I run a backtest on the second machine, which appears to work OK but a message appears telling me words to the effect of:

    "Unable to create instance of indicator 'NinjaTrader.Indicator.SMA'. Most likely the implementation no longer exists, or there is no default constructor defined, or the default constructor does not work correctly: System.TypeInitializationException: The type initializer for 'NinjaTrader.Indicator.Indicator' threw an exception. ---> System.TypeLoadException: Could not load type 'NinjaTrader.Indicator.GuruStdDev' from assembly 'GuruTrader, Version=1.0.0.4,"

    1. Can anyone suggest what's going wrong?

    2. The exported ZIP file includes the source for my custom indicator. Whilst this is a not a problem in this case, it might be in the future should I develop a particularly cunning custom indicator. Is there any way around this potential problem?

    #2
    Hello SoulSurfer,

    The current version of NinjaTrader and Traders Workstation supported together is NinjaTrader 7.0.1000.11 and Traders Workstation 927.7.

    1. Do you have any custom assemblies installed on the machine that you exported this as? Also, what version of NinjaTrader do you have installed when you exported this and what version of NinjaTrader do you have installed on the other computer?

    2. Exporting as an assembly they will not have access to your source code. If you are worried about the security of your Assembly files you may add a higher level of protection by Protecting your compiled assemblies by using CLi Secure/Agile.NET's protection method. You may see the following link to our help guide for more information about it.


    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Hi JC,

      Originally posted by NinjaTrader_JC View Post
      The current version of NinjaTrader and Traders Workstation supported together is NinjaTrader 7.0.1000.11 and Traders Workstation 927.7.
      0. So the warning I read about not using .11 with IB has been superceded? Would the version make any difference to this problem?

      1. Do you have any custom assemblies installed on the machine that you exported this as? Also, what version of NinjaTrader do you have installed when you exported this and what version of NinjaTrader do you have installed on the other computer?
      1. I haven't any NinjaScript assemblies imported on the development machine, although I do reference stuff like QuickFIX. Both machines have .10 installed

      2. Exporting as an assembly they will not have access to your source code.
      2. That was my point. They do! The exported ZIP includes my custom source code for the indicator, but not for the strategy.

      If you are worried about the security of your Assembly files you may add a higher level of protection by Protecting your compiled assemblies by using CLi Secure/Agile.NET's protection method.
      3. I tried filling in the CliSecure application form months ago, but I haven't received any response yet. [Edit - Actually on carefully checking my inbox that's not true - After 3 days they assured me their web site was working correctly. It seems to be working correctly now too!]
      Last edited by SoulSurfer; 01-30-2013, 09:40 AM.

      Comment


        #4
        Hello SoulSurfer,

        0. Yes, you may see an updated release about this at the following link.


        1. Can you send a toy* NinjaScript code replicating the behavior so that I may look into this by emailing it to Support [AT] NinjaTrader [DOT] com. Please put ATTN: JC and reference this thread in the subject line or body.

        *Toy - basically a stripped down version of code that isn't necessarily the whole logic; making it easier to identify lines of code.

        2. Please look at the ".cs" file that your exported assembly created and compare it to the NinjaScript Indicator that you have created. NinjaTrader will generate code so that it can be used properly but the code generated is only for running the NinjaScript files not the actual logic.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi JC,

          Originally posted by NinjaTrader_JC View Post
          1. Can you send a toy* NinjaScript code replicating the behavior so that I may look into this by emailing it to Support [AT] NinjaTrader [DOT] com. Please put ATTN: JC and reference this thread in the subject line or body.
          I've tried creating a stripped down strategy that still uses the custom indicator in the same manner. Unfortunately it produces no strange error messages. Further work will have to wait until tomorrow, since it's now getting late over here in the UK. Do you have any other suggestions? Would you like to see my logs for example?

          2. Please look at the ".cs" file that your exported assembly created and compare it to the NinjaScript Indicator that you have created. NinjaTrader will generate code so that it can be used properly but the code generated is only for running the NinjaScript files not the actual logic.
          I see what you mean. My mistake! Remind me to read autogenerated source files more carefully in future.

          Jim

          Comment


            #6
            Some additional information. If I run a backtest with the "Summary" tab selected, I don't see the error. Then whenever I switch from the summary tab to another tab the error message pops up.

            Restarting NinjaTrader after importing the compiled strategy/indicator seems to eliminate the problem also.

            Comment


              #7
              Hello SouldSurfer,

              The Logs of the machine that the assembly was imported on would not have much information to be able to pin point anything, but I am glad to hear that is is resolved. You may also want to uninstall NinjaTrader and upgrade to the latest version as well.

              Let us know if we can be of further assistance.
              JCNinjaTrader Customer Service

              Comment


                #8
                Hi JC,

                Well, I wouldn't go so far as to say it is resolved to my complete satisfaction. It would be nice to know the reason the error message is displayed in the first place for example, and why a restart seems to "fix" it. Are there any other potentially similar problems that go away after a restart?

                Just in case it's of interest, the log is full of lots of stuff like this:

                30/01/2013 13:50:46|3|4|Unable to create instance of 'NinjaTrader.Strategy.SampleAtmStrategy'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Exception has been thrown by the target of an invocation.
                30/01/2013 13:50:46|3|4|Unable to create instance of 'NinjaTrader.Strategy.SampleMACrossOver'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Exception has been thrown by the target of an invocation.
                30/01/2013 13:50:46|3|4|Unable to create instance of 'NinjaTrader.Strategy.SampleMultiInstrument'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Exception has been thrown by the target of an invocation.
                30/01/2013 13:50:46|3|4|Unable to create instance of 'NinjaTrader.Strategy.SampleMultiTimeFrame'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Exception has been thrown by the target of an invocation.
                30/01/2013 13:50:46|3|4|Unable to create instance of 'NinjaTrader.Strategy.RayRobot2'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Exception has been thrown by the target of an invocation.
                30/01/2013 13:51:30|0|4|Unable to create instance of indicator 'NinjaTrader.Indicator.SMA'. Most likely the implementation no longer exists, or there is no default constructor defined, or the default constructor does not work correctly: System.TypeInitializationException: The type initializer for 'NinjaTrader.Indicator.Indicator' threw an exception. ---> System.TypeLoadException: Could not load type 'NinjaTrader.Indicator.GuruStdDev' from assembly 'GuruTrader, Version=1.0.0.4, Culture=neutral, PublicKeyToken=null'.
                at NinjaTrader.Indicator.Indicator..cctor()
                --- End of inner exception stack trace ---
                at NinjaTrader.Indicator.Indicator..ctor()
                at NinjaTrader.Indicator.SMA..ctor()

                Why should whatever triggers that lot be invoked by switching tabs in the Strategy Analyzer?

                I'll certainly experiment with .11 in the near future.

                Jim

                Comment


                  #9
                  Hello Jim,

                  When you bring up a tab that uses NinjaScript items it will invoke the Intialize() of all NinjaScript items so that you can access them which is why those error came up inside of your Log tab. As to why you are getting those error(s) it can sometimes be related to a corrupt workspace or file inside of NinjaTrader. In the case of a file being corrupt inside of NinjaTrader uninstalling and reinstalling generally fixes this and it will not remove any of your settings/data inside of NinjaTrader.

                  Let us know if you see continued behavior like this after installing .11.
                  JCNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by SoulSurfer View Post
                    Hi JC,

                    Well, I wouldn't go so far as to say it is resolved to my complete satisfaction. It would be nice to know the reason the error message is displayed in the first place for example, and why a restart seems to "fix" it. Are there any other potentially similar problems that go away after a restart?

                    Just in case it's of interest, the log is full of lots of stuff like this:

                    30/01/2013 13:50:46|3|4|Unable to create instance of 'NinjaTrader.Strategy.SampleAtmStrategy'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Exception has been thrown by the target of an invocation.
                    30/01/2013 13:50:46|3|4|Unable to create instance of 'NinjaTrader.Strategy.SampleMACrossOver'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Exception has been thrown by the target of an invocation.
                    30/01/2013 13:50:46|3|4|Unable to create instance of 'NinjaTrader.Strategy.SampleMultiInstrument'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Exception has been thrown by the target of an invocation.
                    30/01/2013 13:50:46|3|4|Unable to create instance of 'NinjaTrader.Strategy.SampleMultiTimeFrame'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Exception has been thrown by the target of an invocation.
                    30/01/2013 13:50:46|3|4|Unable to create instance of 'NinjaTrader.Strategy.RayRobot2'. Most likely there is no default constructor defined, or the default constructor does not work correctly: Exception has been thrown by the target of an invocation.
                    30/01/2013 13:51:30|0|4|Unable to create instance of indicator 'NinjaTrader.Indicator.SMA'. Most likely the implementation no longer exists, or there is no default constructor defined, or the default constructor does not work correctly: System.TypeInitializationException: The type initializer for 'NinjaTrader.Indicator.Indicator' threw an exception. ---> System.TypeLoadException: Could not load type 'NinjaTrader.Indicator.GuruStdDev' from assembly 'GuruTrader, Version=1.0.0.4, Culture=neutral, PublicKeyToken=null'.
                    at NinjaTrader.Indicator.Indicator..cctor()
                    --- End of inner exception stack trace ---
                    at NinjaTrader.Indicator.Indicator..ctor()
                    at NinjaTrader.Indicator.SMA..ctor()

                    Why should whatever triggers that lot be invoked by switching tabs in the Strategy Analyzer?

                    I'll certainly experiment with .11 in the near future.

                    Jim
                    A lot of those that NT is complaining about are default shipping NT indicators. Indications are, therefore, that you have a corrupt installation. The first thing that I would try would be to repair the installation. Just try to install again, and you will have that option to select.

                    Comment


                      #11
                      Hi koganam,

                      Originally posted by koganam View Post
                      A lot of those that NT is complaining about are default shipping NT indicators. Indications are, therefore, that you have a corrupt installation. The first thing that I would try would be to repair the installation. Just try to install again, and you will have that option to select.
                      Thanks very much for that suggestion, which has solved my immeditae problem, but begs a few questions nonetheless. Firstly I "repaired" the target, but the problem remained. Then I "repaired" my development system, and lo and behold the problem seems to have vanished! This is still on .10 BTW.

                      The next obvious question is how can an NT installation become "corrupt"?

                      @JC - Why does flipping between the "Summary" tab and the "Trades" tab, merely different representations of the results of a backtest, require initializing every strategy and indicator?

                      Cheers,

                      Jim

                      Comment


                        #12
                        Hello Jim,

                        It would be hard to pin-point how exactly it happened but here are a few examples: NinjaTrader still running while updating/reinstalling, File monitoring program reverting files to different states, importing NinjaScript files with older version of system indicators, etc... this does not happened often but doing this or uninstalling and reinstalling will not effect your data.

                        The Summary and Trades tab should not invoke the Initialize() method, only items that would have a Strategy or Indicator as a selectable option for example opening up the Backtest, Optimizer, and Walk Forward Optimization tab to the far right. The reason for this is to be able to get the list of NinjaScript items.
                        JCNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by inanazsocial, Today, 01:15 AM
                        1 response
                        5 views
                        0 likes
                        Last Post NinjaTrader_Jason  
                        Started by rocketman7, Today, 02:12 AM
                        0 responses
                        10 views
                        0 likes
                        Last Post rocketman7  
                        Started by dustydbayer, Today, 01:59 AM
                        0 responses
                        1 view
                        0 likes
                        Last Post dustydbayer  
                        Started by trilliantrader, 04-18-2024, 08:16 AM
                        5 responses
                        23 views
                        0 likes
                        Last Post trilliantrader  
                        Started by Davidtowleii, Today, 12:15 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post Davidtowleii  
                        Working...
                        X