• 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

Indicator disappears from the chart

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

    Indicator disappears from the chart

    I am developing a tool for NinjaTrader 7 , however the indicator is disappearing from the graph and the following message appears in log: " Error Plotting indicator " DynamicDOM "Please check the ' OnBarUpdate ' or ' Plot' method . .
    All the code compiles without errors and this part is within the method Plot.
    Below is part of the code within the method Plot.

    Code:
            protected override void Initialize()
            {
                CalculateOnBarClose	= false;
             }
    	
            protected override void OnStartUp()
            {
    	}
    
            protected override void OnBarUpdate()
            {
             }
    
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
             {
    	        int left, top, whidh, heigh, border;
    		left = 13;
    		top = 25;
    		whidh = 55;
    		heigh = 18;
    		border = 2;	
                   
                    foreach ( LadderRow item in askRows )
                    {
                            graphics.DrawString ( "" + askRows [ 15 ] .Price , font , brush , new Point ( (left + whidh ) (top + heigh ))) ;
                            graphics.DrawString ( "" + askRows [ 15 ] .Volume , font , brush , new Point ( (top 5 * ) (top + heigh ))) ;
                     }
    }

    Thank you all
    Last edited by Jonatan Allan; 05-26-2016, 03:11 PM.

    #2
    Hi Jonatan Allan,

    What is the full error message?

    This error occurs the moment the indicator is applied to the chart?

    Have you added any prints to see what line is causing the error?
    If so, what line is causing the error?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      In fact within the Plot method I have two " foreah " and each " foreach " I have 16 calls graphics.DrawString method () ;.
      Ie two " foreach " and 32 calls graphics.DrawString () method ; Plot within the method .
      I need to print price values ​​in String format. But if there is another way to do this I'm open.

      Comment


        #4
        Hello Jonatan Allan,

        You can use DrawText() or DrawTextFixed() in OnBarUpdate().
        (You can do this in a loop too)

        DrawText() - http://ninjatrader.com/support/helpG...7/drawtext.htm

        DrawTextFixed() - http://ninjatrader.com/support/helpGuides/nt7/drawtextfixed.htm

        This is generally how text boxes are added to a chart.


        That said, this doesn't address which exact line is causing the error and what the exact error is. There isn't enough information in the code you have posted to tell what the error is. Most variables are not declared in the code you have posted.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Following is a table image in the chart . each rectangle I need to write the price and volume. You could describe me an example? Thank you.
          Attached Files

          Comment


            #6
            Hello Jonatan Allan,

            For something custom and complicated like this, it may be better to do this with custom rendering in the Plot override.

            I will not be able to code this logic to draw these items on your behalf, however, this thread will remain open for any community members that would like to code this for you.

            If you would like, I can create a very simplified example that demonstrates how to draw a single rectangle and draw text on this. Would you like a simplified example?


            That said, with the code you have in the Plot override, what is the exact error you are getting and what line is generating the error?
            Last edited by NinjaTrader_ChelseaB; 05-27-2016, 09:37 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I would greatly appreciate it for a simple and practical example, it would help me a lot. Thank you for your attention once again follows an image of the error generated in the first row .
              Attached Files

              Comment


                #8
                Hello Jonatan Allan,

                The error part in spanish appears to say invalid parameter.

                This might mean that one of the variables being supplied to the graphics.DrawText() is not the correct parameter.

                What are the values of these variables that are being supplied to the graphics.DrawText() call? Can you print these in the output window so that we can see what is being provided to this call?

                I'm currently creating an example for you to demonstrate drawing a rectangle and text box over the rectangle.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I 'm not using graphics.Draw.Text ( ) , but graphics.DrawString (); And the example with the variables station below. To create the rectangle am using graphics.DrawRectangle ();

                  I'm expecting a simplified example remember? Thank you for your support.
                  here's part of the code

                  Code:
                   public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
                           {
                  			int left, top, whidh, heigh, border;
                  			left = 13;
                  			top = 25;
                  			whidh = 55;
                  			heigh = 18;
                  			border = 2;		
                  						
                  		    //Fill Bid
                  			graphics.FillRectangle(new SolidBrush(color_bid), left, top, whidh, heigh);
                  		    //Fill Price
                  			graphics.FillRectangle(new SolidBrush(color_price), (left + whidh), top, whidh, heigh);
                  		    //Fill Ask
                  			graphics.FillRectangle(new SolidBrush(color_ask), (left + (whidh * 2)), top, whidh, heigh);
                  			
                  			//Background Cels Bid
                  		    graphics.FillRectangle(new SolidBrush(color_fill),   left, (top + heigh), whidh, heigh * 32);
                  			//Background Cels Price
                  			graphics.FillRectangle(new SolidBrush(color_fill),   (left + whidh), (whidh - left), whidh, (heigh * 32));
                  			//Background Cels Ask
                  			graphics.FillRectangle(new SolidBrush(color_fill),  (left + whidh * 2), (top + heigh), whidh,  (heigh * 32));
                  			
                  		    //Legend Bid
                  			graphics.DrawRectangle(new Pen(Color.Black, border),    left, top, whidh, heigh);
                              graphics.DrawString("" + "Bid", font, brush, new Point((left * 2), top));
                  			
                  			//Legend Price
                  			graphics.DrawRectangle(new Pen(Color.Black, border),     (left + whidh), top, whidh, heigh);
                              graphics.DrawString("" + "Price", font, brush, new Point((top + whidh), top));
                  			
                  			//Legend Ask
                  			graphics.DrawRectangle(new Pen(Color.Black, border),  (left + (whidh * 2)), top, whidh, heigh);
                              graphics.DrawString("" + "Ask", font, brush, new Point((top + (whidh * 2)), top));
                  }

                  Comment


                    #10
                    Hello Jonatan Allan,

                    That was my mistake, I did mean graphics.DrawString().

                    I am currently creating an example for you.

                    Did you add the prints to your code as requested? May we see the output from the output window showing the values of the variables being called?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Is there any way to post the code so that only you can see it? As this is a project I'm developing.

                      Comment


                        #12
                        Hi Jonatan,

                        If you would like to keep any code private, send an email to platformsupport [at] ninjatrader [dot] com. In the email include a link to this forum thread.

                        Attached to this post is a simple example that I have created of drawing text in a rectangle.
                        Attached Files
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Thank you. I will examine the example .

                          Comment


                            #14
                            This example works in NT7 ?

                            Comment


                              #15
                              Hi Jonatan,

                              That was my mistake. I made that example for NT8.

                              Here is the example for NT7.
                              Attached Files
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Vincere, Today, 01:59 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post Vincere
                              by Vincere
                               
                              Started by Davoone1, Yesterday, 07:28 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_ChrisSch  
                              Started by Bobisam, Yesterday, 10:53 PM
                              1 response
                              6 views
                              0 likes
                              Last Post Bobisam
                              by Bobisam
                               
                              Started by quantera, Yesterday, 05:38 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post quantera  
                              Started by ciro1963, Yesterday, 03:58 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post ciro1963  
                              Working...
                              X