Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsRequest question

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

    BarsRequest question

    Hello

    I am using pit session trading to run my indicators but I also need to always download the last Overnight session from my code.

    I have done some research and I think that BarsRequest is the best way to achieve that.
    Am I right ?

    If so sometimes I will need to download historical data as well as real time data if I open my indicator in the middle of the overnight session for example.

    Is the bars back download from the BarsRequest constructor only apply to historical data and real time will be updated through my custom OnBarUpdate method as long as there is real time data ?

    Need some guidance
    Thank you

    #2
    Hello blar58,

    Just to confirm, you are looking for data that is not already loaded on the chart, is this correct?

    Is this from a different instrument or a different bar type or interval?

    Using a BarsRequest to get a small period of data from a different instrument would be a way to reduce the amount of resources needed for the script as opposed to adding the other instrument as a secondary series using the AddDataSeries() call.

    The barsRequest.Request() does the request for the historical data.
    Adding a method as a handler to the barsRequest.Update event allows you to create a subscription for real-time data for that instrument.
    http://ninjatrader.com/support/helpG...arsrequest.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ChelseaB

      Yes I am looking for data not already loaded on the chart because I am using the Pit session only for the chart and I am loading last overnight session from the BarsRequest.

      The interval and the instrument is the same obviously.

      Example :

      Main Instrument ES CME US Index Futures RTH 30 Minute

      From BarsRequest : ES Overnight Session (custom session that I created) 30 Minute

      Comment


        #4
        Hi blar58,

        The barsRequest object will have a property for the trading hours template that can be set.

        barsRequest.TradingHours = TradingHours.Get("Default 24 x 7");
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I have coded the BarsRequest like the example provided on this forum but all of a sudden NT8 stops working. Seems to be in conflict with something else.

          No error message from the the trace and log files but I get a message box stating that that NinjaTrader has stopped working.

          Comment


            #6
            Hi blar58,

            I've attached an example that does a dynamic bars request for a selected instrument.

            The trading hours template chosen is the default 24 / 7 template.

            Does this script also cause NinjaTrader to crash?

            Updated version in post # 12
            Last edited by NinjaTrader_ChelseaB; 02-01-2023, 02:39 PM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Yes it does

              Comment


                #8
                Hello blar58,

                I've tested this script on my end and I am not experiencing any crashing.

                Do you have other scripts running?

                What version of the Beta are you using?
                (Help -> About...)
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Yes it is part of a big indicator and I am using beta 11.

                  What I am noticing right now though is that when crash happens and I reload the indicator seems that the BarsRequest object is still in memory.

                  I have reloaded the indicator. it was working fine so I immediately saved and closed my workspace. I reloaded the indicator and seems to be fine now.

                  I will keep this thread updated ...

                  Comment


                    #10
                    Hello blar58,

                    The example I have provided removes the secondaryBarsRequest.Update event handler in State == State.Terminated. This stops the event handler. The .NET garbage collector would then remove this from memory as memory is needed.

                    Please close all workspaces and open a new blank workspace. Then restart NinjaTrader to ensure no other scripts are running. Then try running the example script I have provided you once more by itself. Does the script still cause NinjaTrader to crash?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      No this script doesn't cause NT to crash.

                      But if NT crashes does the state terminated executed ?

                      It seems not according to the way that it behaved.
                      My script still working fine for the time being.
                      Will let you know how it goes

                      Comment


                        #12
                        Hello Community,

                        An updated version of this script attached.
                        Attached Files
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by bill2023, Yesterday, 08:51 AM
                        8 responses
                        43 views
                        0 likes
                        Last Post bill2023  
                        Started by yertle, Today, 08:38 AM
                        6 responses
                        25 views
                        0 likes
                        Last Post ryjoga
                        by ryjoga
                         
                        Started by algospoke, Yesterday, 06:40 PM
                        2 responses
                        24 views
                        0 likes
                        Last Post algospoke  
                        Started by ghoul, Today, 06:02 PM
                        3 responses
                        16 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by jeronymite, 04-12-2024, 04:26 PM
                        3 responses
                        46 views
                        0 likes
                        Last Post jeronymite  
                        Working...
                        X