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 'Macd' does not exist in the current context

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

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

    Hello,
    if i try to compile this indicator i've the above error message.
    And can't find what happen exactly.
    See attached
    Attached Files

    #2
    mate41,

    The error that is showing up is located in the TrenDotMacd.cs file not the one you posted the code to. When the compile error shows as orange it means it's located in a different file than the one you're compiling. you can double click the error and it will open the file with the error and take you to the part of the code with the error. If you can't find the error, then post the code from that file and I or someone else I'm sure can help you.

    VT
    Last edited by VTtrader; 11-06-2011, 12:24 PM.

    Comment


      #3
      Thanks for the reply VTtrader,
      i recompiled without any change and the compile errors are no more orange; white only.
      Double clickking the error conduct me to the line where the error occurs.
      You can see a part of the code i've attached on my first post.
      I think it has todo with these lines:
      private int fast = 12; // Default setting for Fast
      private int slow = 26; // Default setting for Slow
      private int smooth = 1; // Default setting for Smooth
      trMacd = new DataSeries(this);
      trMacd.Set(MACD(Input, fast, slow, smooth)[0]);
      Macd.Set(trMacd[0]);

      Comment


        #4
        Mate41,

        Was the error the same, "The name 'Macd' does not exist in the current context "? it looks like you may have several issues going on.

        Both "trMACD" and "Macd" are being used as DataSeries, they need to be declared in the variables region, and instantiated in the Inititialize() method.

        In the variables you need:
        private DataSeries trMacd;
        private DataSeries Macd;

        in the Initialize() method you will need:
        trMacd = new DataSeries(this);
        Macd = new DataSeries(this);

        Both of those have to be in place first, then in OnBarUpdate() you can call the Set method:
        trMacd.Set(MACD(Input, fast, slow, smooth)[0]);
        Macd.Set(trMacd[0]);

        VT

        Comment


          #5
          Thanks for your time VTtrader,
          it's SOLVED. Your post made ​​me a light !!
          I did it as follows:

          In the variables i need:
          private DataSeries trMacd; // was already done

          In the 'initialize' i need:
          trMacd = new DataSeries(this); // was already done

          In the 'protected override void OnBarUpdate()' i need:
          trMacd.Set(MACD(Input, fast, slow, smooth)[0]); // was already done
          Macd.Set(trMacd[0]); // was already done too

          And here comes the solution :
          adding under 'Properties':
          [Browsable(false)]
          [XmlIgnore()]
          public DataSeries Macd
          {
          get { return Values[0]; }
          }
          If this can help someone.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by lorem, Today, 09:18 AM
          0 responses
          2 views
          0 likes
          Last Post lorem
          by lorem
           
          Started by hazylizard, Today, 08:38 AM
          4 responses
          11 views
          0 likes
          Last Post hazylizard  
          Started by geddyisodin, Today, 05:20 AM
          2 responses
          18 views
          0 likes
          Last Post geddyisodin  
          Started by Max238, Today, 01:28 AM
          5 responses
          47 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by giulyko00, Yesterday, 12:03 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X