Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Measuring Time in Renko or Range Bars

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

    Measuring Time in Renko or Range Bars

    Hey guys, I wanna develop a simple Indicator that deals with some kind of Timer inside a Renko or range bar.

    I want it to basically to "How long did it take for this renko/range bar to complete"

    I can prob build my indicator from there. but I have no idea how to do this for these type of bars.

    Any suggestions?

    #2
    Hello,

    Thank you for the question.

    I wanted to check, you are only looking for the duration of each bar is this correct?

    If so you could store a DateTime variable and for each OnBarUpdate call, subtract the old DateTime from the current time and get the difference.

    Once you have done this you could reset the variable and do the same thing over again.

    For DateTime subtraction you could use something similar to this:

    Code:
    private DateTime oldBarTime = DateTime.MinValue;
    
    protected override void OnBarUpdate()
    {
           if (oldBarTime == DateTime.MinValue)     //set an initial starting value. 
                oldBarTime = DateTime.Now;
    
           TimeSpan difference = DateTime.Now.Subtract(oldBarTime);
           Print(difference.ToString());
           oldBarTime = DateTime.Now;
    
    }

    Comment


      #3
      Okay. first Thanks for reply. but I think I have a clearer question.

      How do I make a diamond appear on Range/Renko bar after lets say every 4 minutes passes by.

      Comment


        #4
        Hello,

        I wanted to check do you mean every 4 minutes regardless of the bar time or are you looking for 4 minutes after the bar starts?

        I look forward to being of further assistance.

        Comment


          #5
          I've attached what I"m working on.

          here's a Pic

          World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


          Notice how I'm trying to get Expiration time to be 4 min.

          Code:
          expiryTime = Time[0].AddMinutes(4+Time[0].Minute);

          But when you look at the Entry Times and Expirytimes. it's Not 4 minutes away.
          Attached Files

          Comment


            #6
            Hello,

            Thank you for the script,

            I wanted to ask, you are trying to Add 4 minutes to the bars time using this statement:
            Code:
            expiryTime = Time[0].AddMinutes(4+Time[0].Minute);
            Lets say the time is 6:44, we would be adding 4 + 44 or 48 minutes to the current time projecting this randomly into the future.

            Instead you would just need to add 4 minutes like the following:

            Code:
            expiryTime = Time[0].AddMinutes(4);
            The current Time or Time[0] is the starting position, we add 4 minutes to that to get our expiryTime.

            Please try this and let me know if this does not correct what you are trying to do.

            I look forward to being of further assistance.

            Comment


              #7
              Thanks so much!!!

              WOOO HOOO!!!. it worked. thanks a lot Jess.

              It even works on Range bars and renkos. much appreciated

              Comment


                #8
                One More Problem when Implementing!

                Okay, so I wrote up the Script I've attached it.

                Here's the Main goal. I'm trying to get the EXACT price of a 1 second Bar close but on the Renko/Range or what ever Price bar.

                Problem is that on Price bar instead of getting the seconds bar's close and TimeStamp. I'm only getting the price bar's timestamp and Close.

                I use the Closes[1][0] and Times[1][0]. as you'll see in the code.

                The Pic here shows what I mean:
                World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


                and The attached code should be self Explainatory.

                Please help with this problem. I just don't know what I'm doing wrong.

                Thanks!
                Attached Files

                Comment


                  #9
                  Hello ginx10k,

                  Thank you for your response.

                  Does this occur when using a pre-packaged bar type such as the Range and Renko that come with NinjaTrader? I was unable to reproduce this with the Range bars in NinjaTrader and it appears you are using a custom bar type.

                  Comment


                    #10
                    Hey Patrick, long time no speak.

                    Here the results are reproduced on a Range Bar. http://screencast.com/t/6bOHigbY


                    Indicator still taking the Close of the Range instead of the Closes[1][0] of seconds bar.

                    Comment


                      #11
                      Hello,

                      Thank you for providing the script.

                      I looked over the code and had a few questions.

                      I tried this and from what I can see, every down arrow is matching up with the 1 second series from what the price in yellow is that follows the arrow.

                      I recreated what you had in your second image using the standard range and the same values you have but can not re create this.

                      I wanted to check with you that you are using the Global Crosshair to check the second chart and If so, you are lining up the crosshair using the range chart, and then going to the second chart. Next you are holding the mouse over that bar, then press down the middle mouse button to see the data box. From my tests the Close of the bar that is referenced in the 1 second chart always is what is printed using your condition.

                      I look forward to being of further assistance.

                      Comment


                        #12
                        I am using Global Crosshairs. and From what I see No the CLose of the Seconds chart is Not being used. the last pic I posted shows it clearly. The Range's CLOSE is being used and the seconds is being ignored.

                        Is there something wrong. cause I just can't figure this out!

                        Comment


                          #13
                          Hello,

                          I wanted to provide you with what I am seeing, I am not sure where the gap in our tests is but I am not seeing the same as you are.

                          I have included an image that shows the two charts, the data box and the crosshair.

                          I have placed arrows on the items of interest. The only difference I see is that you are using the Line on close and basing the value from that where I am using the Middle Mouse button to open the data box and get the exact value of the bar. The Line on Close would be based on the charts tick size settings where the DataBox shows the actual value of the bar.

                          I look forward to being of further assistance.
                          Attached Files

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          571 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          330 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          101 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          548 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          549 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X