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

The name '_indicator' does not exist in the current context

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

    The name '_indicator' does not exist in the current context

    Hello

    Code:
    namespace NinjaTrader.Strategy
    {
        public partial class Strategy : StrategyBase
        {
            [Gui.Design.WizardCondition("Indicator")]
            public Indicator.MyIndicator MyIndicator()
            {
                return _indicator.MyIndicator(Input);
            }
    ...
    what is _indicator variable?
    I do my project in VisualStudio as dll file and get compiler error
    The name '_indicator' does not exist in the current context

    Is any other way to list custom indicator in startegy wizard condition window?

    #2
    Hello,

    Thank you for the question.

    I wanted to check, are you getting the error in NinjaTraders NinjaScript editor or in Visual studio?

    Visual studio should not be used to compile as it will not generate the NinjaScript generated code.

    _indicator is a inherited variable from StrategyBase and is generated in Indicators automatically to assists with how you call indicators from a strategy.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I code, compile and debug in VisualStudio only.
      I copied Ninja generated code to my project. But VS compiler throws this error. So the compiler cant find _indicator property in StrategyBase class.
      Perhaps i have to add some external assemblies to my project? Now i link my project only with NinjaTrader.Core.dll and all work fine besides strategies.

      Comment


        #4
        Hello,

        The process you are describing would not be supported.

        Both NT7 and NT8 require that you compile from inside the platform for the correct code to be generated. Using only visual studio will lead to errors like this. Visual studio can be used as a Syntax aid with its intellesense but NinjaTrader internally compiles and handles all of the custom Types, so a compile from the platform would be required especially for indicators.

        I would suggest to make edits in Visual studio, and the Compile from NinjaTrader to check for errors, you can then change code as needed to resolve errors. Copying the generated code from other files or manually creating this would not be the same as allowing the platform to detect the needed code for each specific object and generate it.

        Please try compiling and correcting the error from the NinjaScript editor instead, if you need to you can completely remove the files you have added to return to a compiled state. From there you could work forward slowly to find the specific portion of your logic that is causing the problem.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Your idea is not a solution for me.

          I cant find _indicator property in StartegyBase class in Net.Reflector, and VS compiler too.
          So I suppose this is compiler preprocessor macro.
          Just want to know what is behind it to reproduce _indicator in VS.

          I can add .cs file to distribution package but dont want user will install my indicators as custom assembly because of there are some other staff like User guide and chart templates in the package.

          Comment


            #6
            Hello,

            Unfortunately because you are using an unsupported/ undocumented process I could not assist with the question as I do not have that information. The variable would be used in the wrapper code as needed by the compiler, there is no guide for this region of code as it is generated automatically and is not meant to be edited.

            You would need to either use the supported processes for compiling and exporting in the platform, otherwise you would likely need to come up with a solution to this yourself if it is possible as there is no documentation on what you are trying to do.

            When using Visual Studio you can:
            Utilize the NinjaTrader.Custom.csproj file with Visual studio to load the custom project
            Utilize Intellesense for coding in Visual Studio
            Save documents in Visual Studio and then go back into NinjaTrader to complete the compile.

            That would be the only supported use with Visual studio. NT8 has also adopted this process although it automatically compiles on file changes now to make it easier.

            The internal compile is needed to both generate the wrapper code for indicators and also load the custom assembly into memory. This ensures the code you will export would be able to both be Exported and Imported again on another machine. NinjaTrader also provides means to export as a protected compiled assembly using cli-secure/agile.net. http://ninjatrader.com/support/helpG...l_security.htm

            Using any other process to export, obfuscate or protect the code will likely result in a non usable dll file that NinjaTrader can not load. The export process is very specific within the platform so most third party tools would not be useful in this way.

            Please let me know if I may be of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Think I will add dummy interface indicators in .cs files to be visible by strategy wizard.
              Thanks.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by rtwave, 04-12-2024, 09:30 AM
              2 responses
              20 views
              0 likes
              Last Post rtwave
              by rtwave
               
              Started by tsantospinto, 04-12-2024, 07:04 PM
              5 responses
              68 views
              0 likes
              Last Post tsantospinto  
              Started by cre8able, Today, 03:20 PM
              0 responses
              7 views
              0 likes
              Last Post cre8able  
              Started by Fran888, 02-16-2024, 10:48 AM
              3 responses
              49 views
              0 likes
              Last Post Sam2515
              by Sam2515
               
              Started by martin70, 03-24-2023, 04:58 AM
              15 responses
              115 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X