• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Data Series

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

    Using Data Series

    Currently, I'm working on an indicator that draws lines for me automatically. I am trying to use a DataSeries, to make the data I input in my variables, in other indicators/strategies. Everything looks ok except for the onbarupdate section. I have

    protected override void OnBarUpdate()
    {
    supportandresistance.Set(line01Value);
    if (Line01Value != 0) Line01.Set(Line01Value);
    if (Line02Value != 0) Line02.Set(Line02Value);
    if (Line03Value != 0) Line03.Set(Line03Value);
    if (Line04Value != 0) Line04.Set(Line04Value);
    if (Line05Value != 0) Line05.Set(Line05Value);
    if (Line06Value != 0) Line06.Set(Line06Value);
    if (Line07Value != 0) Line07.Set(Line07Value);
    if (Line08Value != 0) Line08.Set(Line08Value);
    if (Line09Value != 0) Line09.Set(Line09Value);
    if (Line10Value != 0) Line10.Set(Line10Value);
    if (Line11Value != 0) Line11.Set(Line11Value);
    if (Line12Value != 0) Line12.Set(Line12Value);
    if (Line13Value != 0) Line13.Set(Line13Value);
    if (Line14Value != 0) Line14.Set(Line14Value);
    if (Line15Value != 0) Line15.Set(Line15Value);
    if (Line16Value != 0) Line16.Set(Line16Value);
    if (Line17Value != 0) Line17.Set(Line17Value);
    if (Line18Value != 0) Line18.Set(Line18Value);
    if (Line19Value != 0) Line19.Set(Line19Value);
    if (Line20Value != 0) Line20.Set(Line20Value);
    if (Line21Value != 0) Line21.Set(Line21Value);
    if (Line22Value != 0) Line22.Set(Line22Value);
    if (Line23Value != 0) Line23.Set(Line23Value);
    if (Line24Value != 0) Line24.Set(Line24Value);
    if (Line25Value != 0) Line25.Set(Line25Value);

    }
    to set my dataseries, but I'm not exactly sure what goes in the parentheses. I ultimately want all the variables to be included, but am trying with one to begin with to test it out (much simpler). Thanks
    Attached Files

    #2
    Solomon,

    I am not sure what you are trying to do here. Could you clarify for me? I would be happy to help out if I can.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      I'm using Josh's guide as a template, http://www.ninjatrader.com/support/f...ead.php?t=4991 and the dataseries class http://www.ninjatrader.com/support/h...ries_class.htm to try and expose the input values,
      public class ConstantLines60M25 : Indicator
      {
      #region Variables

      // Wizard generated variables
      private double line01Value = 0; // Default setting for Line01Value
      private double line02Value = 0; // Default setting for Line02Value
      private double line03Value = 0; // Default setting for Line03Value
      private double line04Value = 0; // Default setting for Line04Value
      private double line05Value = 0; // Default setting for Line05Value
      private double line06Value = 0; // Default setting for Line06Value
      private double line07Value = 0; // Default setting for Line07Value
      private double line08Value = 0; // Default setting for Line08Value
      private double line09Value = 0; // Default setting for Line09Value
      private double line10Value = 0; // Default setting for Line10Value
      private double line11Value = 0; // Default setting for Line11Value
      private double line12Value = 0; // Default setting for Line12Value
      private double line13Value = 0; // Default setting for Line13Value
      private double line14Value = 0; // Default setting for Line14Value
      private double line15Value = 0; // Default setting for Line15Value
      private double line16Value = 0; // Default setting for Line16Value
      private double line17Value = 0; // Default setting for Line17Value
      private double line18Value = 0; // Default setting for Line18Value
      private double line19Value = 0; // Default setting for Line19Value
      private double line20Value = 0; // Default setting for Line20Value
      private double line21Value = 0; // Default setting for Line21Value
      private double line22Value = 0; // Default setting for Line22Value
      private double line23Value = 0; // Default setting for Line23Value
      private double line24Value = 0; // Default setting for Line24Value
      private double line25Value = 0; // Default setting for Line25Value
      // User defined variables (add any user defined variables below)
      private DataSeries supportandresistance;

      #endregion

      for use in other indicators/strategies... if you need more clarification, let me know thanks

      Comment


        #4
        Solomon,

        I'm not exactly sure what goes in the parentheses
        Which parenthesis are you referring to here?
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          I'm setting the values for the dataseries in the onbarupdate section. So the parantheses I'm referring to are the ones from...

          "supportandresistance.Set(??????);"

          In the boolseries example, Josh just writes true and false.

          " bullIndication.Set(false);
          bearIndication.Set(false);"

          in the dataseries of help, they write

          "myDataSeries.Set(High[0] - Low[0]);"

          So in the parantheses, I want it to be the values from the variables I set for Line1 in the variable section. If you need more clarification on my question, please let me know. Thanks

          Comment


            #6
            Solomon,

            These "LineXX" are already plots so they should be accessible it looks like. What you added is a data series that would accept double values, as such you could use any value, however I wouldn't suggest true/false as it won't work.

            Are you getting any errors when you compile.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              No errors occur when I compile the constantLines60M25 file. It's when I try to add it in the initialize section of a different ninjascript where the error occurs. The errors are
              CS1501 "No overload for method 'ConstantLines60M25' takes '0' arguments"
              CS1502 "The best overloaded method match for 'NinjaTrader.Indicator.IndicatorBase.Add(NinjaTrad er.Gui.Chart.Line)' has some invalid arguments"
              CS1503 "Argument '1': cannot convert from 'NinjaTrader.Indicator.ConstantLines60M25' to 'NinjaTrader.Gui.Chart.Line' "

              Comment


                #8
                Solomon,

                How are you calling this indicator in the other strategy/indicator? Could you show me an example, not from the code you sent below, but from the strategy/indicator producing this error message?
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  "
                  namespace NinjaTrader.Indicator
                  {
                  /// <summary>
                  /// Test
                  /// </summary>
                  [Description("Test")]
                  public class ConstantLinesTest : Indicator
                  {
                  #region Variables
                  // Wizard generated variables
                  // User defined variables (add any user defined variables below)
                  #endregion

                  /// <summary>
                  /// This method is used to configure the indicator and is called once before any bar data is loaded.
                  /// </summary>
                  protected override void Initialize()
                  {
                  Overlay = false;
                  Add(ConstantLines60M25());
                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                  // Use this method for calculating your indicator values. Assign a value to each
                  // plot below by replacing 'Close[0]' with your own formula.
                  }

                  #region Properties
                  #endregion
                  }
                  }
                  "
                  Also, I was just reading this thread (http://www.ninjatrader.com/support/f...blic+variables) before you replied, and if you read Konagrams comment on the second post, he states that the OP should name all the parameters, or else it won't compile. So maybe I'll try adding something like...

                  Add(ConstantLines60M25(ALL Parameters));
                  and see if it compiles?

                  Comment


                    #10
                    Solomon,

                    Yes, please try this. You can also use intellisense in the NinjaScript editor. For example :

                    If you type out RSI( you will see the various inputs it expects and can hit the arrow keys up/down to see various other overrides. The overrides are other ways you can call the indicator/method/etc.

                    Please let me know if I may assist further.
                    Adam P.NinjaTrader Customer Service

                    Comment


                      #11
                      Hey Adam,

                      I'm having trouble entering all the parameters. Could you please send me an example? Thank you

                      Comment


                        #12
                        Solomon,

                        You are using so many linevalues here that its going to be difficult. I wouldn't recommend that you use 25 inputs as you have.

                        It would be something like this :

                        ConstanLines60M25(Line1Value, Line2Value, Line3Value, ........... so on ..... , Line24Value, Line25Value);
                        Adam P.NinjaTrader Customer Service

                        Comment


                          #13
                          oh... ok I was using the intellesense which was stating to input the lower case one, which I did, and then the error told me to add an identifier, so I added double, and it still didn't work...

                          Now that I use the capital Line##Value for the parameters, that error has stopped, but now the compiling error is

                          CS0103
                          The name 'Line##Value' does not exist in the current context

                          Note the error is occuring 25 times, once for each parameter input.

                          I'm going to try to declare each parameter as dbl with the uppercase version and see if that works. In the meantine, do you have any suggestions?

                          Comment


                            #14
                            Hey, adam, I can get it to compile when I use

                            Add(ConstantLines(0,0,0,0));


                            in the initialize section, (I'm working with the standard builtin constant lines for simplicity, once I get it to work, I'll carry it over to the more complex one with 25 lines), but when I try to get my values on the OnBarUpdate() section, they seem to be locked at 0,0,0,0, for the 4 lines. I understand why it's locked when I test it out, because they're all at 0,0,0,0, but I can't find any other way to compile it.

                            protected override void OnBarUpdate()
                            {
                            if (Close[0] > ConstantLines(0,0,0,0).Line1[0])
                            {
                            BackColor = Color.DarkGreen;
                            }

                            if (Close[0] < ConstantLines(0,0,0,0).Line1[0])
                            {
                            BackColor = Color.DarkRed;
                            }
                            }


                            I can only get it to compile when I use the 0 values. This is frustrating! Hopefully you can help.
                            Last edited by Solomon; 05-14-2012, 04:29 PM.

                            Comment


                              #15
                              Solomon,

                              When you define new code such as this and add a bunch of lines, it doesn't change the indicator generated code below. You will need to go through and modify it to match appropriately. Could you post an updated version of your code or is the ConstantLines in the first post still the one you are using?
                              Adam P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Maxwell123, Today, 12:34 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_ChrisSch  
                              Started by memonic, Today, 02:21 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post memonic
                              by memonic
                               
                              Started by Guru73, Yesterday, 02:47 AM
                              5 responses
                              33 views
                              0 likes
                              Last Post Guru73
                              by Guru73
                               
                              Started by Guru73, Today, 01:35 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post Guru73
                              by Guru73
                               
                              Started by i2w8am9ii2, Yesterday, 04:41 PM
                              1 response
                              11 views
                              0 likes
                              Last Post Lancer
                              by Lancer
                               
                              Working...
                              X