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 love2code2trade, Yesterday, 01:45 PM
          4 responses
          28 views
          0 likes
          Last Post love2code2trade  
          Started by funk10101, Today, 09:43 PM
          0 responses
          7 views
          0 likes
          Last Post funk10101  
          Started by pkefal, 04-11-2024, 07:39 AM
          11 responses
          37 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Yesterday, 08:51 AM
          8 responses
          44 views
          0 likes
          Last Post bill2023  
          Started by yertle, Today, 08:38 AM
          6 responses
          26 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Working...
          X