• 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

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?
            Attached Files
            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

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by iq200, 11-09-2019, 08:26 AM
                      5 responses
                      56 views
                      0 likes
                      Last Post koganam
                      by koganam
                       
                      Started by johng964, Today, 02:57 PM
                      1 response
                      11 views
                      0 likes
                      Last Post NinjaTrader_RyanS  
                      Started by spamula, Today, 03:00 PM
                      2 responses
                      16 views
                      0 likes
                      Last Post spamula
                      by spamula
                       
                      Started by MARTIN MARTIN, Today, 01:01 PM
                      0 responses
                      16 views
                      0 likes
                      Last Post MARTIN MARTIN  
                      Started by bouncetherubble, Today, 10:21 AM
                      2 responses
                      21 views
                      1 like
                      Last Post bouncetherubble  
                      Working...
                      X