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 Spiderbird, 07-27-2018, 07:52 PM
                      12 responses
                      9,240 views
                      2 likes
                      Last Post Mountain_cast  
                      Started by chrischongpdx, Today, 09:39 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post chrischongpdx  
                      Started by Mountain_cast, Today, 12:41 PM
                      2 responses
                      10 views
                      0 likes
                      Last Post Mountain_cast  
                      Started by dontpanic, 04-07-2015, 04:42 AM
                      4 responses
                      1,322 views
                      0 likes
                      Last Post BeachTrader11807  
                      Started by algospoke, Today, 07:54 PM
                      0 responses
                      5 views
                      0 likes
                      Last Post algospoke  
                      Working...
                      X