• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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

        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 Trader_Kim, Yesterday, 03:41 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChristopherD  
          Started by MarthaClines, Yesterday, 06:23 PM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Started by DrDave, Today, 06:42 AM
          1 response
          2 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by kevinenergy, Today, 06:16 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by zhiga, Today, 12:54 AM
          1 response
          15 views
          0 likes
          Last Post NinjaTrader_PaulH  
          Working...
          X