No announcement yet.

Partner 728x90


Hack Alert: Show tooltip on drawing object (kinda sorta)

  • Filter
  • Time
  • Show
Clear All
new posts

    Hack Alert: Show tooltip on drawing object (kinda sorta)

    There is a less intrusive and simpler version here: New AddOn: Add tool tips to drawing objects


    During indicator and strategy development, I often add a lot of texts and/or drawings to the chart in order to highlight conditions that are interesting. This makes it easier to spot/verify patterns and to flesh out different approaches.

    The problem with this approach is that, especially with texts, the charts slow down and there is only so much room on the chart before it becomes really cluttered and hard to read.

    Possible Solutions

    One solution would be to put a minimal amount of texts/drawings and put the detailed information in a tooltip that is shown when the text/drawing is hovered over with the mouse.


    Unfortunately, NT does not support custom tooltips out of the box. Neither does it expose properties/methods that make it easy to implement a custom solution.


    Since source code is included for the text/drawing objects, we can modify the code to add the functionality we desire. The solution below does not implement tooltips in the strict sense of the feature as defined by Windows. Due to the limited information provided by NT, this is more of a hybrid Frankenstein's monster version.

    If you are really determined and persistent, you could eventually get a correct version working since all the information is in NT - it's just not easy and straightforward to get to in an efficient manner.


    Since we are hacking the source directly, we need to copy the changes over each time we install a new version of NT.


    I've attached files that implement the "tooltips" for texts, chart markers and drawing objects (ellipse, rectangle, triangle). These files are a replacement for the ones that ship with NT in the DrawingTools folder (See the notes below about replacing). You could use the same technique to apply this to the other drawing objects as well.

    How It Works

    Unlike regular tooltips that appear on hover, you need to click the target object so it is selected. Any movement of the mouse will then cause the "tooltip" to appear. Also unlike regular tooltips, the tooltip will remain visible until you click somewhere other than in the tooltip.


    This hack adds three properties to the drawing objects. The properties are ToolTipText (string), ToolTipContent (object), and ToolTipContentFactory (Func<object>). You only need to set one of these properties in order to apply your tooltip. The one you use will depend on your scenario.

    Scenario One

    In the simple case, you can use the ToolTipText property to display a simple string.

    var drawing = Draw.Dot(...);
    if (drawing != null)
        drawing.ToolTipText = "Hello, world!";
    Or if you are using my hack for compiling with .Net 4.6 or later (Here)

    var drawing = Draw.Dot(...);
    drawing?.SetToolTipText("Hello, world!");
    Scenario Two

    To display controls on a few objects, you can use the ToolTipContent property to provide your element tree.

    var drawing = Draw.Dot(...);
    var button = new Button { Content = "Hello" };
    button.Click += (_, __) => button.Content = "World";
    Scenario Three

    To display controls on many objects, you can use the ToolTipContentFactory property to provide your element tree. The method you provide will be called only when the tooltip is shown. After the tooltip is hidden, the object instance you returned from the factory will be eligible for garbage collection.

    If you are creating custom tooltips for many drawing objects, it is recommended that you use this property since it will use the least amount of memory. Keep in mind that the function you provide can be called zero or many times.

    var drawing = Draw.Dot(...);
    drawing?.SetToolTipContentFactory(() =>
            var button = new Button { Content = "Hello" };
            button.Click += (_, __) => button.Content = "World";
            return button;
    NOTE: It is important to check the result from the Draw.* functions because they sometimes return null.

    • If you are using version, copy the attached files into the DrawingTools folder
    • If you are using a different version (or whenever you need to upgrade), search for the sections enclosed with "// Begin Wil changes", "// End Wil changes" and copy them into the corresponding files and locations in the DrawingTools folder. I have some changes in there to adjust the calculations of drawing objects to be confined to a bar instead of in-between bars. You can remove those changes if you don't want them


    Since TextFixed cannot be selected, you won't be able to access any tooltips assigned to instances of it. Since by definition there will usually be at most five instances per chart (based on position), you could efficiently implement a proper tooltip for this class - with proper hit testing and hovering.

    !! Super Hack Alert !!

    If you are adventurous and like to live on the edge, you could use custom tooltips to modify the behavior of your indicator/strategy on the fly!
    Attached Files
    Last edited by wbennettjr; 07-15-2017, 04:16 PM.

Latest Posts


Topics Statistics Last Post
Started by GussJ, Today, 01:24 PM
0 responses
Last Post GussJ
by GussJ
Started by frslvr, Today, 12:40 PM
0 responses
Last Post frslvr
by frslvr
Started by Sifred, Today, 10:43 AM
0 responses
Last Post Sifred
by Sifred
Started by Catalon, Today, 10:42 AM
0 responses
Last Post Catalon
by Catalon
Started by vivekniwas, Today, 09:41 AM
0 responses
Last Post vivekniwas