Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    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.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by funk10101, Today, 09:43 PM
        0 responses
        6 views
        0 likes
        Last Post funk10101  
        Started by pkefal, 04-11-2024, 07:39 AM
        11 responses
        37 views
        0 likes
        Last Post jeronymite  
        Started by bill2023, Yesterday, 08:51 AM
        8 responses
        44 views
        0 likes
        Last Post bill2023  
        Started by yertle, Today, 08:38 AM
        6 responses
        26 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        24 views
        0 likes
        Last Post algospoke  
        Working...
        X