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

Checking BarsPeriod.BarsPeriodType

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

    Checking BarsPeriod.BarsPeriodType

    Inside of my OnRender() I only want to do stuff if the chart Periodicity is a minute based chart. Otherwise, don't do anything. Here is what I've tried:
    Code:
       if(BarsPeriod.BarsPeriodType.ToString() == "Minute"){ 
         Print(BarsPeriod.BarsPeriodType.ToString())
         // do stuff
       }
    It prints out "Minute" regardless of whether I am on a Minute, Tick or Range chart. What am I doing wrong? Please note that I have added additional 1 minute bars objects to the chart however, the doc's indicate this is checking the Primary Bars object and not any of the additional bars objects.

    #2
    Hellow swcooke,

    Thank you for your note.

    If you were to use,

    Code:
    BarsPeriod.BarsPeriodType == BarsPeriodType.Minute)
    Does the filter work as expected?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      I replaced my condition with yours and it still does not work. Very strange. This seems pretty straight forward. Any other suggestions would be appreciated.

      Comment


        #4
        Hello swcooke,

        I have attached a sample which will draw "Text1" at the bottom of a chart only when its a minute chart.

        To test I suggest applying the indicator, and toggling between a daily series and a minute series.

        Please let us know if you need further assistance.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          In your State.Configure block, add another data series like this and you'll see the issue I am having:
          Code:
          AddDataSeries("XLK",BarsPeriodType.Minute,1);
          Then test. You'll see that your green text flashes on and off on a tick chart or range chart. Seems like BarsPeriod.BarsPeriodType is referring to the secondary data series at certain times. The docs indicate it only returns this info on the primary bars object. Thoughts?

          Comment


            #6
            Hello swcooke,

            You could prevent BarsInProgress 1 from calling on render.

            If you add the following at the top of OnRender, does that resolve the issue?

            Code:
            if(BarsInProgress!=0) return;
            I look forward to your reply.
            Attached Files
            Alan P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by timmbbo, Today, 08:59 AM
            1 response
            2 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by KennyK, 05-29-2017, 02:02 AM
            2 responses
            1,279 views
            0 likes
            Last Post marcus2300  
            Started by fernandobr, Today, 09:11 AM
            0 responses
            0 views
            0 likes
            Last Post fernandobr  
            Started by itrader46, Today, 09:04 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by bmartz, 03-12-2024, 06:12 AM
            5 responses
            33 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Working...
            X