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

DrawTextFixed with Position as a parameter

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

    DrawTextFixed with Position as a parameter

    Hi,

    My NT7 indicator would display a simple clock showing bar time using DrawTextFixed.

    I created a blank indicator through the wizard and then implemented the folowing snippets to start.

    Code:
            #region Properties
            [Category("Parameters")]
    		[Gui.Design.DisplayName("Clock Position")]
    		public TextPosition pubTextPosition
    		{
    			get { return parTextPosition; }
    			set { parTextPosition = value; }
    		}
    		
    
            #endregion
    In my OnBarUpdate():
    Code:
    DrawTextFixed("Clock", Time[0].ToLongTimeString(), parTextPosition);
    In my Dispose():
    Code:
    RemoveDrawObjects();
    or 
    RemoveDrawObject("Clock");
    Also I tried a number of flags in my Initialize() but am currently using:
    Code:
    ChartOnly			= true;
    Overlay				= true;
    My problem is that if user changes the position parameter I start getting several simultaneus labels on several corners.

    Also I added some Prints and my Outputs show as if the indicator is still running even after I removed it from the chart. The draw objects never disappear.

    Any help would be much appreciated. Thanks!
    Last edited by PedroLucas.net; 08-11-2017, 02:29 PM.

    #2
    Hello,

    Thank you for the post.

    I wanted to check, you said you are using a dispose method, could you instead try using the OnTermination override for removing the object?

    Code:
    protected override void OnTermination()
    {
        // Clean up your resources here
    }


    Otherwise, I would likely need to see a sample I can compile to see what syntax was used in total. I am unable to see from this why multiple objects would be listed.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thanks for your quick reply.

      Here is the full code.
      Attached Files

      Comment


        #4
        Hello,

        Thank you for providing the file.

        I am unable to see several instances appearing when changing the Position property, I wanted to check what are the exact steps you are following to see this happening?

        Also, have you removed the indicator from the chart and re added it since adding the OnTermination override?

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi,

          Ok, it's wierd that you don't see it (as attached). I tried closing chart window, restarting NT7 etc.

          I suppose it was something to do with the way it was 'compiled'. Maybe because I started it trough the wizard. Don't think I'll be able to grasp why it was happening.

          Anyway, I ported the useful bits of my code into a copy of one of the NT7 standard indicators, and it runs fine now.

          Thanks anyway for the triage.
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Jon17, Today, 04:33 PM
          0 responses
          1 view
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          4 views
          0 likes
          Last Post Javierw.ok  
          Started by timmbbo, Today, 08:59 AM
          2 responses
          10 views
          0 likes
          Last Post bltdavid  
          Started by alifarahani, Today, 09:40 AM
          6 responses
          41 views
          0 likes
          Last Post alifarahani  
          Started by Waxavi, Today, 02:10 AM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Working...
          X