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

DrawObject Removal

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

    DrawObject Removal

    Is there any way to stop drawobjects you've written into your indicator from being removed when the user manually clears them by clicking "Remove All Draw Objects" from the drop-down menu?

    If not, is there a known way to plot dots that have an outline as with DrawDot() , but in a Plot instead ?


    Thanks in Advance

    #2
    Nevermind about the dots, I guess its case of overiding the Plot class.

    Just an 'ignore user input' flag for drawobjects would be good, otherwise you get into overiding the Plot class for a very minor reason.

    Comment


      #3
      We'll put it to our list. Thanks for your suggestion.

      Comment


        #4
        RemoveDrawObject

        I did a script to Draw a Triangle Up when RSI is above 65 and a Triangle Down when RSI is below 35 as you can see below.

        If RSI goes above 65 the Triangle Up appears but if than the bar close with RSI below 65 the Triangle up stays there. I tried to use RemoveDrawObject for the cases whose RSI is between 35 - 65, but the Triangles stay there.

        Could you please tell me how to fix this.

        If I use BackColor = Color.DarkSeaGreen; instead DrawTriangleUp it works really good and I don't need to remove it.

        Thanks


        if (RSI(period,1)[0]>65)
        {
        DrawTriangleUp("rsi1" +CurrentBar, true, 0, Low[0] - 13*TickSize, Color.Yellow);
        }
        else if (RSI(period,1)[0]<35)
        {

        DrawTriangleDown("rsi12" +CurrentBar, true, 0, High[0] + 13*TickSize, Color.White);
        }

        if(RSI(period,1)[0]>35 || RSI(period,1)[0]<65)
        {

        RemoveDrawObject("rsi1");
        RemoveDrawObject("rsi12");

        }

        Comment


          #5
          Hello Fernando,

          If RSI goes above 65 the Triangle Up appears but if than the bar close with RSI below 65 the Triangle up stays there
          You can set CalculateOnBarClose = true and these conditions will only be evaluated at bar close.

          If you want COBC = false, your removal code doesn't include the CurrentBar portion in the tag field.

          if(RSI(period,1)[0]>35 || RSI(period,1)[0]<65)
          {
          RemoveDrawObject("rsi1" + CurrentBar);
          RemoveDrawObject("rsi12" + CurrentBar);
          }
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Thanks RyanM

            I prefer COBC = false. I tried with RemoveDrawObject("rsi1" + CurrentBar); and all Triangles had gone. I only want the Triangle being remove if the bar closes with RSI below 65 after RSI went above 65 in the some bar, As I sad with BackColor = Color.DarkSeaGreen; instead DrawTriangleUp it works really good and I don't need to remove it.

            Thanks

            Comment


              #7
              You can probably fix this by changing the removal if clause to else. It's then only evaluted when the previous two conditions are false.

              Code:
               
              if (RSI(period,1)[0]>65)
              {
              DrawTriangleUp("rsi1" + CurrentBar, true, 0, Low[0] - 13*TickSize, Color.Yellow);
              }
              
              else if (RSI(period,1)[0]<35)
              {
              DrawTriangleDown("rsi12" + CurrentBar, true, 0, High[0] + 13*TickSize, Color.White);
              }
              
              else
              {
              RemoveDrawObject("rsi1" + CurrentBar);
              RemoveDrawObject("rsi12" + CurrentBar);
              }
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                Thanks RyanM

                I don't know what you mean. Could you please be more specific

                Thanks

                Comment


                  #9
                  Please try with the code snippet I posted.

                  Changing if to else so that the removal condition is only evaluated when the previous two conditions are false.

                  With the way it's structured now, your results are expected. It's removing whenever RSI > 35 which is also true when RSI > 65.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks RyanM

                    I'm sorry only after my post I realized what you meant.

                    It works like you sad.
                    Really good now.

                    Thanks

                    Comment


                      #11
                      Glad to hear, Fernando. Thanks for the update.
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Cancel warning

                        I asked to close NT with one working order, it shows up a Warning saying "You have 1 active order. Do you really want to disconnect? I chose No and canceled all orders but now every time I ask to close comes that warning.

                        How can I cancel this warning once there are no active orders anymore?

                        Thanks

                        Comment


                          #13
                          Fernando,

                          There can be occassions where orders get stuck in a pending state. You can remove these types of orders by resetting the simulated account.

                          Resetting a simulation account will clear all historical trade data from this account. Please follow the instructions below to reset a simulation account.
                          • From the NinjaTrader Control Center window select the menu Tools > Options
                          • Select the "Simulator" tab
                          • Press the "Reset" button
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            #14
                            Thanks RyanM

                            It worked well.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by kempotrader, Today, 08:56 AM
                            0 responses
                            6 views
                            0 likes
                            Last Post kempotrader  
                            Started by kempotrader, Today, 08:54 AM
                            0 responses
                            4 views
                            0 likes
                            Last Post kempotrader  
                            Started by mmenigma, Today, 08:54 AM
                            0 responses
                            2 views
                            0 likes
                            Last Post mmenigma  
                            Started by halgo_boulder, Today, 08:44 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post halgo_boulder  
                            Started by drewski1980, Today, 08:24 AM
                            0 responses
                            3 views
                            0 likes
                            Last Post drewski1980  
                            Working...
                            X