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

Can't dispose of Stroke object

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

    Can't dispose of Stroke object

    Hello,
    I created a new Sroke object, setting width to 5. I deleted the command later, but the Draw.Dot method draws large points now no matter what I do. I do not remember exactly what object I created. I guess, it was smth like Stroke a = new Stroke(Brushes.Red, 5); How can I reset the Stroke, or dispose of that object?
    Thanks.

    #2
    Hello Lucero,

    Thanks for writing in.

    You can set the Stroke you created to null when you are done with it and no longer wish to use the Stroke.

    As for removing the drawing object, you may wish to look into RemoveDrawObject() and RemoveDrawObjects(). RemoveDrawObject() removes that drawing objects based on tag, and RemoveDrawObjects() removes all drawing objects from the indicator or strategy.

    Please see the documentation below for more information and sample code:


    If you have any other questions, please don't hesitate to ask.
    JimNinjaTrader Customer Service

    Comment


      #3
      The object is no longer in the code, I deleted it long ago, how can I set it to null? The problem is that the Draw.Dot() does not plot a 1 pixel dot, instead it plots a circle 10 pixels in diameter. How can I make it draw a 1 pixel point again?

      Comment


        #4
        Hello Lucero,

        Thanks for the clarification.

        The Draw.Dot() method creates a dot with the size specified by the chart's bar width.

        Tip: The size of the dot is tied to the chart's BarWidth and thus will scale automatically as the chart is resized


        If you wish to make drawing objects that are the size of one pixel, you may have more flexibility using Draw.Line() so you can specify an exact width. You may wish to also investigate using GetTimeByX() and the advanced features used with OnRender() to work with the Draw.Line() to create an object being one pixel in width.

        Documentation can be found below:
        Draw.Line() - https://ninjatrader.com/support/help.../draw_line.htm
        GetTimeByX() - https://ninjatrader.com/support/help...gettimebyx.htm
        OnRender() - https://ninjatrader.com/support/help...e_onrender.htm

        Please let me know if we may be of further help.
        JimNinjaTrader Customer Service

        Comment


          #5
          The bar width is set to 1, and still Draw.Dot(this, LineNumber.ToString()+" Start", true, xStart , TickSize * yStart, Brushes.Brown); draws circles instead of dots. I even created a different indicator consisting of a single line Draw.Dot(this, "1", true, 0 , Close[0], Brushes.Brown); and it also draws the same circle no matter if IsAutoscale is set to true or false or what color is set.
          Attached Files

          Comment


            #6
            Hello Lucero,

            Thanks for pointing that out.

            The Draw.Dot() drawing object will keep fixed minimum size, but scales with the chart as you increase the margin.

            If you would like, I can place a feature request for the development team to add another overload for allowing the Draw.Dot() method to override the minimum size.

            Please let me know if we may be of further assistance.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Barry Milan, Today, 10:35 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by WeyldFalcon, 12-10-2020, 06:48 PM
            14 responses
            1,428 views
            0 likes
            Last Post Handclap0241  
            Started by DJ888, Yesterday, 06:09 PM
            2 responses
            9 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            40 views
            0 likes
            Last Post jeronymite  
            Started by bill2023, Today, 08:51 AM
            2 responses
            16 views
            0 likes
            Last Post bill2023  
            Working...
            X