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

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 algospoke, Yesterday, 06:40 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post algospoke  
                              Started by ghoul, Today, 06:02 PM
                              3 responses
                              14 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              44 views
                              0 likes
                              Last Post jeronymite  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              7 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              10 responses
                              180 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X