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

Have to hit F5 refresh

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

    Have to hit F5 refresh

    Platform NT 7.0.0.17

    I have a relatively simple indicator that occasionally 'stutters' and stops painting bars.
    If I hit F5, the chat refreshes and everything looks good....until the next stutter.
    Everything else on the chart moves on per normal, but this indicator just occasionally stops painting bars.

    What did I do wrong????

    Code excerpt:

    protected override void Initialize()
    {
    Add(new Plot(new Pen(Color.Red, 6), PlotStyle.Bar, "AO (Negative)"));
    Add(new Plot(new Pen(Color.Green, 6), PlotStyle.Bar, "AO (Positive)"));
    Add(new Plot(Color.Transparent, PlotStyle.Line, "AO"));

    DrawOnPricePanel = false;
    CalculateOnBarClose = false;
    Overlay = false;
    PriceTypeSupported = false;

    fastline = new DataSeries(this);
    slowline = new DataSeries(this);
    }
    //==============================================
    protected override void OnBarUpdate()
    {
    if(CurrentBar == 0)
    {
    DrawHorizontalLine("Zero Line", true, 0, Color.DimGray, DashStyle.Solid, 1);
    ------ other code -------
    }

    ao = fastline[0]-slowline[0];
    if(ao>ao1)
    AOPos.Set(ao);
    else
    AONeg.Set(ao);
    {
    if(FirstTickOfBar)
    ao1=ao;
    }
    AOValue.Set(ao);
    }

    #2
    Hi photog53,

    Are you seeing any errors in the Log tab while running the indicator until it fails?

    Does setting CalculateOnBarClose =true; make any difference?

    Do you happen to be using MIN or MAX anywhere in your code? (there is a known bug)
    TimNinjaTrader Customer Service

    Comment


      #3
      Log:
      Checked the log....no errors related to this indicator.
      (I did find log errors for other activities...such as a reference to a strategy I deleted, and
      reference to a NT6 indicator I tired to import.....but nothing related to this code).

      Code change:
      I will try CalculateOnBarClose = true;

      Min/Max:
      Yes....this thing references various Moving Averages....(it plots the diff between 2 moving average
      lines)...and all of those make heavy use of Min/Max.

      Comment


        #4
        I believe you would not see an issue with COBC true, there are known issues with the MIN / MAX and COBC false in Beta 17, this will be fixed with Beta 18 - please retest your scenario then.

        Thanks
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks......

          Comment


            #6
            Has this min max issue been resolved?I have the same problem.

            Comment


              #7
              Hello outsource,

              Yes, this MIN/MAX issue has been resolved.

              Are you finding that MIN does not return the lowest value in a series for the given period (including the current bar with Calculate on bar close set to false)?

              Are you finding that MAX does not return the highest value in a series for the given period (including the current bar with Calculate on bar close set to false)?

              Do you have an example script (with no other code than what is necessary to demonstrate this) that I may test?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Hello outsource,

                Yes, this MIN/MAX issue has been resolved.

                Are you finding that MIN does not return the lowest value in a series for the given period (including the current bar with Calculate on bar close set to false)?

                Are you finding that MAX does not return the highest value in a series for the given period (including the current bar with Calculate on bar close set to false)?

                Do you have an example script (with no other code than what is necessary to demonstrate this) that I may test?
                Hi Chelsea,

                regardless of what the bar close is set to COBC = false or COBC = true.Also, regardless of the Autoscale is set to true or false.I have to left click on the chart or hit F5,to back the scalse in their place.I use percentages of the Y scale - 80% for upper scale,20% for lower scale.And sometimes the upper scale is being stuck in the middle of the chart until i left mouse click or hit F5.Then it comes back to its place.So the scale problem is still there!!!

                Here is the snippet code:

                Code:
                int lastY = ChartControl.GetYByValue( Bars, Close[0] );			
                double percentage = 100.0 - ( ( lastY * 100.0 ) / bounds.Height );
                How do i get the scales stable?

                Thank you
                Last edited by outsource; 04-21-2015, 03:46 PM.

                Comment


                  #9
                  Hello outsource,

                  Are you sure this is a related issue?

                  Are you using MIN() or MAX() in your code?
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_ChelseaB View Post
                    Hello outsource,

                    Are you sure this is a related issue?

                    Are you using MIN() or MAX() in your code?
                    No,i`m not sure if it`s related.There`s a line that uses max min,although it can be different things

                    Code:
                    public override void Plot( Graphics graphics, Rectangle bounds, double min, double max )
                    But,regardless of that,Chelsea,can we get back to the issue at hand,shall we?

                    Thank you.

                    Comment


                      #11
                      Originally posted by outsource View Post
                      Hi Chelsea,

                      regardless of what the bar close is set to COBC = false or COBC = true.Also, regardless of the Autoscale is set to true or false.I have to left click on the chart or hit F5,to back the scalse in their place.I use percentages of the Y scale - 80% for upper scale,20% for lower scale.And sometimes the upper scale is being stuck in the middle of the chart until i left mouse click or hit F5.Then it comes back to its place.So the scale problem is still there!!!

                      Here is the snippet code:

                      Code:
                      int lastY = ChartControl.GetYByValue( Bars, Close[0] );			
                      double percentage = 100.0 - ( ( lastY * 100.0 ) / bounds.Height );
                      How do i get the scales stable?

                      Thank you
                      Have you taken a look at this source code?

                      Comment


                        #12
                        Originally posted by sledge View Post
                        Have you taken a look at this source code?

                        http://www.ninjatrader.com/support/f...d=4&linkid=467
                        Yes,but i don`t want an artificial scale,i need Ninja scale,but so its value wouldn`t stick in the middle of the chart until you mouse click or hit F5,like i already said.

                        Comment


                          #13
                          Originally posted by outsource View Post

                          Here is the snippet code:

                          Code:
                          int lastY = ChartControl.GetYByValue( Bars, Close[0] );            
                          double percentage = 100.0 - ( ( lastY * 100.0 ) / bounds.Height );
                          How do i get the scales stable?

                          Thank you
                          If you wish to code a custom plot, you need to do it correctly. You can only access Close[0] in OnBarUpdate(), but not in public override void Plot().

                          The behaviour that you observe is the result of a flawed custom plot.

                          Comment


                            #14
                            Originally posted by Harry View Post
                            If you wish to code a custom plot, you need to do it correctly. You can only access Close[0] in OnBarUpdate(), but not in public override void Plot().

                            The behaviour that you observe is the result of a flawed custom plot.
                            It`s already in OnBarUpdate() section

                            Code:
                            protected override void OnBarUpdate()
                                    {
                            			
                            						
                            			BarColorSeries.Set( Math.Max( 0, CurrentBar + Math.Max( 0, Displacement ) + 
                            						( CalculateOnBarClose ? 1 : 0 ) ), Color.Transparent );
                            			CandleOutlineColorSeries.Set( Math.Max( 0, CurrentBar + Math.Max( 0, Displacement ) + 
                            						( CalculateOnBarClose ? 1 : 0 ) ), Color.Transparent );
                            						
                            			if( Historical || plottedBounds == null )
                            			{
                            				return;
                            			}
                            			
                            			Rectangle bounds = (Rectangle)plottedBounds;
                            			
                            			int lastY = ChartControl.GetYByValue( Bars, Close[0] );			
                            			double percentage = 100.0 - ( ( lastY * 100.0 ) / bounds.Height );
                            			
                            			
                            			if( percentage >= overbroughtPercentage )
                            			{
                            				if( !currentlyOverBrought )
                            				{
                            					currentlyOverBrought = true;
                            					sendNotifications( true );
                            				}
                            			}
                            			else
                            			{
                            				if( currentlyOverBrought )
                            				{
                            					sendNotifications( false );
                            					
                            				}
                            				currentlyOverBrought = false;
                            				
                            			}

                            Comment


                              #15
                              @Harry,

                              i got it.Yes, i have these line in the public override void Plot region:

                              Code:
                              Lines[0].Value = Instrument.MasterInstrument.Round2TickSize(min + (max - min)*(overbroughtPercentage/100));
                              Lines[1].Value = Instrument.MasterInstrument.Round2TickSize(min + (max - min)*(oversoldPercentage/100));
                              But,placing them under OnBarUpdate region doesnt work.

                              How would you place them in the OnBarUpdate section?An example?

                              Some of the additional parts,de bene esse:


                              protected override void Initialize()
                              Code:
                              {
                              Add(new Line(Color.DarkGreen, 0, "OverboughtAlertLine"));
                              Add(new Line(Color.DarkRed, 0, "OversoldAlertLine"));
                              Overlay = true;
                              BarsRequired = 0;			
                              AutoScale = false;
                              			
                               }
                              #region Variables

                              Code:
                              private double overbroughtPercentage = 100;
                              private double oversoldPercentage = 0;

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              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  
                              Started by samish18, Yesterday, 08:31 AM
                              2 responses
                              9 views
                              0 likes
                              Last Post elirion
                              by elirion
                               
                              Started by Mestor, 03-10-2023, 01:50 AM
                              16 responses
                              391 views
                              0 likes
                              Last Post z.franck  
                              Working...
                              X