Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Renko bar timing

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

    Renko bar timing

    Hi,

    I am using Renko bars for strategy development. I noticed there is a time stamp on each bar, not sure if this time stamp signifies the completion of each bar. I would like to know if there is a command to call out the timing between say bar[0] and bar[3]?

    Please advise. Thanks.

    #2
    Welcome to our forums, yes the Time[x] method would give you access to the historical time stamp values of the bars. You can store the difference of Time[0] - Time[3] in a timepan variable and then print this for analysis.

    Comment


      #3
      Another question to add. Time[0]-Time[3] will give what format? I need the compare timing between the current bar and 3 bar ago and give a value in terms of minute.

      Example: If Time[0]-Time[3]< 3minute then {go long}, how do I code this into ninjascript? Cause the timing maybe 1101 at Time[0] and 1059 at Time[3]. Hope my question is clear. Thanks.

      Comment


        #4
        For this you can check the Duration method of the TimeSpan - much like :

        protected override void OnBarUpdate()
        {
        if (CurrentBar < 3) return;

        myTS = Time[0] - Time[3];

        Print(myTS.Duration().ToString());
        }

        For more info on the C# TimeSpan methods / Duration() please check : http://msdn.microsoft.com/en-us/libr....duration.aspx

        Comment


          #5
          TimeSpan Renko

          Hi Bertrand, thanks for posting this. I'm trying to do the same thing. The problem is I'm getting an error. I tried converting the myTS to a double and that didn't work either. Is there something missing to get it working? Thanks. DJ
          Attached Files

          Comment


            #6
            DJ, that error says you must first declare the variable before you can use it. I believe this variable should be of type TimeSpan, so please add this to your variables section:
            Code:
            private TimeSpan myTS;
            AustinNinjaTrader Customer Service

            Comment


              #7
              Renko Time Bars

              Thanks Austin that solved that issue. A couple of other issues have arisen now on this. Firstly I'm trying to put the time rounded to the nearest minute in the middle of the bar as a visual. This has resulted in the picture attached which looks like a dog's breakfast. So the first question is how would I round this to the nearest 0.5 minutes? For example, 1.5 or 20.5 minutes instead of what is appearing on the chart? I am using the following formula:

              DrawText("My text196"+CurrentBar ,false,(myTS.Duration().ToString()),0,((Open[0]+Close[0])/2),0,Color.Black,textFontSmall, StringAlignment.Center, Color.Transparent, Color.Transparent, 10);

              Normally I used "N0" but this is now not available with this timespan in the string.

              The second point is I am trying to say if the time of the last bar was less than 5 minutes then do something. I am using the following code and many different types of it but get compile errors. Could you please enlighten me on the format of this?

              myTS[0]<[00:00:05]

              Thanks in advance
              DJ
              Attached Files

              Comment


                #8
                DJ, for the rounding part, please check into this from MSDN here - http://social.msdn.microsoft.com/For...-36ae5a06710c/

                For your filtering condition, try something like

                if (myTS.Duration().Minutes < 5) ... do something ...

                Comment

                Latest Posts

                Collapse

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