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

Getting alternative time series and instrument data programtically; BarsRequest?

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

    Getting alternative time series and instrument data programtically; BarsRequest?

    Hello,

    I have an indicator which runs on Tick charts/data. As tick data can be very resource/memory intensive depending on how many days are loaded I am trying to find a way to access previous days time data within the indicator for alternative instruments without having to load multiple days data from within the tick chart. e.g If I am trading EURUSD on tick data with one full day of tick data loaded and I want to access the previous 5 days closes for GBPUSD so that I can can then get my exchange rate for £/$ and vice versa which I can then use within my indicator to determine my position size. I don't want to have to load 5 days worth of tick data. Ideally I would like to request the time data once the chart is loaded (state=dataloaded), get the info then remove the time data before I move into realtime processing of tick data for my indicator.

    I am hoping you can advise on the best way to achieve this? I was wandering whther BarsRequest might be an option? Request the specific bars, get the close price then dispose of the requested bars? I ahve no experience of using bars request and have and looked at the guide however am not sure that I could get it to work in this way? https://ninjatrader.com/support/help..._reference.htm

    Thanks

    #2
    What is your question ??
    You explaining so much but not understand

    Comment


      #3
      Cincai, my request is:

      Originally posted by b16_aln View Post
      I am hoping you can advise on the best way to achieve this? I was wandering whther BarsRequest might be an option?

      Comment


        #4
        Hello b16_aln,

        You could try using the bars request if that would suit your needs. That does not produce Series<double> based data so it cannot be used with indicators or anything that takes a series. You would need to request the timespan and bar series you wanted and then use the returned Bars to loop over the returned bars and find the data you wanted. The sample in the help guide shows that concept in its OnBarUpdate void.


        From the sample it also has some UI related code because BarsRequests are intended to be used in addons, you would need to review the loop it used:

        Code:
        for (int i = 0; i < bars.Bars.Count; i++)

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks Jesse, that's excellent.

          I'm getting some unexpected behaviour when I call bars.Bars.GetTime(i). When setting the trading hours based on a trding hours template which has a 10pm session start time, the Bars.GetTime(i) returns the correct date but the hours as 00:00:00 for day bar of type day. I would be expecting time to return as the time at start of session?

          for(inti=0;i<bars.Bars.Count;i++)
          {
          // Output the bars
          NinjaTrader.Code.Output.Process(string.Format("Time: {0} Open: {1} High: {2} Low: {3} Close: {4} Volume: {5}",
          bars.Bars.GetTime(i),
          bars.Bars.GetOpen(i),
          bars.Bars.GetHigh(i),
          bars.Bars.GetLow(i),
          bars.Bars.GetClose(i),
          bars.Bars.GetVolume(i)),PrintTo.OutputTab1);
          }

          Comment


            #6
            Hello b16_aln,

            If you are using Daily bars then the timestamps would not be relevant, you would just see dates. If you are using a bar series that can have specific times per bar then you would see hours listed. With daily bars you would just need to reference the session information you already used to know what times the bars begin/end, the data would be for the daily bar.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Great, thanks again Jesse

              Comment


                #8
                ..removed post
                Last edited by b16_aln; 03-31-2021, 03:11 AM.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by pechtri, 06-22-2023, 02:31 AM
                9 responses
                122 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by frankthearm, 04-18-2024, 09:08 AM
                16 responses
                64 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by habeebft, Today, 01:18 PM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by benmarkal, Today, 12:52 PM
                2 responses
                13 views
                0 likes
                Last Post benmarkal  
                Started by f.saeidi, Today, 01:38 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Working...
                X