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

Complex processing of DataSeries

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

    Complex processing of DataSeries

    Hi,
    I would like to manipulate heavily a dataseries with a loop going through all the values. The examples that I see always rely on setting the value of the DataSeries on the OnUpdateBar method with a simple set of the variable.
    I had issues when I tried to do a 2-pass of the series with a for loop.
    Could someone provide an example of a more complex manipulation as a guide?

    Thanks
    sk

    #2
    Hi sktrader1,

    What issue did you experience with the loop?
    Can you post snippet of code to test, and describe what you mean by two-pass loop?
    TimNinjaTrader Customer Service

    Comment


      #3
      I did some debugging and actually the major problem is when I try to create a DataSeries. For example

      I declare the Series Result

      #region Variables
      private DatSeries Result;
      #endregion

      protected override void Initialize()
      {

      Result = new DataSeries(this);
      }


      protected override void OnBarUpdate()
      {

      for(Bar=2;Bar<=1000;Bar++)
      {
      Result[Bar]=Bar;
      Print((Result[Bar]).ToString());
      }
      }



      When I try this the Result can fill in only up to value 20(!) and then it stops....
      Shouldnt that be as long as the data bars?

      Comment


        #4
        Hi sktrader1,

        What version of NT are you using?

        Since you're assigning a value....

        Result[Bar]

        You'll be limited to the number of bars on the chart (or by 256 in NT7 with lookback = 256).

        If you want the Bar<=1000 setting, you would need atleast 1000 bars on the chart.

        Alternatively, you could set Bar<=CurrentBar
        TimNinjaTrader Customer Service

        Comment


          #5
          I agree but the point is not with the Bar but with the Result[].
          The chart contains >1000 bars but when I try to assign a value to the Result where Bar>20 the program folds!

          Comment


            #6
            Hi sktrader1,

            So I can test this, what version of NT are you using?
            TimNinjaTrader Customer Service

            Comment


              #7
              Sorry. I am not using NT but XP. maybe I should try that on Win7 as well. Re-reading your post i am using 6.5 I believe.
              Last edited by sktrader1; 04-29-2010, 12:18 PM.

              Comment


                #8
                Hi sktrader1,

                Tested on my end and appears to work fine.
                Re-assigning in the loop, or in another piece of code?
                Can you provide that?
                TimNinjaTrader Customer Service

                Comment


                  #9
                  Hi thanks for the help but I cannot make it work on mine!

                  Here is the complete code:


                  public class TEST : Strategy
                  {
                  #region Variables
                  // Wizard generated variables
                  private int myInput0 = 1; // Default setting for MyInput0
                  // User defined variables (add any user defined variables below)

                  private DataSeries Result;
                  #endregion

                  /// <summary>
                  /// This method is used to configure the strategy and is called once before any strategy method is called.
                  /// </summary>
                  protected override void Initialize()
                  {
                  CalculateOnBarClose = true;
                  Result = new DataSeries(this);
                  }

                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                  int Bar;

                  for(Bar=2;Bar<=100;Bar++)
                  {

                  Result[Bar]=Bar;
                  Print((Result[Bar]).ToString());
                  }


                  }

                  #region Properties
                  [Description("")]
                  [Category("Parameters")]
                  public int MyInput0
                  {
                  get { return myInput0; }
                  set { myInput0 = Math.Max(1, value); }
                  }
                  #endregion
                  }



                  It never prints more than the value 20 on the output window. Am I missing something? I am using version 6.5.1000.15

                  Comment


                    #10
                    Hi I found why it was doing that. For some reason when I was applying the strategy there was under General--> Min. bars required---> was set to 20 ! When I changed that to a higher number the output was variable to that number. I wasnt aware that you had to set that number there if you synchronize your data to the whole series... How about if you want to have access to the whole dataseries and you don't know how big it is when you apply the data? I am aware you can get that from Count but that is internal. When you run the strategy the number has to be but put there manually. How do these two reconcile?

                    Thanks

                    Comment


                      #11
                      Hi sktrader1,

                      Aw, I see, I was under the impression this was an indicator, otherwise I would have offered that solution, my apologies.

                      The min bars required is a setting used for calculating the strategies positions and indicator values. Generally, you will still have access to all the bars, but since you were assigning values historical, with each new bar, for your strategy, you did need to know the number of bars of the chart. Which as mentioned earlier, can be done with CurrentBar.
                      TimNinjaTrader Customer Service

                      Comment


                        #12
                        Thanks. Is there a quick way to plot the Result[] if is calcualted in this way except of DrawDot etc?

                        Comment


                          #13
                          Hi sktrader1,

                          Can you clarify what you mean by "if is calcualted in this way except of DrawDot etc?"
                          TimNinjaTrader Customer Service

                          Comment


                            #14
                            I mean that assuming we have the data in a dataseries : Result[] in this example. How do we plot it on the chart assuming it is part of the strategy not an indicator?

                            Comment


                              #15
                              Yes, what are you trying to do exactly? Are you debugging or trying to build the indicator?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by rhyminkevin, Today, 04:58 PM
                              3 responses
                              48 views
                              0 likes
                              Last Post Anfedport  
                              Started by iceman2018, Today, 05:07 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post iceman2018  
                              Started by lightsun47, Today, 03:51 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post lightsun47  
                              Started by 00nevest, Today, 02:27 PM
                              1 response
                              14 views
                              0 likes
                              Last Post 00nevest  
                              Started by futtrader, 04-21-2024, 01:50 AM
                              4 responses
                              50 views
                              0 likes
                              Last Post futtrader  
                              Working...
                              X