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

DataSeries

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

    DataSeries

    Would it be possible to to create a DataSeries for a multi time frame indicator that would hold say Closes[0] when the bar is closed but Closes[1] when the bar is front and not yet closed. The idea is that say I had 10 min bars as primary bars and 1 tick bars as secondary that when I referenced my data series I would get the closes of the 10min bars unless I was looking at MyDataSeries[0] which would return Closes[1][0] ?

    #2
    Hello GKonheiser,

    Thank you for your post.

    So hold the Closes[0][0] or Closes[1][0] based on a condition? Like the following?
    Code:
            #region Variables
            private DataSeries myDataSeries;
            #endregion
    		
            protected override void Initialize()
            {
    			Add("NQ 03-16", PeriodType.Minute, 1);
                myDataSeries = new DataSeries(this);
            }
    		
            protected override void OnBarUpdate()
            {
                if (Closes[0][0] > Closes[1][0])
    				myDataSeries[0] = Closes[0][0];
    			else
    				myDataSeries[0] = Closes[1][0];
            }

    Comment


      #3
      Hi Patrick,

      What I want to do it have a data series that contains the close of 10min bars unless its the first bar which should contain the close of 1 tick bar. the complication is that i need to align the data series with a 10 min series and then just update the data-series at index 0 when prices change on processing of BarsInProgress == 1 (tick bars). At the moment with logic similar to below I get stack overflow error and I can guess why.

      More like this
      Code:
       protected override void Initialize()
      {
           if(Historical)
           {
           Add(PeriodType.Tick,1);
      
           hClose = new DataSeries(this);
           }
      
      }
      
      protected override void OnBarUpdate()
      {
           if(Historical)
          {
                if(BarsInProgress == 0)
                {
                      hClose.Set(1,Close[1]);
                }
      				
                if(BarsInProgress == 1)
                {
                     hClose.Set(Closes[1][0]);
                }
           }
      }

      Comment


        #4
        Hello GKonheiser,

        I am not sure if it is Set and calling the bars index, but I used the attached code without issue.
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by RDTrader16, Today, 10:19 PM
        0 responses
        5 views
        0 likes
        Last Post RDTrader16  
        Started by gemify, 03-08-2023, 08:02 AM
        9 responses
        148 views
        0 likes
        Last Post culpepper  
        Started by elirion, Today, 10:03 PM
        0 responses
        2 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by RaddiFX, Today, 09:55 PM
        0 responses
        9 views
        0 likes
        Last Post RaddiFX
        by RaddiFX
         
        Started by Trader146, 03-29-2024, 01:22 PM
        4 responses
        27 views
        0 likes
        Last Post Trader146  
        Working...
        X