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 gravdigaz6, Today, 01:43 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post gravdigaz6  
                  Started by DayneSwift, Yesterday, 11:06 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post DayneSwift  
                  Started by AidanLawrence, Yesterday, 10:03 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post AidanLawrence  
                  Started by butt_toast, Yesterday, 09:47 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post butt_toast  
                  Started by GaryOz, Yesterday, 06:54 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post GaryOz
                  by GaryOz
                   
                  Working...
                  X