Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time of duration of Renko bars

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

    Time of duration of Renko bars

    Hi everyone

    Renko bars are a great tool. They are necessarily time-independent.

    It is all too easy when judging a strategy on a Renko chart (or Range chart for that matter) not to take into account the fact that some of the trades indicated would never, in practice, get a good fill because the market is moving too fast.

    What I'm aiming for is to get my automated Renko-based strategies to reject a trade if the bar in question has formed too rapidly, or to have this information easily visible when trading on a discretionary basis. Trouble is, I don't know how to code this and I'm asking for some help with this.

    I'd therefore greatly appreciate some assistance with:

    a) how to code for the time that elapses from Close[1] to Close[0].

    b) ideally, I would like this figure (being the elapsed number of minutes and seconds) to appear in a box at the top right of the chart. Is this possible and if so, how would I code it?

    Many thanks in advance.

    #2
    Hi arbuthnot,

    Thanks for your note.

    To find the time between two bars.

    Time[0].Subtract(Time[1]).TotalSeconds.ToString();


    Would you only want the time of the last completed bar in this textbox?

    If so:

    DrawTextFixed("bartime", Time[0].Subtract(Time[1]).TotalSeconds.ToString(), TextPosition.TopRight);
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks, Chelsea, that's exactly what I was looking for!

      Previously, I'd looked in Help, in the Forum and googled and there's no way I would have found these solutions - that work great - in a finite amount of time! (Given time is what this thread is about...)

      I've looked up DrawTextFixed in Help and there are various ways you can adjust the parameters.

      I now see that the problem with putting the text in the Top Right is that the Chart Trader symbol can get in the way so Bottom Right could be a better idea.

      I may want to use or display information about other bars than the last completed bar but I'll play around with this and see what I can produce and post again if I get stuck.

      Much obliged, Chelsea.

      Comment


        #4
        Hi again

        I'm returning to this thread as I'm having a problem with coding the requirement that if the time between Close[0] and Close[1] for the current Renko bar is less than k number of seconds, then no trade is to be entered.

        This is how my code looks at the moment:

        Code:
        if(
        
        [I]...conditions...[/I]
        
        [B]&& Time[0].Subtract(Time[1]).TotalSeconds <=30[/B]
        
        )
        I want there to be no trade if the Renko bar is not longer than 30 seconds. When I use the code here, it compiles OK but weird things happen to the chart which aren't what I'm hoping for!

        Thanks in advance for any advice about this.

        Comment


          #5
          Hi arbuthnot,

          The code seems right. If you print the value before the condition is the total seconds showing correctly from the print?

          For example:
          Print(Time[0].Subtract(Time[1]).TotalSeconds);
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thanks very much, Chelsea. You said it should work - and it does!

            For anyone new to the Forum and NT, a good way to sort out a coding problem is to test it in the simplest possible manner.

            So I coded up a 'toy' indicator as follows:

            Code:
            if(     
                            Close[0] > Open[0]
                            && Time[0].Subtract(Time[1]).TotalSeconds >= 30
                            )
                        
                        {BarColor = Color.Blue;}
                        
                        if(     
                            Close[0] < Open[0]
                            && Time[0].Subtract(Time[1]).TotalSeconds >= 30
                            )
                        
                        {BarColor = Color.Red;}
            Loading this on a Renko chart, those bars lasting less than 30 seconds had unchanged Bar Color.

            I now know the problem lies with some lines of code other than

            Code:
            Time[0].Subtract(Time[1]).TotalSeconds
            Much obliged for your help.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            649 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            370 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            573 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            576 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X