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

Toolbar Button for Indicators - NT7

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

    Toolbar Button for Indicators - NT7

    Hi,

    Is there a generic toolbar button that will hide or show an indicator on NT7 charts. This can be a sample indicator with a toolbar button or a script that can be used to turn on and off any indicator.

    Many Thanks.

    #2
    Hello aligator,

    No, there is not a toolbar button that will remove indicators from a chart. On the chart toolstrip, there is a button to open the indicator window where you can manage the indicators added to the chart.

    I am not aware of a way to remove indicators from a chart through code in NinjaTrader 7, however, this may be possible with NinjaTrader 8.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello aligator,

      No, there is not a toolbar button that will remove indicators from a chart. On the chart toolstrip, there is a button to open the indicator window where you can manage the indicators added to the chart.

      I am not aware of a way to remove indicators from a chart through code in NinjaTrader 7, however, this may be possible with NinjaTrader 8.
      Thanks,

      Is there an example of an indicator with a chart toolstrip button to hide or show the indicator on the chart. I have seen such NT7 indicator using private void hideshow(object s, EventArgs e) to hide/show the indicator on the chart using a button, but can not locate that.

      Thanks.

      Comment


        #4
        Hello aligator,

        From within an indicator, you can add a button to a toolstrip. Clicking on the button could trigger a method that changes the color of a plot or removes drawing objects, etc. However, this would not remove the indicator from the chart. The indicator also would not be able to access other indicators added to the chart.

        So, if you wanted to, you could make a button that sets colors or removes drawing objects.

        An example of a button is below.
        http://ninjatrader.com/support/forum...php?linkid=490

        Also, below is a link to the help guide on the Plots object where you can set the Pen of the entire plot of an existing plot.
        http://ninjatrader.com/support/helpGuides/nt7/plots.htm

        A link to PlotColors where you can set the colors of individual bars of a plot (the plot tag will remain the original color in the price margin).
        http://ninjatrader.com/support/helpG...plotcolors.htm

        A link to RemoveDrawObject() where you can remove one object by tag name.
        http://ninjatrader.com/support/helpG...drawobject.htm

        And a link to RemoveDrawObjects() which removes all drawing objects.
        http://ninjatrader.com/support/helpG...rawobjects.htm
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello aligator,

          From within an indicator, you can add a button to a toolstrip. Clicking on the button could trigger a method that changes the color of a plot or removes drawing objects, etc. However, this would not remove the indicator from the chart. The indicator also would not be able to access other indicators added to the chart.

          So, if you wanted to, you could make a button that sets colors or removes drawing objects.

          An example of a button is below.
          http://ninjatrader.com/support/forum...php?linkid=490

          Also, below is a link to the help guide on the Plots object where you can set the Pen of the entire plot of an existing plot.
          http://ninjatrader.com/support/helpGuides/nt7/plots.htm

          A link to PlotColors where you can set the colors of individual bars of a plot (the plot tag will remain the original color in the price margin).
          http://ninjatrader.com/support/helpG...plotcolors.htm

          A link to RemoveDrawObject() where you can remove one object by tag name.
          http://ninjatrader.com/support/helpG...drawobject.htm

          And a link to RemoveDrawObjects() which removes all drawing objects.
          http://ninjatrader.com/support/helpG...rawobjects.htm
          Thank you ChelseaB,

          The links are great. I can now use PlotColors to simply toggle a Plot() (such as a simple SMA) color to Transparent.

          However, in the case of DrawLine, DrawText, DrawRay, etc. is it possible to use a new pen color for such drawn objects to make them transparent instead of removing them per the link above?

          For example, I want to use the toggle button to make a drawn line or a ray transparent. Is there such a thing as DrawObjectsColor (or something similar), that can be used like PlotColors?

          Thanks.

          I
          Last edited by aligator; 06-30-2016, 10:33 AM.

          Comment


            #6
            Hello aligator,

            Each time you draw an object, store that with a variable (or array).
            Then use that variable to change its settings.
            Code:
            In #region Variables:
            IArrowDown myDownArrow;
            
            In the method drawing the object (such as OnBarUpdate):
            myDownArrow = DrawArrowDown("tag1", true, 0, High[0] + TickSize, Color.Red);
            
            if (myDownArrow != null)
            myDownArrow.Color = Color.Green;
            http://ninjatrader.com/support/helpG...iarrowdown.htm

            You can also loop through the DrawObjects collection.
            http://ninjatrader.com/support/helpG...rawobjects.htm
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello aligator,

              Each time you draw an object, store that with a variable (or array).
              Then use that variable to change its settings.
              Code:
              In #region Variables:
              IArrowDown myDownArrow;
              
              In the method drawing the object (such as OnBarUpdate):
              myDownArrow = DrawArrowDown("tag1", true, 0, High[0] + TickSize, Color.Red);
              
              if (myDownArrow != null)
              myDownArrow.Color = Color.Green;
              http://ninjatrader.com/support/helpG...iarrowdown.htm

              You can also loop through the DrawObjects collection.
              http://ninjatrader.com/support/helpG...rawobjects.htm
              Thank you ChelseaB, that worked nicely. However, the following code:

              myDownArrow.Color = Color.Green; needed a "Pen" included as:

              myDownArrow.Pen.Color = Color.Green;

              to get it to work.

              Thanks again.

              Cheers!

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Hello aligator,

                Each time you draw an object, store that with a variable (or array).
                Then use that variable to change its settings.
                Code:
                In #region Variables:
                IArrowDown myDownArrow;
                
                In the method drawing the object (such as OnBarUpdate):
                myDownArrow = DrawArrowDown("tag1", true, 0, High[0] + TickSize, Color.Red);
                
                if (myDownArrow != null)
                myDownArrow.Color = Color.Green;
                http://ninjatrader.com/support/helpG...iarrowdown.htm

                You can also loop through the DrawObjects collection.
                http://ninjatrader.com/support/helpG...rawobjects.htm
                ChelseaB, Thanks again. I think I spoke too soon in my previous post.

                If I use the above code:

                if (myDownArrow != null)
                myDownArrow.Pen.Color = Color.Green;

                it works fine, however this will only work for the last drawn object (in this case a DrawLine) and the historical drawn lines are un-effected. I want the toggle button to color all the drawn lines on the same chart. I believe the loop will color all lines globally on all open charts running the same indicator having the same tag.

                Can the above code be modified to color all lines by the indicator (same tag) on the same chart instead of just the most recent line?

                Thanks and appreciate.

                Comment


                  #9
                  Hello aligator,

                  The example I showed you would draw a single line and would not draw multiple lines.
                  The tag name is not unique so this would only create a single line.

                  I've also tested setting the color without setting the pen and this appears to work ok. However, using a pen is fine, it just shouldn't be required.
                  Attached is an example of setting the color without using a pen. Does this script show green arrows or red arrows on your end?

                  And yes, you can change the color of all the objects or a single object.
                  Are you looping through the DrawObject collection or have you made a List<> to hold these drawing objects?

                  The tag is a string.
                  Print(myDownArrow.Tag);
                  IArrowDown.Tag

                  If you are looping through the DrawObject instead of your own array or list, the Tag property is also part of the IDrawObject class and is accesible before or after the object is cast.
                  IDrawObject.Tag
                  Attached Files
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_ChelseaB View Post
                    Hello aligator,

                    The example I showed you would draw a single line and would not draw multiple lines.
                    The tag name is not unique so this would only create a single line.

                    I've also tested setting the color without setting the pen and this appears to work ok. However, using a pen is fine, it just shouldn't be required.
                    Attached is an example of setting the color without using a pen. Does this script show green arrows or red arrows on your end?

                    And yes, you can change the color of all the objects or a single object.
                    Are you looping through the DrawObject collection or have you made a List<> to hold these drawing objects?

                    The tag is a string.
                    Print(myDownArrow.Tag);
                    IArrowDown.Tag

                    If you are looping through the DrawObject instead of your own array or list, the Tag property is also part of the IDrawObject class and is accesible before or after the object is cast.
                    IDrawObject.Tag
                    Thanks again ChelseaB,

                    I took your sample indicator and added a toggle button for the arrows color. A double click on the toolbar button should make all arrows transparent. However, only the most recent arrow will become transparent and the rest remain red.

                    I need to have all the arrows transparent using the toggle button. I was not sure how or where the Print().Tag or IDrawObject.Tag should be used. Here is your modified code.

                    Thanks.
                    Attached Files

                    Comment


                      #11
                      Hello aligator,

                      The example I have provided to you only tracks one drawing object at a time.

                      If you want to change the color of all drawing objects, put this in an list or array and then loop over the array.

                      Code:
                      private System.Collections.Generic.List<IArrowDown> myDownArrows;
                      
                      myDownArrows.Add(DrawArrowDown("tag1" + CurrentBar, true, 0, High[0] + TickSize, Color.Red));
                      
                      for (var i = 0; i < myDownArrows.Count; i++)
                      {
                      myDownArrows[i].Color = Color.Empty;
                      }
                      Chelsea B.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by RookieTrader, Today, 09:37 AM
                      3 responses
                      13 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by kulwinder73, Today, 10:31 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post kulwinder73  
                      Started by terofs, Yesterday, 04:18 PM
                      1 response
                      22 views
                      0 likes
                      Last Post terofs
                      by terofs
                       
                      Started by CommonWhale, Today, 09:55 AM
                      1 response
                      3 views
                      0 likes
                      Last Post NinjaTrader_Erick  
                      Started by Gerik, Today, 09:40 AM
                      2 responses
                      7 views
                      0 likes
                      Last Post Gerik
                      by Gerik
                       
                      Working...
                      X