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

Setting DataSeries

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

    Setting DataSeries

    I am trying to create a DataSeries of PivotPoints. The IndexLocation 0 is populated but index location 1 is not.

    I define the DataSeries

    private DataSeries pivotSeries; //Data Series for PivotPoints

    Calculate the Variableat the start of the day:-

    if(BarsInProgress == 2)// 5 Min Bars
    {
    #region Calculate and Draw Pivots

    if(ToTime(Time[0]) == 80500)
    {

    if(historical)
    {
    // Calculate Pivot Points(for order Entery)



    pp = Math.Round((Highs[1][0] + Lows[1][0] + Closes[1][0])/3,2);

    and set the DataSeries on the Daybar update,

    if(BarsInProgress == 1)// Day Bars
    {
    pivotSeries.Set(pp); // Adds Current Pivot to Pivot DataSeries
    }

    But when I do Print(pivotSeries[1]); I get 0 as the reply???

    #2
    GKonheiser, from which BarsInProgress do you print the prior pivot series entry then? You assign a value on the day bar and calculate the values on 5 min however the data series per default would be synched to the primary series on your chart.

    You can though sync it to any other bars object as well, a 'how to' is shown with this sample - http://www.ninjatrader.com/support/f...ead.php?t=3572
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I am calculating the pivots once a day at 8.05 based on the previous days day bar. I have now used the reference you gave to sync the dataseries to the day bars>/

      protected override void Initialize()
      {

      Add(PeriodType.Day, 1);//Add Day Bars with index location 1
      Add(PeriodType.Minute, 5);//Add 5 min Bars with index location 2

      pivotSeries = new DataSeries(this);

      CalculateOnBarClose = true;
      BarsRequired = 20;
      }


      protected override void OnBarUpdate()
      {

      if(pivotSeries == null) // This is just to tie the pivotSeries DataSeries to the Day bars, Index 1
      {
      pivotSeries = new DataSeries(SMA(BarsArray[1], 1));
      }


      It then calculates the pivot in the BarsInProgress == 2 which is the 5 min bars but it only makes this calculation once at 8.05.

      if(BarsInProgress == 2)// 5 Min Bars
      {
      #region Calculate and Draw Pivots

      if(ToTime(Time[0]) == 80500)
      {

      if(historical)
      {
      // Calculate Pivot Points(for order Entery)



      pp = Math.Round((Highs[1][0] + Lows[1][0] + Closes[1][0])/3,2);


      I then set the dataSeries in BarsInProgress == 1, the day bars,

      if(BarsInProgress == 1)// Day Bars
      {
      pivotSeries.Set(pp); // Adds Current Pivot to Pivot DataSeries
      }


      BUT im still not getting a value for the prior day, pivotSeries[1]?

      Comment


        #4
        GKonheiser, what's the intent for the series? To be able to compare to one prior value to see the direction of the pivot? I would then not take a series at all but just store in two variables to be able to do the compare. The series would only have the value that you explicitly set for a bar, plus the primary series would always be processed first so if you set the value from the daily > you could not print the value from the primary series of that date, but only after the day bar was this date was processed. This can complicate matters and for that reason, I would rather work with tracking variables here.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Yes your right at the moment I only need 2 pivots so should I do something like this:-

          if(ToTime(Time[0]) == 80000)
          {
          ppold = pp
          }

          where pp is the current pivot and ppold would be yesterdays and after setting ppold the new pp would be calculated at 80500.
          Last edited by GKonheiser; 11-20-2013, 01:51 PM.

          Comment


            #6
            Correct, for example like this -

            if(BarsInProgress == 2)
            {
            if(ToTime(Time[0]) == 80000)
            ppOld = pp;

            if(ToTime(Time[0]) == 80500)
            pp = Math.Round((Highs[1][0] + Lows[1][0] + Closes[1][0])/3,2);

            }
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Could I use Bars.FirstBarOfSession instead, I tried to use it beofre but ran into some problems but it should be a cleaner way of doing it?

              Comment


                #8
                That should be possible as well, yes cleaner since it would not mean static times you check for but the session templates.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by rtwave, 04-12-2024, 09:30 AM
                2 responses
                20 views
                0 likes
                Last Post rtwave
                by rtwave
                 
                Started by tsantospinto, 04-12-2024, 07:04 PM
                5 responses
                68 views
                0 likes
                Last Post tsantospinto  
                Started by cre8able, Today, 03:20 PM
                0 responses
                7 views
                0 likes
                Last Post cre8able  
                Started by Fran888, 02-16-2024, 10:48 AM
                3 responses
                49 views
                0 likes
                Last Post Sam2515
                by Sam2515
                 
                Started by martin70, 03-24-2023, 04:58 AM
                15 responses
                115 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X