Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with draw.text

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

    #16
    Hello Mark,

    Thanks for your reply.

    I've attached an example of how you can use draw.TextFixed to display 4 seperate lines with different colors. Add this to a chart with real time data.

    DrawtextFixedColorexample.zip


    In terms of the market analyzer, all you need is a plot for each variable. The market analyzer can work with plot values.


    Comment


      #17
      Thanks Paul, very much appreciated.

      Comment


        #18
        Hello All, I am continuing my quest to learn more about, what appears to be simple formatting. PaulH had helped me tremendously (thanks) . The goal
        To use 3 Draw.TextFixed statements to draw a status notification of three variables.

        Paul had provided me with this, which works fine

        Draw.TextFixed(this,"status1", "Stat1 is Red ", TextPosition.Center,Brushes.Red, ChartControl.Properties.LabelFont,Brushes.Transpar ent,Brushes.White,0);

        Draw.TextFixed(this,"status2", "Stat2 is Green", \nTextPosition.Center,Brushes.Green, ChartControl.Properties.LabelFont,Brushes.Transpar ent,Brushes.White,0);

        Draw.TextFixed(this,"status3", "Stat3 is Red ", \n\nTextPosition.Center,Brushes.Red, ChartControl.Properties.LabelFont,Brushes.Transpar ent,Brushes.White,0);

        This leaves out the drawing of the text box and area fill which I am hoping to be able to add so that a quicker visual can be taken when preparing to enter. If I change
        the Brushes.Transparent to a color what appears to happen is the text boxes grow in height due to the \n's and the previous text is blocked out.
        Question - How can I use formatting to produce three Draw.TextFixed Outputs to the same screen location with Shaded Text boxes.

        The desired look is this
        Last edited by markbb10; 05-15-2020, 07:50 AM.

        Comment


          #19
          Hello markbb10,

          Thanks for your reply.

          Draw.TextFixed is limited in its functionality and was originally intended to place just one line of text. You can try using various amount of escape codes (\n) to see if you can achieve your desired goal but I suspect using the outline may not get what you need.

          Alternatively, you may want to look at using Draw.Text() which does offer other alignment options and a pixel offset for perhaps better adjustment: https://ninjatrader.com/support/help.../nt8/?text.htm A limitation here is that you would have to decide where at to draw the text relative to the display. Likely you would have to draw relative to the height of the current candle.

          A better alternative would be to create the text and draw the box(s) directly in the OnRender() method. This would allow you to draw the box in the chart at a consistent location, however it require a great deal more coding to implement. To get an idea of this type coding you can review the indicator "Sample custom render". Here is a link to the OnRender() method help guide: https://ninjatrader.com/support/help.../?onrender.htm

          Comment


            #20
            Thanks Paul, I will check it out. I have it working with Draw.Text but the indications move are the screen with the offset I have it tied to (candle) this is not workable from what I can see. I will soldier on, who ever thought it would be so difficult to draw 3 lines of text on a chart at a fixed location lol.. Thanks again

            Comment


              #21
              Hello markbb10,

              Thanks for your reply.

              I forgot to mention another alternative which is to use plots in an indicator panel. Plots do not have to be lines, they can be triangles, squares, dots. You could plot, bar by bar, a symbol for each condition and color it as you wish. Because you are plotting it in an indicator panel, you can control the y axis values, meaning for example condition 1 is always printed at a value of say 1, Condition 2 at a value of 2, condition 3 at 3 and so on. This will provide a consistent level of objects bar by bar. You can change the color of any given plot to indicator the status you want to indicate. I've attached an example screenshot.

              Click image for larger version

Name:	markbb10-1.PNG
Views:	607
Size:	25.7 KB
ID:	1099910

              Comment


                #22
                Thanks Paul, really appreciate your time and all the direction. - Mark

                Comment


                  #23
                  Originally posted by NinjaTrader_PaulH View Post
                  Hello markbb10,

                  Thanks for your reply.

                  I forgot to mention another alternative which is to use plots in an indicator panel. Plots do not have to be lines, they can be triangles, squares, dots. You could plot, bar by bar, a symbol for each condition and color it as you wish. Because you are plotting it in an indicator panel, you can control the y axis values, meaning for example condition 1 is always printed at a value of say 1, Condition 2 at a value of 2, condition 3 at 3 and so on. This will provide a consistent level of objects bar by bar. You can change the color of any given plot to indicator the status you want to indicate. I've attached an example screenshot.

                  Click image for larger version  Name:	markbb10-1.PNG Views:	123 Size:	25.7 KB ID:	1099910
                  HI Paul, could you please elaborate how to use dots or blocks in an indicator panel.
                  What I intend to do in a strategy:
                  Set 3 Trendfilters and 3 Entry signals. To visualise the conditions, I would like to use blocks or dots. in total 6 lines. If condition1 is valid: green dot. if not: red dot, otherwise: no dot. How do I do that? Do you have an code example how to use dots in a indicator panel and colour them as you described it?

                  Thanks a lot in advance

                  Comment


                    #24
                    Hello guw75,

                    Thanks for your post.

                    A strategy cannot create an indicator panel. <= This statement is incorrect, please see post #31 for explanation and example.

                    You would need to create your conditions in an indicator if you want to get that type of display in an indicator panel.

                    I have attached an example indicator that you show the screenshot of. It should demonstrate using plots with a specific "PlotStyle" that can be changed.

                    Example4Square.zip

                    Attached Files
                    Last edited by NinjaTrader_PaulH; 07-02-2021, 01:18 PM. Reason: Noted incorrect statement and point to correction.

                    Comment


                      #25
                      Hello Paul,

                      thank you very much.

                      I reviewed the code of your example file.
                      When I reference your example indicator to one (of 6) indicator signals Signal1[0] = Strategy.Signal.GetValueAt(CurrentBar);

                      and compare Signal1[0] in OnBarUpdate()

                      I do receive the following error message:

                      Error CS0021 Cannot apply indexing with [] to an expression of type 'double'

                      Code:

                      protected override void OnBarUpdate()
                      {
                      if (Strategy != null)
                      {
                      Signal1[0] = Strategy.Signal.GetValueAt(CurrentBar);
                      }

                      Filter1[0] = 0.1;

                      PlotBrushes[0][0] = Signal1[1][0] > 0 ? Brushes.Green : Signal1[1][0] < 0 ? Brushes.Red : Brushes.Transparent; // conditionally set the colors
                      //PlotBrushes[1][0] = Closes[2][0] > Opens[2][0] ? Brushes.Green : Closes[2][0] < Opens[2][0] ? Brushes.Red : Brushes.Gold;
                      //PlotBrushes[2][0] = Closes[3][0] > Opens[3][0] ? Brushes.Green : Closes[3][0] < Opens[3][0] ? Brushes.Red : Brushes.Gold;
                      //PlotBrushes[3][0] = Closes[4][0] > Opens[4][0] ? Brushes.Green : Closes[4][0] < Opens[4][0] ? Brushes.Red : Brushes.Gol

                      }


                      Could you please support how solve this issue. Thank you very much

                      Comment


                        #26
                        Hello guw75,

                        Thanks for your reply.

                        When you get an error typically you will see what line number the error is generated from at the bottom of the editor window.

                        Just looking at the code I think it is from: PlotBrushes[0][0] = Signal1[1][0] > 0 ? Brushes.Green : Signal1[1][0] < 0 ? Brushes.Red : Brushes.Transparent; // conditionally set the colors

                        Try: PlotBrushes[0][0] = Signal1[0] > 0 ? Brushes.Green : Signal1[0] < 0 ? Brushes.Red : Brushes.Transparent; // conditionally set the colors



                        Comment


                          #27
                          Hello Paul,

                          I tried that. Its possible to compile. But its not possible to enable the strategy.

                          Error message in the log file:
                          Strategy ' System A': Error on calling 'OnBarUpdate' method on bar 2: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
                          Indicator 'Strategy Signals V1.0': Error on calling 'OnBarUpdate' method on bar 0: Index was outside the bounds of the array.

                          Comment


                            #28
                            Hello guw75,

                            Thanks for your reply.

                            Let's take this offline as we are getting away from the thread subject.

                            Please write into PlatformSupport[at]Ninjatrader[dot]com. Mark the e-mail Atten: Paul, ticket # 2552838.

                            In the body of the e-mail include a link to this thread for reference.

                            In the e-mail attach the source code file for both the indicator you have modified and the strategy you are testing with.

                            Comment


                              #29
                              Hello guw75,

                              While waiting for your e-mail I researched a bit further and had forgotten that we have an example that demonstrates a strategy calling a plot in an indicator and the indicator can be in its own indicator panel which sounds like what you are trying to do. Please see the example here: https://ninjatrader.com/support/help..._a_ninjasc.htm

                              It seems a bit convoluted but demonstrates what can be done.

                              It would be far easier for you to place the conditions for the signal in the indicator and let the strategy read the signals from the indicator which is the traditional approach.


                              Comment


                                #30
                                Hello Paul, I have sent you the files.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                581 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                338 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                103 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                554 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                552 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X