Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Possible bug or am I missing something?

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

    Possible bug or am I missing something?

    Scenario:

    I add an additional 1 tick time frame using: Add(PeriodType.Tick, 1); Works fine.

    My code wasn't working correctly so I put in a Print to see the values.

    protected override void OnBarUpdate()
    {
    Print("TimeFrame3 " + BarsInProgress + " " + BarsPeriod.Id + " " + BarsPeriod.Value);
    .. user code

    I added the time frame as 1 tick in "Initialize" but BarsPeriod.Id shows as "Range".
    Below is the log from the Print. The "0" BarsInProgress is the chart timeframe and the "1'" BarsInProgress is my added timeframe.

    TimeFrame3 0 Range 1
    TimeFrame3 1 Range 1
    TimeFrame3 0 Range 1
    TimeFrame3 1 Range 1
    TimeFrame3 0 Range 1
    TimeFrame3 1 Range 1
    TimeFrame3 0 Range 1
    TimeFrame3 1 Range 1
    TimeFrame3 0 Range 1
    TimeFrame3 1 Range 1
    TimeFrame3 0 Range 1

    Question:
    Why does my added timeframe show as "Range"? Does tick not support "BarsPeriod.Id"? How can I tell if a tick was from my 1 added tick timeframe? It works fine on just 1 chart time frame but if the user adds an additional chart time frame (which I have no control over) the BarsInProgress changes to 2 for my added time frame and "0" and "1" are used by the chart time frames.

    Cheers
    Last edited by ct; 02-19-2019, 01:54 PM.

    #2
    You are printing the BarsPeriod.Id of the primary series.
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment


      #3
      Originally posted by eDanny View Post
      You are printing the BarsPeriod.Id of the primary series.
      Duh! thanks.

      Comment


        #4
        Hello ct,

        Thanks for your question.

        BarsPeriod is reflective of the primary data series. If you would like to reference the BarsPeriod for the iterating data series, I would suggest to use Bars.Period instead.

        For example:

        Code:
        protected override void Initialize()
        {
            Overlay                = false;
            Add("ES 03-19", PeriodType.Range, 5);
            Add("ES 03-19", PeriodType.Tick, 150);
        }
        
        protected override void OnBarUpdate()
        {
            if (BarsInProgress == 0)
            {
                Print(String.Format("BarsInProgress: {0} Bars.Period.Id: {1} Bars.Period.Value: {2}", BarsInProgress, Bars.Period.Id, Bars.Period.Value));
            }
            else if (BarsInProgress == 1)
            {
                Print(String.Format("BarsInProgress: {0} Bars.Period.Id: {1} Bars.Period.Value: {2}", BarsInProgress, Bars.Period.Id, Bars.Period.Value));
            }
            else if (BarsInProgress == 2)
            {
                Print(String.Format("BarsInProgress: {0} Bars.Period.Id: {1} Bars.Period.Value: {2}", BarsInProgress, Bars.Period.Id, Bars.Period.Value));
            }
        }
        Please let me know if you have any additional questions.

        Comment


          #5
          Or, without using BarsInProgress you could use BarsArray[1].Period.Id and BarsArray[1].Period.Value.
          eDanny
          NinjaTrader Ecosystem Vendor - Integrity Traders

          Comment

          Latest Posts

          Collapse

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