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 in Class

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

    RemoveDrawObject in Class

    Hello together,

    I am working with NT8 and built a class to draw several things on the chart. I am not experienced with building classes..

    Now, I would like to use the "RemoveDrawObject" to remove some drawings on my chart, but inside the class I can´t use it:

    RemoveDrawObject("TradeID");

    ErrorCode CS0103.

    Is there any possibility to get this working? Why and how do I have to declare the object?

    Thanks for your help!
    Regards
    uupsa

    #2
    Hello uupsa,

    Thank you for your inquiry.

    Your custom class will not contain a definition for the RemoveDrawObject() method, hence why you are getting the CS0103 error.

    The Indicator class contains the definition of RemoveDrawObject().

    As you would like to remove a draw object from the current instance of the indicator, you would need to pass the indicator instance to your custom class' method.

    As an example:
    Code:
    public class ClassTest : Indicator
    {
         .......
         private CustomClass theCustomClass;
         theCustomClass = new CustomClass();
         protected override void OnBarUpdate()
         {
              theCustomClass.DestroySomething(this);
         }
    }
    
    public class CustomClass
    {
         public void DestroySomething(Indicator indicator)
         {
              indicator.RemoveDrawObject("TheDrawObject");
         }
    }
    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Hello Zachary,

      thanks a lot for your reply. Sometimes it is so easy. I defined the Indicator class in my custom class and now I am able to work with the RemoveDrawObject().

      Thanks
      uupsa

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bill2023, Yesterday, 08:51 AM
      8 responses
      43 views
      0 likes
      Last Post bill2023  
      Started by yertle, Today, 08:38 AM
      6 responses
      25 views
      0 likes
      Last Post ryjoga
      by ryjoga
       
      Started by algospoke, Yesterday, 06:40 PM
      2 responses
      24 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      46 views
      0 likes
      Last Post jeronymite  
      Working...
      X