Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting no data

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

    Getting no data

    Hello

    I have created an indicator and I am using the bar request to get some data.


    Here I am trying to get daily data on the SPY.


    Here is part of my code :

    Code:
    requestDailyBestVolume = new BarsRequest(Instrument.GetInstrument("SPY", DateTime.Now.AddDays(-25), DateTime.Now);
    
    // Parametrize your request.
    requestDailyBestVolume.BarsPeriod = new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1440 };
    requestDailyBestVolume.TradingHours = TradingHours.Get("CME US Index Future RTH");
    
    
    requestDailyBestVolume.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage) =>
    {
    
    if (errorCode != ErrorCode.NoError)
    {
    ChartControl.Dispatcher.InvokeAsync(new Action(() => {
    NinjaTrader.Gui.Tools.NTMessageBoxSimple.Show(Wind ow.GetWindow(ChartControl.OwnerChart as DependencyObject), " Error on requesting bars !", "Alert", MessageBoxButton.OK, MessageBoxImage.Hand);
    }));
    //System.Windows.Forms.MessageBox.Show(" Error on requesting bars !");
    return;
    }
    Print(" Bars Count : "+bars.Bars.Count);
    
    // Output the bars we requested. Note: The last returned bar may be a currently in-progress bar
    for (int i = 0; i < bars.Bars.Count; i++)
    {
    Print((double)bars.Bars.GetVolume(i));
    }



    After testing it gets the instrument right as well as the Trading Hour but I get no bars ?
    it prints Bars Count : 0 and it doesn't get to my second print statement.


    What is wrong ?




    #2
    Hello blar58,

    Thank you for your note.

    Looks like you have some issues with the forming of the request. I've created a simple example script that I'm seeing return SPY bar values that you can compare to your code - I'm seeing this print as I would expect. Do you see the same on your end?

    Thanks in advance; I look forward to assisting you further.
    Attached Files

    Comment


      #3
      My code is exactly the same except that it is not coming from State.Configure but inside a timer that triggers a BackgroundWorker as I need to delay the downloading.

      In short I am waiting 30 seconds before downloading the data.
      Last edited by blar58; 07-27-2022, 01:23 PM.

      Comment


        #4
        Hello blar58,

        Thank you for your reply.

        Can you modify the indicator I sent to demonstrate how you're trying to trigger the request?

        Thanks in advance; I look forward to assisting you further.

        Comment


          #5
          Hello Kate

          Sorry for the delay.
          Here I have attached the modified indicator.

          Thank you
          Attached Files

          Comment


            #6
            Hello blar58,

            Thank you for your reply.

            This doesn't compile when I import it manually into NinjaTrader. We would need a compilable example that demonstrates what you are seeing with prints.

            Thanks in advance; I look forward to assisting you further.

            Comment


              #7
              Sorry for this Kate

              Here is the modified indicator again
              Attached Files

              Comment


                #8
                Hello blar58,

                Thank you for your reply.

                I'm able to see the output I would expect when running the above example on a chart. Here's the output I get from testing:

                Code:
                 Bars Count : 18
                Time: 7/8/2022 3:00:00 PM Open: 387.27 High: 390.64 Low: 385.66 Close: 389.02 Volume: 50623398
                Time: 7/11/2022 3:00:00 PM Open: 385.85 High: 386.87 Low: 383.5 Close: 384.65 Volume: 44893902
                Time: 7/12/2022 3:00:00 PM Open: 383.65 High: 386.16 Low: 378.99 Close: 380.81 Volume: 46223253
                Time: 7/13/2022 3:00:00 PM Open: 375.1 High: 381.92 Low: 374.66 Close: 378.15 Volume: 59611696
                Time: 7/14/2022 3:00:00 PM Open: 373.66 High: 378.57 Low: 371.04 Close: 378.15 Volume: 59357802
                Time: 7/15/2022 3:00:00 PM Open: 382.55 High: 385.36 Low: 380.54 Close: 385.25 Volume: 49347522
                Time: 7/18/2022 3:00:00 PM Open: 388.38 High: 389.09 Low: 380.66 Close: 382.41 Volume: 47403304
                Time: 7/19/2022 3:00:00 PM Open: 386.08 High: 393.36 Low: 385.39 Close: 393.04 Volume: 58291904
                Time: 7/20/2022 3:00:00 PM Open: 392.41 High: 396.26 Low: 391.03 Close: 394.04 Volume: 52512042
                Time: 7/21/2022 3:00:00 PM Open: 394.16 High: 399.03 Low: 391.63 Close: 397.72 Volume: 48175831
                Time: 7/22/2022 3:00:00 PM Open: 398.92 High: 400.18 Low: 392.75 Close: 394.99 Volume: 50192063
                Time: 7/25/2022 3:00:00 PM Open: 395.75 High: 396.47 Low: 393 Close: 394.76 Volume: 40379644
                Time: 7/26/2022 3:00:00 PM Open: 393.84 High: 394.06 Low: 389.95 Close: 392.51 Volume: 40602818
                Time: 7/27/2022 3:00:00 PM Open: 394.36 High: 402.88 Low: 394.05 Close: 400.66 Volume: 61608779
                Time: 7/28/2022 3:00:00 PM Open: 401.89 High: 409.72 Low: 398.15 Close: 409.21 Volume: 54303371
                Time: 7/29/2022 3:00:00 PM Open: 407.58 High: 413.03 Low: 406.77 Close: 411.94 Volume: 57955342
                Time: 8/1/2022 3:00:00 PM Open: 409.15 High: 413.41 Low: 408.4 Close: 411.02 Volume: 51700105
                Time: 8/2/2022 3:00:00 PM Open: 409.12 High: 413 Low: 406.82 Close: 409.44 Volume: 37618202
                Are you not seeing the same on your end with the modified example you provided?

                Thanks in advance; I look forward to assisting you further.

                Comment


                  #9
                  No

                  I am seeing Bars Count : 0

                  It's kind of weird !
                  Same indicator different results
                  Last edited by blar58; 08-02-2022, 01:40 PM.

                  Comment


                    #10
                    Hello blar58,

                    Thank you for your reply.

                    Can you confirm you're connected to a data connection when testing?

                    Who is your data provider? Are you able to pull up a chart of the same time frame for SPY?

                    Thanks in advance; I look forward to assisting you further.

                    Comment


                      #11
                      Here is my chart settings.

                      Yes I am connected and my data provider is Rithmic for NinjaTrader Brokerage

                      But I cannot load SPY data from this connection !
                      Attached Files

                      Comment


                        #12
                        OK the code is fine but my data provider doesn't allow me to download stock data.
                        I did a test with Kinetick and everything is fine.

                        Thank you

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        637 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        366 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        107 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        569 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        571 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X