Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw text on 2 panels from same indicator

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

    Draw text on 2 panels from same indicator

    Hello,

    I am ware that this setting DrawOnPricePanel = false; will allow my indicator to draw on non price panel. I need ability for 1 indicator to draw on 2 different panels at the same time. I found this post from Ninja Staff from about 2 years ago:

    "It is not possible for a single indicator to draw objects on multiple panels.
    It is necessary to split the drawing calls into multiple indicators."


    Is this still the case?

    Thanks,
    redduke

    #2
    Hello RedDuke,
    I believe its not possible to add multiple panels from within an indicator as of now so we have to split the indicators for such cases. We can't draw or plot on multiple panels simultaneously.

    Comment


      #3
      Hello RedDuke,

      Thanks for your post.

      Yes, it is possible and there are some limitations however first let's be clear on what a Draw Object is as there can be confusion. To keep it simple, Draw Objects are created by the use of Draw statements. Plots are not considered draw objects. So it is correct that plots can only be sent to one panel and one script can only send plots to one panel. So in the case of plotting in two panels, yes that would require two scripts.

      Draw objects can be sent to the price panel and/or the indicator panel when the script creates as an indicator panel. If the script is a price panel only, then it cannot send draw objects to an indicator panel it did not create.

      Also, there is this limitation in the use of DrawOnPricePanel which you must be aware of: Warning: This property should ONLY be set from the OnStateChange() method during State.SetDefaults. Dynamically using DrawOnPricePanel in an indicator outside of State.SetDefaults may show issues when working with that indicator through a hosting strategy via AddChartIndicator(). Reference: https://ninjatrader.com/support/help...pricepanel.htm

      So if your indicator is ever added to a chart by AddChartIndicator() in a strategy, it may not perform as expected regarding the draw objects.

      I've attached an example script you can replicate that shows creating an indicator panel (IsOverLay = false) and assigning a plot value to plot in the indicator panel. Two Draw.Dot() statements, every 100 bars, are used to show that you can draw on the price panel and then draw on the indicator panel by flipping the state of DrawOnPricePanel. They draw at the same bar/time but this does not mean they have to be drawn on the same bar/time.


      Click image for larger version

Name:	RedDuke1.PNG
Views:	1487
Size:	111.4 KB
ID:	1122812

      Comment


        #4
        Hi Paul,

        Thanks a lot. This is exactly what I needed. Brilliant!!!

        Regards,
        redduke

        Comment


          #5
          Hello Paul,
          Thanks for the info.

          Comment


            #6
            Hi Paul,

            I tried this with Draw.Text but in both below examples text got printed on price panel:

            Draw.Text(this, "A4", true, "A", 0, Low[0]-TickSize*3, 0, Brushes.Blue, textFont, 0 , Brushes.Black, Brushes.Black, 0);
            Draw.Text(this, "A5", true, "A", 0, High[0]+TickSize*3, 0, Brushes.Blue, textFont, 0 , Brushes.Black, Brushes.Black, 0);

            DrawOnPricePanel=false;

            Draw.Text(this, "A6", true, "B", 0, Lows[2][0]-TickSize*3, 0, Brushes.Blue, textFont, 0 , Brushes.Black, Brushes.Black, 0);
            Draw.Text(this, "A7", true, "B", 0, Highs[2][0]+TickSize*3, 0, Brushes.Blue, textFont, 0 , Brushes.Black, Brushes.Black, 0);

            DrawOnPricePanel=true;

            Any idea what I am doing wrong?

            Thanks,
            redduke

            Comment


              #7
              Hello RedDuke,
              Try this:
              Draw.Text(this, "pp", "test", 0, Low[0] - 5);
              DrawOnPricePanel = false;
              Draw.Text(this, "ip", "test", 0, 0);
              DrawOnPricePanel = true;
              pp should draw on price panel & ip should draw on indicator panel. I am assuming you've set DrawOnPricePanel = true; so you're basically resetting this property after each text command.
              Hope it helps!
              Last edited by s.kinra; 10-20-2020, 10:39 PM.

              Comment


                #8
                TestText.zip
                Here you get the sample code.

                Comment


                  #9
                  Hi S. Kinra,

                  It did not work. But I think I know why. I have 2 price Panels with different time series on the same instrument. Essentially I want indicator that runs on Price Panel 1 draw something on Price Panel 2.

                  Thanks,
                  redduke

                  Comment


                    #10
                    Hello RedDuke,
                    I haven't yet worked with 2 price panels but surely give a try, update you if I get something, I am sure Paul will guide in a better way for now.

                    Comment


                      #11
                      Hello RedDuke,

                      Thanks for your reply.

                      An indicator can draw in its own indicator panel and/or the related price panel through the demonstrated use of DrawOnPricePanel.

                      There would be no means to draw from one price panel to another price panel.

                      Comment


                        #12
                        Originally posted by NinjaTrader_PaulH View Post
                        Hello RedDuke,

                        Thanks for your reply.

                        An indicator can draw in its own indicator panel and/or the related price panel through the demonstrated use of DrawOnPricePanel.

                        There would be no means to draw from one price panel to another price panel.
                        I understand. Thank you very much for explaining.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        648 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        369 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        108 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        572 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        573 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X