• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Symbol indicator not collecting the right data

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

    Multi Symbol indicator not collecting the right data

    I am collecting data in a script that posts data to excel.

    The currency data is working fine as is the vix data.

    The Stock and Index date timestamp is -1 day from the OHLC and a check with the historical data manager confirms this.

    Some the the futures data works and some have the date behind the price data.

    I put this code is as it seems to run through on each barupdate twice on the primary bar and once on all the others, eg. 0,1,2,3,0.

    So this code works on the second appearance of the primary bar.

    I can see why on a daily feed the dates and prices would miss on some and work on others

    if (lastinstrument==true && BarsInProgress == 0)

    lastinstrument=false;


    if (BarsInProgress == 0)lastinstrument=true;


    Code:
            protected override void OnBarUpdate()
            {
            
                // Use this method for calculating your indicator values. Assign a value to each
                // plot below by replacing 'Close[0]' with your own formula.
                if (excelOpen == false)
                {
                    SetUpSpreadsheet();
                    rowCount ++;
                }
    
                
    
                
        if     (lastinstrument==true && BarsInProgress == 0)
        {
            for (int i = 0; i < 437; i++) 
            {
                if (CurrentBars[i]>=0)        
                        {        
                            excelSheet = (Excel._Worksheet)excelWorkBook.Sheets[names[i]];
                        
                            excelSheet.Cells[rowCount,1] = ToDay(Times[i][0]);
                            excelSheet.Cells[rowCount,2] = ToTime(Times[i][0]);
                            excelSheet.Cells[rowCount,3] = Opens[i][0];
                            excelSheet.Cells[rowCount,4] = Highs[i][0];
                            excelSheet.Cells[rowCount,5] = Lows[i][0];
                            excelSheet.Cells[rowCount,6] = Closes[i][0];
                            excelSheet.Cells[rowCount,7] = Volumes[i][0];
                        }
                
            }
        lastinstrument=false;
        rowCount ++;
        if (rowCount == Count+10) rowCount = 1;    
        }
    
    
    
    if (BarsInProgress == 0)lastinstrument=true;
            }

    #2
    Hi Tinkerz,

    Thank you for posting.

    What time frame are you adding in?

    Are you running against historical or real time data?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I am running daily's historical data.

      Is there any way to get Excel 2010 and the database connector to look at NT's sql database to look at the historical data, that is probably the best way to do what I want?

      Thanks

      Tinkerz

      Comment


        #4
        Hi Tinkerz,

        Unfortunately, it is not possible to have Excel 2010 and the database connector look at NinjaTraders SQL for the historical data.

        You are correct about when OnBarUpdate() is called it's going through twice. When using multiple symbols, the primary will always be executed first, then the secondary symbols.

        Your code -
        Code:
        Opens[i][0]
        is asking to get the Open of the 'i', which is being increased by the for loop and represents the bars array index value, and then the current bar's Open price.

        If I'm following your code correctly, you will want to change the 'i' to the second set of brackets to access the bars and change the first bracket to which symbol you would want to access and then have a second set of excel cells to grab the next symbol.

        I would also print out the bars to ensure you are referencing the correct bar and symbols by using the Print() feature.

        Below is a link on to the online help guide on Multi-Time Frame & Instruments for NinjaScript.
        http://www.ninjatrader.com/support/h...nstruments.htm

        Please let me know if I can be of further assistance
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Code:
              if (BarsInProgress == 0)
               {
                    double primaryClose  = Close[0];
                    double msft3minClose = Closes[1][0];
                    double aapl1minClose = Closes[2][0];
           
                    // primaryClose could also be expressed as
                    // primaryClose = Closes[0][0];
               }
          I used the example in the ninjatrader notes, so on every Onbarupdate a new row will be printed to excel. So whatever data is in the bar will be printed, bar by bar.

          So should I be printing data on the first time barsinprogress=0 or the secondtime it appears?

          Also the print in my excel document will match any print NT statement, but I have coded on in as a double check.

          The data is correct as in the close prices follow the close prices in the history manager. Just the dates dont match up but they match in the chart itself, this is quite odd
          Last edited by tinkerz; 05-07-2013, 02:52 PM.

          Comment


            #6
            Hi Tinkerz,

            What instruments are you working with?

            Have you changed the session template for any of those instrument through the Instrument manager?

            What timezone are you located in?

            Can you send me a screen shot of the compared dates that aren't matching up?

            To send a screenshot press Alt + PRINT SCREEN to take a screen shot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

            For detailed instructions please visit the following link

            http://take-a-screenshot.org/
            Cal H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Grantx, Today, 08:22 AM
            0 responses
            5 views
            0 likes
            Last Post Grantx
            by Grantx
             
            Started by Swing123, Today, 08:21 AM
            2 responses
            5 views
            0 likes
            Last Post Swing123  
            Started by lunardiplomacy, Today, 07:57 AM
            0 responses
            3 views
            0 likes
            Last Post lunardiplomacy  
            Started by Tagliareni, Yesterday, 08:10 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Started by SDaCosta30, Today, 04:19 AM
            2 responses
            14 views
            0 likes
            Last Post SDaCosta30  
            Working...
            X