Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Percentage of bar time left condition

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

    Percentage of bar time left condition

    I'm wanting an IF statement whose conditional logic is similar to:

    if (time.minutes left on bar <= 50%) then...

    How do I do this please including any declarations I need to make so as to be able to reference the time left.

    #2
    Hello dsfalc,

    Yes, there is Bars.PercentComplete that offers this.

    if (Bars.PercentComplete <= .50)
    {
    }
    Last edited by NinjaTrader_RyanM1; 08-24-2010, 04:40 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      In BarTimer there is a string: timeLeft. If BarTimer is also added ot the chart, is there a way I can access the value of this string from another piece of indicator code - present in a separate indicator added to the chart?.

      Comment


        #4
        Also, going to try using it - but wondering why PercentComplete not suggested.

        Comment


          #5
          It may be better to expose the TimeSpan object rather than the string. You can expose values from other indicators using the principles from this reference sample:
          Exposing indicator values that are not plots

          Good catch on PercentComplete - seems to offer exactly what you're looking for. Corrected my first reply.
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Thanks Ryan - appreciated

            One question. Am wanting to use the following line:
            TimeSpan barTimeLeft = Bars.Get(Bars.Count - 1).Time.Subtract(DateTime.Now);

            In the declarations - I already have:
            using System;

            do I need to declare anything else - and/or is the line with null in it - needing to be called for this function - first..

            Comment


              #7
              Hi dsfalc, no, it should be available with the System namespace - if you work with it in the OnBarUpDate the bars should be present, so you should not need a null check.

              Comment


                #8
                Just thought I'd piggyback on this thread instead of a new one.

                But if you were trading futures which in some cases can start or finish inside the hour, would Ninjatrader cope with that and reflect it in Bars.PercentComplete?

                eg CAC close at 1815. If you were looking at 1 Hr bars, would Ninjatrader know the final bar is only 15 minutes long?

                Comment


                  #9
                  Hi Zeeee,

                  This property should work the same even if bars don't trade evenly on the hour. It will depend on the time stamp of the bar though. If you want to define charts ending at 1815, this would be set in the session manager for version 7 or the Session End chart property for 6.5.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks, I don't want to have to bother with the session manager. I just want to set the strategy to 1 day, 2 day, or whatever and have it trade at the end of the bar without tedious coding.
                    Ta

                    edit, didn't realise I was in the indicator section here, came in via search. I am talking about a strategy, not an indicator.
                    Last edited by zeeee; 09-24-2010, 11:02 AM.

                    Comment


                      #11
                      The time stamp for the end of session bar will be based on the time defined in session manager. This is what PercentComplete is based on.
                      Ryan M.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      581 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      338 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      554 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      552 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X