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

Can't reference public dataseries...

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

    Can't reference public dataseries...

    in one indicator I have the following in "properties":
    Code:
            [Browsable(false)]
            [XmlIgnore()]
            public DataSeries BB_UpperBand
            {
                get { return Values[0]; }
            }
            
            /// <summary>
            /// </summary>
            [Browsable(false)]
            [XmlIgnore()]
            public DataSeries BB_LowerBand
            {
                get { return Values[1]; }
            }
    In another indicator I am trying to reference those dataseries like this:
    Code:
    if (macdFlag[0] == false && CrossAbove(MACDBBLines().Value, MACDBBLines().BB_LowerBand,1))
                {    
                    macdFlag[0] = true;
                }
                
                if (macdFlag[0] == true && CrossAbove(MACDBBLines().Value, MACDBBLines().BB_UpperBand,1))
                {
                        if (Low[16] <= ((CurrentPeakHigh - CurrentPeakLow) * .382) + CurrentPeakLow)
                        {
                            CurrentPeakLow = (Low[16]);
                        }
                        macdFlag[0] = false;
                }
    I get the compile error 'NinjaTrader.indicator.MACDBBLines does not contain a definition for 'BB_LowerBand''

    Should I not be able to access this?

    #2
    Hello Sleeping Troll,

    Thank you for your post.

    You need to verify that you've "Set" these values somewhere in your MACDBBLines indicator.

    BB_LowerBand.Set(yourIndicatorCalculationsHere);

    You'll also have to check the Initialize() method to verify you have added at least two plots for this indicator.

    If you continue to have issues, make sure you've compiled NinjaScript and reply with some more of the code used for MACDBBLines.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thx Ryan! Will do.

      (From MACDBBLines)

      Code:
      protected override void Initialize()
              {    
                  Add(new Plot(new Pen(Color.Red, 1), "BB_UpperBand"));
                  Add(new Plot(new Pen(Color.Blue, 1), "BB_LowerBand"));
                  Add(new Plot(new Pen(Color.DarkGray, 1), "BB_MiddleBand"));
                  
                  bbMacd    = new DataSeries(this);
                  dotSeries = new DataSeries(this);
                  
                  DrawOnPricePanel=false;
      
              }
      Code:
              protected override void OnBarUpdate()
              {
                  bbMacd.Set(MACD(Input, fast, slow, smooth)[0]);
                      
                  Avg = EMA(bbMacd,bandPeriod)[0];
                  double SDev = StdDev(bbMacd,bandPeriod)[0];    
                  double upperBand=Avg+(stDv*SDev);
                  double lowerBand=Avg-(stDv*SDev);
                  
                  BB_UpperBand.Set(upperBand);
                  BB_LowerBand.Set(lowerBand);
                  BB_MiddleBand.Set(Avg);
                  dotSeries.Set(bbMacd[0]);
                  currentBar=CurrentBar;
              }
      Last edited by Sleeping Troll; 04-05-2010, 10:55 AM.

      Comment


        #4
        Sleeping Troll,

        Hm. Let us test this first then. Can you please comment out the references to MACDBBLines you have in your other indicator. Then try to compile MACDBBLines and see if you run into compile errors?
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Just did that and it compiles fine, I thought maybe some sort of circular reference, but no joy. Even after it has compiled with the DataSeries in place if I uncomment the references, same error.

          Comment


            #6
            I found the problem, find and replace has gotten me into some trouble, I mistakenly compiled MACDBBLines as BegyHunniewellPeaks...

            Now when I change it back I get errorNJ namespace already contains MACDBBLines, what is the easiest way to fix this?

            Also have you considered calling assemblies instead of compiling them into NJ for NJ7?

            Comment


              #7
              Probably the easiest way is to delete the indicator using Tools > Edit NinjaScript > Indicator.

              Highlight the indicator and click delete. If there are references to this indicator in others, those references will have to commented out.

              Then, recreate the indicator from scratch.

              Could you clarify what you mean by "calling assemblies instead of compiling them into NJ for NJ7?"
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Gladly! As I understand it, indicators and strategies are compiled into NinjaTrader, hence problems like I just experienced with the indicator already present in the NinjaTrader namespace, not to mention that now indicators and strategies that are not currently in use are executing regardless. Would it not be better to compile the indicators and strategies as dll's and load them when called for?

                Comment


                  #9
                  You can package your NinjaScript indicators into dlls using File > Export NinjaScript indicator. Select the option, "Export compiled assembly of selected source files".

                  Our development environment won't create dlls by default but you can develop outside of NinjaTrader and add references to dlls created.

                  To add references to custom dlls, right click within the editor and select references, then add.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    OK, thx, I will review this later when my brain is not drowning in digital macaroni!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by jaybedreamin, Today, 05:56 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post jaybedreamin  
                    Started by DJ888, 04-16-2024, 06:09 PM
                    6 responses
                    18 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by Jon17, Today, 04:33 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post Jon17
                    by Jon17
                     
                    Started by Javierw.ok, Today, 04:12 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post Javierw.ok  
                    Started by timmbbo, Today, 08:59 AM
                    2 responses
                    10 views
                    0 likes
                    Last Post bltdavid  
                    Working...
                    X