Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Data Series question

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

    Custom Data Series question

    Code:
    Variables
    
    for (int i=iLow;i<=iHigh;i++)
    
    where int ilow is 0 index tick bar and iHigh is 10 index tick bar
    --------------------------------------------------
    Initialize
    
    spread = new DataSeries(this);	
    
    --------------------------------------------------
    
    OnBarUpdate
    
    (again, these all using tick bars)
    
    for (int i=iLow;i<=iHigh;i++)	
    
    spread.Set(GetCurrentAsk(i) - GetCurrentBid(i));
    maSpread = SMA(spread, 20)[0];
    Print("maSpread is   " + maSpread + "  " + Instruments[i].FullName);
    
    ________________________________________________________________________

    Question: My security names are updating according to int i; however the maSpread value seems to always be that of the zero bar....

    Any thoughts?

    Kind Regards

    Andrew
    Last edited by alabell; 11-16-2012, 10:42 AM.

    #2
    Hello Andrew,

    Is this a Multi-Instrument NinjaScript?

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Yes, int i contains an array of 10 securities, all tick bars.

      There are also some bars assigned to track minute and day functions but they do not apply here.

      Comment


        #4
        perhaps this will make more sense:

        the initialize section also contains the following...



        //Add("MSFT", PeriodType.Tick, 1); // Add a 1 Tick Bars object - BarsInProgres index = 0 "MSFT""
        Add("ACE", PeriodType.Tick, 1); // Add a 1 Tick Bars object - BarsInProgres index = 1 "ACE""
        Add("ACN", PeriodType.Tick, 1); // Add a 1 Tick Bars object - BarsInProgres index = 2 "ACN""
        Add("ADSK", PeriodType.Tick, 1); // Add a 1 Tick Bars object - BarsInProgres index = 3 "ADSK""
        Add("AKAM", PeriodType.Tick, 1); // Add a 1 Tick Bars object - BarsInProgres index = 4 "AKAM""
        Add("ALGN", PeriodType.Tick, 1); // Add a 1 Tick Bars object - BarsInProgres index = 5 "ALGN""
        Add("ALXN", PeriodType.Tick, 1); // Add a 1 Tick Bars object - BarsInProgres index = 6 "ALXN""
        Add("ANR", PeriodType.Tick, 1); // Add a 1 Tick Bars object - BarsInProgres index = 7 "ANR""
        Add("AOL", PeriodType.Tick, 1); // Add a 1 Tick Bars object - BarsInProgres index = 8 "AOL""
        Add("APOL", PeriodType.Tick, 1); // Add a 1 Tick Bars object - BarsInProgres index = 9 "APOL""

        Comment


          #5
          Originally posted by NinjaTrader_JC View Post
          Hello Andrew,

          Is this a Multi-Instrument NinjaScript?

          Happy to be of further assistance.
          Hello, was that the assistance, we're going on three hours now?

          I think I am probably missing an "i" or [i] somewhere....?

          Comment


            #6
            Hello alabell,

            Thanks for the information.

            I believe two things are happening that may be the issue. First, the following statement: "spread.Set(GetCurrentAsk(i) - GetCurrentBid(i));" will override the value for spread each time.

            The second, using Tick based OnBarUpdate will be called only when a "Last" price is sent. Using lower volume stocks than MSFT you may see many BarInProgress 0 before you see another one.

            Click here to see how bar data is reference.

            Happy to be of further assistance.
            JCNinjaTrader Customer Service

            Comment


              #7
              so how might i ensure that my data is not overwritten every time?

              Comment


                #8
                Would it work to eliminate the data series and simply use my array of tick bars to calculate

                SMA((getCurrentBid(i) - getCurrentAsk(i)),20)[0];

                and then use the result as my value?

                Comment


                  #9
                  Hello alabell,

                  You may want to create multiple data series for each instrument so when you are using your for loop it will be writing on a different data series.

                  http://www.ninjatrader.com/support/h...ries_class.htm

                  Let us know if we can be of further assistance.
                  JCNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by yertle, Yesterday, 08:38 AM
                  7 responses
                  28 views
                  0 likes
                  Last Post yertle
                  by yertle
                   
                  Started by bmartz, 03-12-2024, 06:12 AM
                  2 responses
                  21 views
                  0 likes
                  Last Post bmartz
                  by bmartz
                   
                  Started by funk10101, Today, 12:02 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post funk10101  
                  Started by gravdigaz6, Yesterday, 11:40 PM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by MarianApalaghiei, Yesterday, 10:49 PM
                  3 responses
                  11 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Working...
                  X