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

Drawing on indicator panels

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

    Drawing on indicator panels

    I am trying to draw a vertical line on the DMI indicator panel, but the code below doesn't do it and I can't tell what mistake am I making.

    Also, when I copy the code from the NT8 editor, it inserts large spaces to the left that I then have to delete so that I align the code properly. Is there a way of copying multiple lines of code at once from the NT8 to this page without the spaces?

    Thank you

    Code:
    if (State == State.SetDefaults)
    {
       IsOverlay                                     = true;
       DrawOnPricePanel                      = true;
    .....
    }
    
    else if (State == State.DataLoaded)
    {                
         DMI1            = DMI(Closes[0], Convert.ToInt32(DmiPeriod));
         DMI1.Plots[0].Brush = Brushes.Lime;
         AddChartIndicator(DMI1);                    
         DMI1.Panel = 1;  
    }         
    
    else if (State == State.Realtime)
    {
           Draw.VerticalLine(this, "vline", 0, Brushes.Magenta, DashStyleHelper.Solid, 1, true); 
    
           Draw.VerticalLine(this, "vlineDMI", 0, Brushes.Magenta, DashStyleHelper.Solid, 1, false);     // This line doesn't show on the DMI panel
     }

    #2
    Hello itrader46,

    To confirm, both of the vertical lines are not showing is this correct?
    (As they are drawn on the same bar and are on top of each other, only one of them will be visible)

    Are there any errors on the Log tab of the Control Center when both vertical lines do not appear?

    In the NinjaScript Editor, it is possible to highlight text and use Shift + Tab to remove spaces on the left.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      The first line (vline) is showing on the price panel, but the one I want on DMI panel (vlineDMI) is not showing

      Comment


        #4
        Hello itrader46,

        All drawing objects from a script will appear on the same panel. This can be the price panel or an indicator panel.

        If you want objects in multiple panels you will need multiple indicators added to each panel.

        Your objects are being drawn on the same bar in the same panel on top of each other.

        Have you checked the Drawing Objects window to confirm both objects are being drawn?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          They are indeed drawn both on the price panel, but I thought this code will make "vlineDMI" show on DMI panel, as the "false" is for DrawOnPricePanel?

          Is there a way to choose what panel you draw the line on, in case I have more indicator panels?

          Code:
            Draw.VerticalLine(this, "vlineDMI", 0, Brushes.Magenta, DashStyleHelper.Solid, 1, false);
          Last edited by itrader46; 01-16-2020, 01:23 PM.

          Comment


            #6
            Hello itrader46,

            NinjaScript Strategies do not have the option to be on another panel.

            You may be able to set the owner to the indicator, and then it will use the panel of the indicator.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              In a previous post you said :
              All drawing objects from a script will appear on the same panel. This can be the price panel or an indicator panel.
              So how do you set them to show on an indicator panel?

              Comment


                #8
                Hello itrader46,

                By drawing the objects from the indicator that is applied to a different panel than the price panel.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I thought so, but by changing the code above to this, the line is still drawn on the price panel
                  Code:
                  Draw.VerticalLine(DMI1, "vlineDMI", 0, Brushes.Magenta, DashStyleHelper.Solid, 1, false);

                  Comment


                    #10
                    Hello itrader46,

                    The drawing object was moved to the indicator code correct?

                    Is DrawOnPricePanel set to false in the indicator?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Yes, but it still draws the line on the price panel

                      Comment


                        #12
                        How can I find what is the " NinjaScriptBase owner " for DMI?

                        Comment


                          #13
                          Hello itrader46,

                          I am seeing that the drawOnPricePanel parameter for Draw method calls is not respected when called from an indicator added to the chart by a strategy with AddChartIndicator().

                          I have submitted a report about this.


                          Attached is an example script that sets the DrawOnPricePanel for all objects to the indicator panel and is called from a strategy.
                          Attached Files
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello itrader46,

                            Our development has let me know that the drawOnPricePanel overload parameter for Draw methods temporarily change the chart DrawOnPricePanel property for the indicator, draw the object, and then change it back.

                            Because of this, it is subject to the same limitations of the DrawOnPricePanel property.

                            "Dynamically using DrawOnPricePanel in an indicator outside of State.SetDefaults may show issues when working with that indicator through a hosting strategy via AddChartIndicator()."



                            I will submit your vote to SFT-4159: 'DrawOnPricePanel should be able to be used dynamically working with an indicator through a hosting strategy via AddChartIndicator'.
                            Chelsea B.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by yertle, Yesterday, 08:38 AM
                            7 responses
                            28 views
                            0 likes
                            Last Post yertle
                            by yertle
                             
                            Started by bmartz, 03-12-2024, 06:12 AM
                            2 responses
                            20 views
                            0 likes
                            Last Post bmartz
                            by bmartz
                             
                            Started by funk10101, Today, 12:02 AM
                            0 responses
                            4 views
                            0 likes
                            Last Post funk10101  
                            Started by gravdigaz6, Yesterday, 11:40 PM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by MarianApalaghiei, Yesterday, 10:49 PM
                            3 responses
                            10 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Working...
                            X