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

RemoveDrawObject doesn't delete

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

    RemoveDrawObject doesn't delete

    Hi
    I am trying to remove some lines I had created before with RemoveDrawObject but it seems it doesn't work.
    For example the line can be created after the order is working
    if (order.OrderState == OrderState.Working)
    {
    IHorizontalLine buyLine = DrawHorizontalLine(order.Name, order.LimitPrice, Color.DarkBlue);
    }

    And removed when the order is filled
    if (order.OrderState == OrderState.Filled)
    {
    RemoveDrawObject(order.Name);
    }

    While the creation works fine, I don't see the removal process. I have tried to unlock the buyLine but that didn't help (buyLine.Locked = false)
    I have also tried this suggested in the link below without success.




    How can I manage to remove these lines, otherwise they keep accumulating?

    Thanks for your help
    Last edited by jakjak74; 01-04-2017, 05:11 AM.

    #2
    Hello jakjak74,

    Thank you for your post.

    Print the name of the order to the Output window when the Horiztonal Line is drawn and when you attempt to remove it.
    For information on Print please visit the following link: http://ninjatrader.com/support/helpGuides/nt7/print.htm
    You can access the Output window under Tools > Output.

    This will show you if the order.Name is the same when the drawing object is created and when attempting to remove.

    Please let me know if you have any questions.

    Comment


      #3
      Hello Patrick

      I found my error thanks to your suggestion.
      Does the RemoveDrawObject delete also the object in the memory? I want to get rid completely of these objects gradually. If not, how can I force the graphical object to pass to the garbage collector?

      Comment


        #4
        Hello jakjak74,

        Thank you for your response.

        Garbage Collection in .Net cannot be forced through NinjaScript. The removal of the visual object and it's identification in the collection is all that can be performed through NinjaScript.

        Please let me know if you have any questions.

        Comment


          #5
          Thanks. Is there any way of releasing the memory when we remove Graphical objects? From your answer I understand no.
          My Concern is a not gradually released memory for a Strategy which is supposed to run in production for long time.

          Comment


            #6
            Hello jakjak74,

            Thank you for your response.

            I understand your concern on the memory. You may wish to adjust the Drawing Object rather than removing it, to prevent multiple instances in memory.
            For example, instead of removing the object, set it to a transparent color. Then when the order is active, set the color back to the desired color and set the y value.

            Please let me know if you have any questions.

            Comment


              #7
              I understand your suggestion, however if I have many of these objects and need to find easily which one is which, this becomes a headache.
              Would be good to have deletion functionality in the future if possible.

              Thanks Patrick for your help

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by xiinteractive, 04-09-2024, 08:08 AM
              2 responses
              11 views
              0 likes
              Last Post xiinteractive  
              Started by Irukandji, Today, 09:34 AM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by RubenCazorla, Today, 09:07 AM
              1 response
              5 views
              0 likes
              Last Post RubenCazorla  
              Started by TraderBCL, Today, 04:38 AM
              3 responses
              25 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by WeyldFalcon, 08-07-2020, 06:13 AM
              11 responses
              1,423 views
              0 likes
              Last Post jculp
              by jculp
               
              Working...
              X