Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Check if chart is Minute based

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

    Check if chart is Minute based

    I am developing an indicator that requires minute bars and no other periodicity will work. How and where can I check that? I see that in the BuySellPressure Indicator example, it is being checked in State.DataLoaded. However this is not working for me:

    Code:
    if (State == State.DataLoaded)
            if (BarsPeriodType == BarsPeriodType.Minute)
            {
                Draw.TextFixed(this, "tag1", "Chart must be a minute based chart.", TextPosition.BottomRight); 
            }
    }
    My two questions are:

    a.) is this the right place to check and
    b.) is there some other way since this is returning an error: 'NinjaTrader.Data.BarsPeriodType' is a 'type' but is used like a 'variable'

    #2
    Hello swcooke,

    Thank you for the post.

    I wanted to check, where did you find this syntax specifically? I do not see this in the BuySellPressure indicator but I do see this is used in the ImportTypes which would make sense as to why you are getting this error. This is not a variable an Indicator would inherit so this would not be able to be used like shown from an indicator.

    You could use something like the following:

    Code:
    Print(Bars.BarsPeriod.BarsPeriodTypeName);
    This would print "Minute" for a Minute type bar series. This should also be fine to use from DataLoaded however Historical or Realtime could also be used here. You may additionally look at the BarTimer and its check:

    Code:
    if (Bars.BarsType.IsTimeBased && Bars.BarsType.IsIntraday)
    I look forward to being of further assistance.

    Comment


      #3
      Hi Jesse,

      I should have mentioned that I was referring to the concept of displaying the text rather than the actual condition. The condition in BuySellPressure is checking to make sure that Calculate == Calculate.OnEachTick. Can you confirm that State.DataLoaded is the recommended place to check? In thinking about this further, should I just check right inside OnBarUpdate and return from OnBarUpdate if the condition tests true? Any downsides to this?
      Last edited by swcooke; 03-26-2019, 08:19 AM.

      Comment


        #4
        Hello swcooke,

        If the point is to draw text, I would suggest moving this to OnBarUpdate like you noted and also return to prevent logic if that is the overall goal. That just reduces the number of times this logic is being used as it seems the overall use is going to target OnBarUpdate. I don't see any reason why this would have a downside being used from OnBarUpdate for this use case.


        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

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