Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

chart marker

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

    chart marker

    I have a indicator where I plot a Arrow Up, Arrow Down or a Dot, depending of the condition.
    In a same bar it is possible a change of Arrow Up to Dot, or, to Arrow Down.
    When occur the change, I would like to erase the last picture before to plot the new.
    I am using the "RemoveDrawObject("xxx") to erase the last picture, but it is not working. The second picture is being plot on the first.
    is there a other form to do it?
    Thank you

    #2
    Hello sasil,

    Thank you for writing in.

    This would depend on if your script has CalculateOnBarClose set to true or false. If it is set to true, OnBarUpdate() will only run at the close of each bar; in this case, you wouldn't be able to change the drawn object. However, you could change the drawn object if you have CalculateOnBarClose set to false. This allows your script to run on every tick that comes in, so it would be possible for changes to occur intrabar.

    I have provided an example indicator that shows how you can change drawing objects intrabar.

    Please, let us know if we may be of further assistance.
    Attached Files
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      ok I will try it. thank you

      Comment


        #4
        I tried your example, but it is not work yet.

        I am using OnBarClose = false;

        I am not using a DrawDot, for example, I am using

        Add(new Plot(new Pen(Color.FromKnownColor(KnownColor.Red),3), PlotStyle.Dot, "SetUp0"));
        Add(new Plot(new Pen(Color.FromKnownColor(KnownColor.Green),3), PlotStyle.TriangleUp, "SetUp1"));
        Add(new Plot(new Pen(Color.FromKnownColor(KnownColor.Blue),3), PlotStyle.TriangleDown, "SetUp2"));

        In this case I can to use the RemoveDrawObject?

        Comment


          #5
          In this case I can to use the RemoveDrawObject to remove the SetUp0, SetUp1 or SetUp2 when they change?

          Comment


            #6
            Hello sasil,

            RemoveDrawObject() is used for removing draw objects, not plots.

            You would want to utilize the Plots collection and modify the already existing plot: http://ninjatrader.com/support/helpG...nt7/?plots.htm

            As an example:
            Code:
            private Plot dotPlot;
            private Plot squarePlot;
            private int counter = 0;
            
            protected override void Initialize()
            {
                 Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Dot, "Plot0"));
                 CalculateOnBarClose = false;
            }
            
            protected override void OnBarUpdate()
            {
                 counter++;
                 // if counter % 2 == 0, change the plot's PlotStyle to Dot and its color to green
                 if (counter % 2 == 0)
                 {
                      Plots[0].PlotStyle = PlotStyle.Dot;
                      Plots[0].Pen.Color = Color.Green;
                 }
                 // if counter % 2 != 0, change the plot's PlotStyle to Square and its color to red
                 else
                 {
                      Plots[0].PlotStyle = PlotStyle.Square;
                      Plots[0].Pen.Color = Color.Red;
                 }
            
                 Plot0.Set(Close[0]);
            }
            Last edited by NinjaTrader_ZacharyG; 06-01-2016, 01:30 PM.
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              Sorry, but still I not get what I wanted, thanks for the patience .

              In my Indicator I have a line, in a Painel different of the input series, where in each bar I plot a symbol. A triangle up when the signal is to buy, a triangle down when the signal is to sell and a dot when you don´t do anything.

              I am setting CalculateOnBarClose = false, and a Plot Collection to plot my line of signals.

              When the signals change inside the bar, what I want is to erase the last drawing objects, in the current bar, before drawing the new symbol for the new condition.

              Is this possible? If so what or how can I do?

              Thanks

              Comment


                #8
                Hello sasil,

                I have provided how to remove and replace drawing objects intrabar in the script in my initial reply.

                Originally posted by NinjaTrader_ZacharyG View Post
                Hello sasil,

                Thank you for writing in.

                This would depend on if your script has CalculateOnBarClose set to true or false. If it is set to true, OnBarUpdate() will only run at the close of each bar; in this case, you wouldn't be able to change the drawn object. However, you could change the drawn object if you have CalculateOnBarClose set to false. This allows your script to run on every tick that comes in, so it would be possible for changes to occur intrabar.

                I have provided an example indicator that shows how you can change drawing objects intrabar.

                Please, let us know if we may be of further assistance.
                You have later stated plots. I have provided information on how to modify the indicator plot.

                Originally posted by NinjaTrader_ZacharyG View Post
                Hello sasil,

                RemoveDrawObject() is used for removing draw objects, not plots.

                You would want to utilize the Plots collection and modify the already existing plot: http://ninjatrader.com/support/helpG...nt7/?plots.htm

                As an example:
                Code:
                private Plot dotPlot;
                private Plot squarePlot;
                private int counter = 0;
                
                protected override void Initialize()
                {
                     Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Dot, "Plot0"));
                     CalculateOnBarClose = false;
                }
                
                protected override void OnBarUpdate()
                {
                     counter++;
                     // if counter % 2 == 0, change the plot's PlotStyle to Dot and its color to green
                     if (counter % 2 == 0)
                     {
                          Plots[0].PlotStyle = PlotStyle.Dot;
                          Plots[0].Pen.Color = Color.Green;
                     }
                     // if counter % 2 != 0, change the plot's PlotStyle to Square and its color to red
                     else
                     {
                          Plots[0].PlotStyle = PlotStyle.Square;
                          Plots[0].Pen.Color = Color.Red;
                     }
                
                     Plot0.Set(Close[0]);
                }
                I am not entirely clear of what you are wishing to modify.

                Please provide a screenshot of your chart for further clarification of what you wish to modify.
                Zachary G.NinjaTrader Customer Service

                Comment


                  #9
                  I am sending you a screenshot. The signal of bar 0 is the condition without change. But in the Bars 3, 4 and 5, occurred a change and you don't know what the last condition.
                  I am sending the code of my indicator too.

                  Thank you
                  Attached Files

                  Comment


                    #10
                    see the screenshot
                    Attached Files

                    Comment


                      #11
                      Hello sasil,

                      You will need to use drawing objects rather than creating plots to accomplish what you are wanting to do.

                      To have these draw objects drawn in the same panel as your indicator, you'll want to add DrawOnPricePanel = false; to your script Initialize() method: http://ninjatrader.com/support/helpG...pricepanel.htm

                      I have modified my previous sample to demonstrate the use of draw objects. They are drawn at 0 in the indicator panel. When connected to live data, you can see the drawing object change intrabar.
                      Attached Files
                      Zachary G.NinjaTrader Customer Service

                      Comment


                        #12
                        ok, thanks for the help, now is working. thank you

                        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
                        574 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X