• 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

Working with two types of charts

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

    Working with two types of charts

    Hello, please help to solve the problem. I add three multiple charts and an additional unirenko chart type to the strategy.

    Add(indicator);
    Add(second_instr, BarsPeriod.Id, BarsPeriod.Value);
    Add(third_instr, BarsPeriod.Id, BarsPeriod.Value);
    Add(PeriodType.Custom5, 002004002);

    In "OnBarUpdate"
    if (BarsInProgress != 0) return;

    And when I try to call the data of Renko bars the strategy does not react or reacts incorrectly

    For example
    if(Opens[3][1] < Closes[3][1] && Opens[3][0] > Closes[3][1])
    {
    ........
    }

    It's not working

    In addition, when I call in "Print" opens[3][0] and closes[3][0], the closes price is true, and the opens is not

    In this regard, there is a question - how to call the Renko data in the strategy
    Forgot to add, I'm using CalculateOnBarClose = false; Maybe this causes problems, although the open price should still remain unchanged

    #2
    Hello Kovalev,

    Custom bar types are not officially supported for NinjaTrader 7 (but are supported for NinjaTrader 8) so there isn't any information in the help guide about adding a custom series.

    Are there any errors appearing on the Log tab of the Control Center when running the script?


    When printing the Opens[3][0], is this returning a 0?


    Below is a link to another forum thread where users are discussing this.
    https://ninjatrader.com/support/foru...-unirenko-bars
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello Kovalev,

      Are there any errors appearing on the Log tab of the Control Center when running the script?

      When printing the Opens[3][0], is this returning a 0?
      Hello NinjaTrader_Chelsea, no, the logs are absolutely clean. As far as I understand, the program does not see any errors, but for some reason it takes the wrong price data, as if I'm making some kind of error when calling. Because the opening price is shown of that instrument, but it is not the price of opening the Renko bar to which it belongs

      Comment


        #4
        Originally posted by Kovalev View Post
        Hello, please help to solve the problem. I add three multiple charts and an additional unirenko chart type to the strategy.

        Add(indicator);
        Add(second_instr, BarsPeriod.Id, BarsPeriod.Value);
        Add(third_instr, BarsPeriod.Id, BarsPeriod.Value);
        Add(PeriodType.Custom5, 002004002);

        In "OnBarUpdate"
        if (BarsInProgress != 0) return;

        And when I try to call the data of UniRenko bars the strategy does not react or reacts incorrectly

        For example
        if(Opens[3][1] < Closes[3][1] && Opens[3][0] > Closes[3][1])
        {
        ........
        }

        It's not working

        In addition, when I call in "Print" opens[3][0] and closes[3][0], the closes price is true, and the opens is not

        In this regard, there is a question - how to call the UniRenko data in the strategy
        Forgot to add, I'm using CalculateOnBarClose = false; Maybe this causes problems, although the open price should still remain unchanged
        Always type out "UniRenko", because "Renko" and "UniRenko" are NOT the same thing.

        Originally posted by Kovalev View Post
        In addition, when I call in "Print" opens[3][0] and closes[3][0], the closes price is true, and the opens is not
        That is correct. The UniRenko BarType (like all Renko-based bars) lie about the Opening price of the bar.

        Originally posted by Kovalev View Post
        Forgot to add, I'm using CalculateOnBarClose = false; Maybe this causes problems, although the open price should still remain unchanged
        Are you using "FirstTickOfBar" to examine EndOfBar values?
        Or are you specifically trying to access Open and Close price on every tick?

        When using COBC=False, such code should be segregated,

        Code:
        protected override void OnBarUpdate()
        {
            if (BarsInProgress == 3)
            {
                if (Historical)
                    /* do nothing -- this example utilizes tick information in real-time */ ;
        
                else if (CalculateOnBarClose)
                {
                    ... here Opens[3][0] is open of most recently closed UniRenko bar
                    ... here Closes[3][0] is close of most recently closed UniRenko bar
                }
        
                else
                {
                    ... here Opens[3][0] is open of current UniRenko bar being built
                    ... here Closes[3][0] is close of current UniRenko bar being built
                    ... here Opens[3][1] is open of most recently closed UniRenko bar
                    ... here Closes[3][1] is close of most recently closed UniRenko bar
                    if (FirstTickOfBar)
                    {
                        ... previous UniRenko bar has just closed
                        ... use Opens[3][1] and Closes[3][1] to access previous bar that just closed
                    }
                    else
                    {
                        ... this section runs on every tick for UniRenko bar series
                        ... use Opens[3][0] and Closes[3][0] to access current bar still being built
                        ... use Opens[3][1] and Closes[3][1] to access previous bar that just closed
                    }
                }
            }
        }
        Last edited by bltdavid; 06-10-2019, 04:35 PM.

        Comment


          #5
          Originally posted by bltdavid View Post

          That is correct. The UniRenko BarType (like all Renko-based bars) lie about the Opening price of the bar.
          That's news to me, thanks for the tip.

          Originally posted by bltdavid View Post
          Always type out "UniRenko", because "Renko" and "UniRenko" are NOT the same thing.
          I did not specify the type of Renko bars because I believed that they all obey the same laws.

          bltdavid, Thank you very much for your help, I did not use FirstTickOfBar, most likely this is my mistake

          Comment


            #6
            I adjusted my code example -- sorry, previous example was wrong.

            Note how when CalculateOnBarClose is True, you use 0 as the index for the most recent closed bar.

            When false, you must use 1 as the index.

            FirstTickOfBar is used to differentiate when a bar has closed.

            Comment


              #7
              Assuming all you care about is COBC=False, here is a slightly better example,

              Code:
              protected override void OnBarUpdate()
              {
                  ...
                  if (BarsInProgress == 3)
                  {
                      if (Historical || CalculateOnBarClose)
                          /* do nothing -- this example utilizes tick information in real-time */ ;
              
                      else
                      {
                          if (FirstTickOfBar)
                          {
                              ... previous UniRenko bar has just closed
                              ... use Opens[3][1] and Closes[3][1] to access previous bar that just closed
                          }
                          else
                          {
                              ... this section runs on every tick for UniRenko bar series
                              ... use Opens[3][0] and Closes[3][0] to access current bar still being built
                              ... use Opens[3][1] and Closes[3][1] to access previous bar that just closed
                          }
                      }
                  }
                  ...
              }
              Last edited by bltdavid; 06-10-2019, 04:44 PM.

              Comment


                #8
                bltdavid, thank you very much for your detailed answer, your help is invaluable!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by akitenge, 06-14-2019, 02:54 PM
                4 responses
                28 views
                0 likes
                Last Post chartish  
                Started by siriusm, Today, 09:15 AM
                2 responses
                12 views
                0 likes
                Last Post siriusm
                by siriusm
                 
                Started by Duval, Today, 09:27 AM
                3 responses
                9 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by chazyang, Today, 08:11 AM
                2 responses
                9 views
                0 likes
                Last Post chazyang  
                Started by Erwin Beckers, 11-04-2018, 02:39 AM
                6 responses
                79 views
                2 likes
                Last Post koganam
                by koganam
                 
                Working...
                X