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

Backward looking bars

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

    Backward looking bars

    Hello,

    How can I create backward look bars? Here is what I am looking for:

    Let's take 5 min bars. Each bar starts at 5 min intervals: 9:30, 9:35, 9:40. etc...

    However, suppose it is 10:03:00 now and I want to plot the 5 min candle from 9:58:00 until now (which is 10:03:00).

    The same applies to tick charts. Suppose I want to create a 500 tick chart that starts exactly 500 ticks ago and ends now.

    How would this be accomplished?

    Many thanks in advance!


    #2
    Hello electronicsnake,

    Thank you for your post.

    That would be a little tricky, but you could consider creating a tickbased bar type that builds bars based on timestamps that you specify.

    You can check the time with some custom logic to decide when to make a bar, (such as the time.Minute being 3 or 8), and then call AddBar() instead of UpdateBar() to break a new bar early.
    https://ninjatrader.com/support/help...nt8/addbar.htm

    For the tick bars, I'm a bit confused - that sounds like a 500 tick chart with Break at EOD unchecked - that would create a chart of 500 tick bars beginning at the start of the loaded data - is this not what you're wanting?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate,

      Many thanks for the answer and the suggestion with AddBar(). Truly appreciate it!

      Does AddBar() create a tick-based bar type?

      With respect to time bars, my goal is this:

      If you consider a 5 min candlesticks, they normally start at increments of 5 minutes, beginning at 9:30, 9.35, 9:40, etc... So if it is 9:42 now, the current 5min candlestick bar has a duration of 2 minutes. What I need is a 5 min bar that shows the LAST 5min beginning from now. So if it is 9:42 now, the back-ward looking bar would start at 9.37 and ends now at 9:42.


      With respect to tick bars, I guess the solution would be like this:

      If I want a back-ward looking 200-tick chart, I would simply need to compress the last 200 1-tick bars into a single bar. In this case, I would get a candle that includes the trading activity of the last 200 ticks.
      Normally a 200-tick chart starts a new bar whenever 200 ticks are made.So the current candle might have 20 ticks or 23 ticks or whatever... However, in case of a back-ward looking tick chart, the current candle ALWAYS has 200 ticks.


      I hope I have not confused you, Kate... Once again, many many thanks!

      Regards,
      ES


      Comment


        #4
        Hello electronicsnake,

        Thank you for your clarification.

        Unfortunately it wouldn't be possible to build bars going backwards, OnDataPoint will always be chronological.

        We read the initial post as "I want to start a 5min bar at 10:03" so that could be done with a custom bar that is based on tick data. It would be possible to say, make a few 5 minute bar variant that is based off of tick data and is offset by 1, 2, 3, or 4 minutes.

        For tick bars could you could try loading a data series of single tick data with 500 bars to load and use an indicator to analyze the data from there.

        That would be as far as you could go with a BarsType. You may wish to do some indicator analysis to highlight relevant bars instead. You could get information on the last bar in the data series in State.DataLoaded, or look for the first bar after State.Realtime and do what you need from there, but constructing bars by going backwards wouldn't be something you could do.

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Kate!

          Many thanks for your answer! Truly appreciate it!

          Could you please just tell me how I can construct this data series of single tick data with 500 bars? Let's suppose I want to calculate the total delta of this 500 single tick bars. How would I do that?

          Many thanks again!

          Regards,
          ES

          Comment


            #6
            Hello electronicsnake,

            Thank you for your reply.

            If you have a lifetime license key and have access to the Order Flow + items, you could use a 1 tick Volumetric bars series in an indicator, and loop through and add up the deltas for each of the last 500 bars, that would seem to satisfy what you're looking for.



            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by nandhumca, Yesterday, 03:41 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by The_Sec, Yesterday, 03:37 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by vecnopus, Today, 06:15 AM
            0 responses
            1 view
            0 likes
            Last Post vecnopus  
            Started by Aviram Y, Today, 05:29 AM
            0 responses
            5 views
            0 likes
            Last Post Aviram Y  
            Started by quantismo, 04-17-2024, 05:13 PM
            3 responses
            27 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X