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

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 ghoul, Today, 06:02 PM
            3 responses
            14 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            44 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            20 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            180 views
            0 likes
            Last Post jeronymite  
            Started by DanielSanMartin, Yesterday, 02:37 PM
            2 responses
            13 views
            0 likes
            Last Post DanielSanMartin  
            Working...
            X