Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using OnMarketData and bars

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

    Using OnMarketData and bars

    I'm looking to combine real-time data and bar data in an indicator.

    My question is given the following description is it sufficient to use OnBarUpdate and CalculateOnBarClose = false or do I need to use OnMarketData somehow? Are there any known issues I should expect?


    1) Given an indicator with a lookback of N bars.
    The indicator measures the magnitude of a trend,
    magnitude = numerator / denominator - 1

    2) I need the numerator to be real-time data and the denominator to be the close of a bar n bars ago (where n <= N).

    3) Then, assuming we are using volume bars, value = 1000,
    I need a new bar to be formed in real-time for every 1000 contracts (volume) to make sure that the bars in the lookback are updating with the arrival of new data.

    #2
    Hello bluelou,

    Running you calculations on each incoming tick of data either using CalculateOnBarClose (COBC) set to false or OnMarketData() can both use a lot of CPU usage depending on how the indicator is programmed itself.

    This all can be programmed inside of OnBarUpdate() to keep this simple as you are going to be getting the Close of the price a specific number of bars ago. So you can use Close[0] to reference the current bar and you can reference Close[x] were "x" is the number of bars ago that you would like to view and still use the COBC to control if you want your Indicator to be calculating on the Close of the Bar or on each incoming tick of data just like in OnMarketData().



    Let me know if you have any further questions.
    JCNinjaTrader Customer Service

    Comment


      #3
      JC,
      So, if I understand you correctly COBC should be sufficient, right? (And, yes, I need every tick since it's a very short term strategy).

      You said "all can be programmed inside of OnBarUpdate() to keep this simple...". This is unclear to me. How will putting everything in OnBarUpdate() simplify things? FWIW, the indicator has several functions and >1000 lines of code. Are you saying ALL of this should be in OnBarUpdate?


      Originally posted by NinjaTrader_JC View Post
      Hello bluelou,

      Running you calculations on each incoming tick of data either using CalculateOnBarClose (COBC) set to false or OnMarketData() can both use a lot of CPU usage depending on how the indicator is programmed itself.

      This all can be programmed inside of OnBarUpdate() to keep this simple as you are going to be getting the Close of the price a specific number of bars ago. So you can use Close[0] to reference the current bar and you can reference Close[x] were "x" is the number of bars ago that you would like to view and still use the COBC to control if you want your Indicator to be calculating on the Close of the Bar or on each incoming tick of data just like in OnMarketData().



      Let me know if you have any further questions.

      Comment


        #4
        Hello bluelou,

        Correct, COBC should be sufficient.

        To clarify, I was referring to the price logic like Close[0] and Close[x] all can be done inside of OnBarUpdate(). With that said, it really depends on what you have programmed but typically most logic can go inside of OnBarUpdate() as you will have access to the data series in this and when the data series changes.

        Happy to be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          JC,
          So, if I was using the close of a 1000 volume bar w/COBC = true but now I want BOTH the real-time latest tick and I still need to access the bar close after 1000 contracts do I use COBC = false and ".Close", Close[0] or some other object?

          I just need to make sure that the indicator gets both the real-time recent tick and can still receive real-time OHLC bars.

          Comment


            #6
            Hello bluelou,

            With COBC = false using Close[0] will get the latest tick of information, so if you want to get the bar close after the bar has closed then you would want to the previous bars value "Close[1]".

            We actually have a reference sample that you may want to view that goes over separating logic to either calculate once on bar or on every tick at the following thread.


            Happy to be of further assistance.
            JCNinjaTrader Customer Service

            Comment


              #7
              JC, I get it now. Thx much.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by warreng86, 11-10-2020, 02:04 PM
              4 responses
              1,354 views
              0 likes
              Last Post mathewlo  
              Started by Perr0Grande, Today, 08:16 PM
              0 responses
              2 views
              0 likes
              Last Post Perr0Grande  
              Started by elderan, Today, 08:03 PM
              0 responses
              5 views
              0 likes
              Last Post elderan
              by elderan
               
              Started by algospoke, Today, 06:40 PM
              0 responses
              10 views
              0 likes
              Last Post algospoke  
              Started by maybeimnotrader, Today, 05:46 PM
              0 responses
              12 views
              0 likes
              Last Post maybeimnotrader  
              Working...
              X