Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Visual Studio dll referencing NT7 Indicators

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

    Visual Studio dll referencing NT7 Indicators

    I'm in the process of packing my custom indicators into an external dll using Visual Studio. I've gotten a few methods to work with help from this site (much appreciated) but I can't seem to make a call to any NT7 indicators. For example, the line...
    Code:
    double avg = SMA(Input, 10)[barsBack];
    gives me the error Error NinjaTrader.Indicator.SMA is a 'type' but is used like a 'variable'
    Does anyone have a clue as to what my problem is? Thanks in advance .

    #2
    Originally posted by thekreme View Post
    I'm in the process of packing my custom indicators into an external dll using Visual Studio. I've gotten a few methods to work with help from this site (much appreciated) but I can't seem to make a call to any NT7 indicators. For example, the line...
    Code:
    double avg = SMA(Input, 10)[barsBack];
    gives me the error Error NinjaTrader.Indicator.SMA is a 'type' but is used like a 'variable'
    Does anyone have a clue as to what my problem is? Thanks in advance .
    You must specify the Input.

    Comment


      #3
      Hello thekreme,

      Thank you for your post.

      If you define the Input as koganam suggested or remove Input so it just states double avg = SMA(10)[barsBack]; do you still see the same error?

      Comment


        #4
        Input is given in the function call.

        Code:
        /// <summary>
        /// Given: barsBack is the start of the first signal. support is the price level of the potential support
        /// Returns: -1 from below, 1 from above, 0 otherwise
        /// </summary>
        /// <param name="barsBack"></param>
        /// <param name="support"></param>
        /// <returns></returns>
        public int IntoSupport(int barsBack, double support, NinjaTrader.Data.IDataSeries Input) {
             i = new NinjaTrader.Indicator.SMA();
        
             double avg = i.SMA(Input, 10)[barsBack];
             if (avg < support) return -1;
             if (avg > support) return 1;
             else return 0; }

        Comment


          #5
          Originally posted by thekreme View Post
          Input is given in the function call.

          Code:
          /// <summary>
          /// Given: barsBack is the start of the first signal. support is the price level of the potential support
          /// Returns: -1 from below, 1 from above, 0 otherwise
          /// </summary>
          /// <param name="barsBack"></param>
          /// <param name="support"></param>
          /// <returns></returns>
          public int IntoSupport(int barsBack, double support, NinjaTrader.Data.IDataSeries Input) {
               i = new NinjaTrader.Indicator.SMA();
          
               double avg = i.SMA(Input, 10)[barsBack];
               if (avg < support) return -1;
               if (avg > support) return 1;
               else return 0; }
          That syntax is not what you posted the first time out.
          Code:
          double avg = [COLOR="Blue"][B]i[/B][/COLOR].SMA(Input, 10)[barsBack]; //emphasis mine in [COLOR="blue"]blue[/COLOR]
          is not the same as what you first asked about.
          Code:
          double avg = SMA(Input, 10)[barsBack];
          You have defined "i", as an SMA object. An SMA object does not have an SMA member.

          Try this instead:
          Code:
            [COLOR="Blue"]SMA   i = SMA(Input, 10);[/COLOR] //create your object using the method that NT creates when it compiles an indicator.
          
               double avg = i[barsBack]; //get at the index directly in the existing SMA object.
              [COLOR="blue"] i.Dispose();[/COLOR] //get rid of objects that are no longer referenced.
               if (avg < support) return -1;
               if (avg > support) return 1;
               else return 0; }
          Last edited by koganam; 06-17-2015, 07:30 AM.

          Comment


            #6
            Thanks for the idea, koganam, but it still didn't work. I'm just going to toss this particular function aside and continue with the others that don't use NT indicators. Thanks for looking at this, though.

            Cheers

            Comment


              #7
              Originally posted by thekreme View Post
              Thanks for the idea, koganam, but it still didn't work. I'm just going to toss this particular function aside and continue with the others that don't use NT indicators. Thanks for looking at this, though.

              Cheers
              What was the error?

              Comment


                #8
                'NinjaTrader.Indicator.SMA' is a 'type' but is used like a 'variable'
                I wonder if I'm not including the right NT dll's in the doc. Currently I have:
                Code:
                using NinjaTrader.Data;
                using NinjaTrader.Cbi;
                using NinjaTrader.Indicator;
                and am referencing nt.Core, nt.Custom and WilsonORMapper.

                Comment


                  #9
                  Originally posted by thekreme View Post
                  I wonder if I'm not including the right NT dll's in the doc. Currently I have:
                  Code:
                  using NinjaTrader.Data;
                  using NinjaTrader.Cbi;
                  using NinjaTrader.Indicator;
                  and am referencing nt.Core, nt.Custom and WilsonORMapper.
                  I think the problem is in your calling signature. You are using a Type instead of a variable of the type. Try this, and if it still fails, I will have to throw it onto my own system after market close. This looks simple enough that we should be able to either do it, or explain why not.
                  Code:
                  public int IntoSupport(int barsBack, double support, NinjaTrader.Data.IDataSeries input) {
                  SMA   i = SMA(input, 10); //create your object using the method that NT creates when it compiles an indicator.
                  
                       double avg = i[barsBack]; //get at the index directly in the existing SMA object.
                       i.Dispose(); //get rid of objects that are no longer referenced.
                       if (avg < support) return -1;
                       if (avg > support) return 1;
                       else return 0; }
                  Note the change in case for input to turn it into a variable, rather than the Input that is defined by the IndicatorBase.

                  Comment


                    #10
                    Same error as before,
                    'NinjaTrader.Indicator.SMA' is a 'type' but is used like a 'variable'
                    Good idea, though.

                    Comment


                      #11
                      Originally posted by thekreme View Post
                      Same error as before,
                      Good idea, though.
                      You have a different problem., I just cut-and-paste the code into a test indicator, and it compiled with no issue.

                      Edit: Actually it compiles even when I change to the original code that used Input instead of input. Which of course means that my thesis about the calling signature was wrong.
                      Last edited by koganam; 06-18-2015, 02:09 PM.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by DeskTroll, Today, 12:09 PM
                      3 responses
                      23 views
                      0 likes
                      Last Post NinjaTrader_LuisH  
                      Started by Pabulon, 12-02-2024, 03:42 PM
                      14 responses
                      90 views
                      0 likes
                      Last Post Pabulon
                      by Pabulon
                       
                      Started by tfa2806trader, Today, 12:04 PM
                      10 responses
                      25 views
                      0 likes
                      Last Post tfa2806trader  
                      Started by trdninstyle, 11-26-2024, 12:23 PM
                      62 responses
                      186 views
                      0 likes
                      Last Post trdninstyle  
                      Started by lorien, 08-08-2021, 07:33 AM
                      12 responses
                      722 views
                      0 likes
                      Last Post AndyM871  
                      Working...
                      X