Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicator jumps around ?

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

    indicator jumps around ?

    please ignore this thread. I have to fix something then maybe resubmit it
    Attached Files
    Last edited by joemiller; 08-26-2013, 07:28 AM. Reason: want to rethink this

    #2
    indicator jumps around

    The redline indicator shown in the attachments is a function of the previous bar open and close. Those open and close values never change, yet the last segment of the indicator jumps around as shown in the two attachments. Any comments or suggestions will be appreciated.
    Attached Files

    Comment


      #3
      Hi joe,

      What are you indicator values based on? Do you mean they are Close[1] and Open[1]?

      Do you have a sample of code you can post which demonstrates this behavior?
      MatthewNinjaTrader Product Management

      Comment


        #4
        thanks Matthew

        the indicator file is attached.
        the code which creates the indicator is as follows:

        if(BarsPeriod.Id == PeriodType.Day)//for day bars [don't use GetDayBar for day bars]
        {
        XXCloseyest=((Open[1]+High[1]+Low[1]+Close[1])*0.25);
        XXOpen=((XXCloseyest+XXOpenyest)*0.5);
        XXOpenyest=XXOpen; //this will be used on next bar, when at that time it will be XXOpenyest
        }
        Attached Files

        Comment


          #5
          Hi Joemiller,

          I'm not seeing any errors with the compile and code.

          Are you seeing this with all your charts and instruments or just this one in particular?

          I see you are using the Print() for your values, are they correct ones being plotted?

          What are you setting the Calculate on Bar Close to?
          Cal H.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by joemiller View Post
            thanks Matthew

            the indicator file is attached.
            the code which creates the indicator is as follows:

            if(BarsPeriod.Id == PeriodType.Day)//for day bars [don't use GetDayBar for day bars]
            {
            XXCloseyest=((Open[1]+High[1]+Low[1]+Close[1])*0.25);
            XXOpen=((XXCloseyest+XXOpenyest)*0.5);
            XXOpenyest=XXOpen; //this will be used on next bar, when at that time it will be XXOpenyest
            }
            Code:
            XXOpen=((XXCloseyest+XXOpenyest)*0.5);
            XXOpenyest=XXOpen; //this will be used on next bar, when at that time it will be XXOpenyest
            That block of code, when you use COBC=false, is effectively a loop, changing the value of XXOpenyest on each tick, and hence also changing the value of XXOpen.

            Remember that OnBarUpdate(), while an event-handler, is at base, a loop construct. We often forget that the whole paradigm of event-driven programing is to process messages in either a loop, or based on an interrupt scheme.
            Last edited by koganam; 08-26-2013, 06:40 PM.

            Comment


              #7
              damn, I don't have a clue what you said but, no matter, I do think it sounds like I may somehow be able to correct the issue by finding some way to preserve XXOpenyest. because I think I have to Keep COBC = false?

              if you guys have any suggestions I will be eternally grateful.

              Comment


                #8
                Cal,
                forgot to answer your questions.

                Are you seeing this with all your charts and instruments or just this one in particular?
                ALL CHARTS

                I see you are using the Print() for your values, are they correct ones being plotted?
                LOOKS LIKE THEY ARE THE SAME ... THE OUTPUT WINDOW KEEPS UPDATEING WITH INCOMING PRICE FEED.

                What are you setting the Calculate on Bar Close to?
                DIDN'T KNOW I SHOULD SPECIFY ANYTHNG BEYOND COBC = FALSE?
                Last edited by joemiller; 08-26-2013, 05:51 PM.

                Comment


                  #9
                  Joemiller,

                  You can set the indicator to calculate on bar close set to true when you first enable the indicator on the chart.

                  I will agree with Koganam that your variable is most likely getting reset over and over with the indicator set to false, thus causing the indicator to act the way you see it from the screenshots.

                  Let me know if I can be of further assistance
                  Cal H.NinjaTrader Customer Service

                  Comment


                    #10

                    CalculateOnBarClose is set
                    false in the initialize region of the indicator to force last day display of the indicator.

                    do you mean I should set it to true ... because if I do I think the indictor will not be displayed on the last currently developing bar, which is what I need?

                    Comment


                      #11
                      Joemiller,

                      You can try using FirstTickOfBar in your condition to preserve the variable so that it does not keep getting updated over and over in the OBU.

                      Let me know if this works for you
                      Cal H.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by joemiller View Post

                        CalculateOnBarClose is set
                        false in the initialize region of the indicator to force last day display of the indicator.

                        do you mean I should set it to true ... because if I do I think the indictor will not be displayed on the last currently developing bar, which is what I need?
                        In which case, all you are really saying is that you want your code block to be run only once per bar, even though you are processing every tick. There is more than one way to do that using a bool flag, but NT actually already provides a ready-made flag called FirstTickOfBar, which is just what it says. Just encase your block and use FirstTickOfBar as a filter.
                        Code:
                        [B][SIZE=3][COLOR=#000000][FONT=Calibri]if(BarsPeriod.Id == PeriodType.Day)//for day bars [don't use GetDayBar for day bars] [/FONT][/COLOR][/SIZE][/B]
                        [B][SIZE=3][COLOR=#000000][FONT=Calibri]{[/FONT][/COLOR][/SIZE][/B]
                        [COLOR=Red][B]if (FirstTickOfBar)
                        {[/B][/COLOR]
                        [B][SIZE=3][COLOR=#000000][FONT=Calibri]XXCloseyest=((Open[1]+High[1]+Low[1]+Close[1])*0.25);[/FONT][/COLOR][/SIZE][/B]
                        [B][SIZE=3][COLOR=#000000][FONT=Calibri]XXOpen=((XXCloseyest+XXOpenyest)*0.5);[/FONT][/COLOR][/SIZE][/B]
                        [B][SIZE=3][COLOR=#000000][FONT=Calibri]XXOpenyest=XXOpen; //this will be used on next bar, when at that time it will be XXOpenyest[/FONT][/COLOR][/SIZE][/B]
                        [COLOR=Red][B]}[/B][/COLOR]
                        [B][SIZE=3][COLOR=#000000][FONT=Calibri]} [/FONT][/COLOR][/SIZE][/B]

                        Comment


                          #13
                          problem solved


                          "if (FirstTickofBar)" made the problem go away.

                          As so many times before, much appreciated and many thanks.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Waxavi, Today, 02:10 AM
                          0 responses
                          3 views
                          0 likes
                          Last Post Waxavi
                          by Waxavi
                           
                          Started by TradeForge, Today, 02:09 AM
                          0 responses
                          8 views
                          0 likes
                          Last Post TradeForge  
                          Started by Waxavi, Today, 02:00 AM
                          0 responses
                          2 views
                          0 likes
                          Last Post Waxavi
                          by Waxavi
                           
                          Started by elirion, Today, 01:36 AM
                          0 responses
                          4 views
                          0 likes
                          Last Post elirion
                          by elirion
                           
                          Started by gentlebenthebear, Today, 01:30 AM
                          0 responses
                          4 views
                          0 likes
                          Last Post gentlebenthebear  
                          Working...
                          X