Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Hotkey Indikator for DrawingTools

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

    Hotkey Indikator for DrawingTools

    Hi, I have created an indicator that processes my own hotkeys. The goal is, for example:
    1. Ctrl + V creates a horizontal, solid, yellow line with a width of 2.
    2. Ctrl + B creates a horizontal. dash, red, line with a width of 3.
    Click image for larger version

Name:	Screenshot_1.jpg
Views:	307
Size:	4.3 KB
ID:	1184249

    Code:
    private void EventHandlerKeyPressedV(object sender, RoutedEventArgs e)
    {
    
    }
    with
    Code:
    SendKeys.SendWait("{F6}");
    Does not help me, because only the already existing template is taken. I should somehow be able to define the color, style, wide etc. before sending the command and only then send the create command. Anyone has any idea how best to approach this?
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    I'm not certain if you want to program your own hotkeys or if you want to trigger a drawing tool to be drawn with the mouse by its pre-mapped hotkey.

    For capturing your own keypresses take a look these examples.

    This is a conversion of the NYSE TICK and Advance/Decline Market Internals developed and originally coded for the NinjaTrader 7 platform by monpere. Please contact the original author for any questions or comments.


    For triggering a drawing tool to begin drawing with the mouse have a look at the example attached and the link to the mahtoolbar on the user app share linked below.
    mahToolBar – Version 6 This version updates the code to includes several new icons for NT8 default Drawing Tools plus additional chart management tools. The mahToolBar6 indicator installs drawing tools icons in the NinjaTrader 8 Main Toolbar for a one-click drawing. The early version of this indicator with selected tools used sample scripts from several […]


    When triggering a drawing tool to begin drawing with the mouse, it will use the default template. But you draw the object with a Draw method you can specify the color and other properties.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi _ChelseaB, super, thank you! I'll take a look at it.

      Another question: is it possible to find out which drawing object was last added to a chart?

      As an example: I add a horizontal line to the chart with "F6". This object is then the last object added to the chart. I could then use it either to change the stroke with this method, or as in the code when it was selected.

      Code:
      foreach (IChartObject obj in ChartControl.ChartObjects.ToList())
      {[INDENT]if (draw == null || !draw.IsUserDrawn)
      {[/INDENT][INDENT=2]continue;[/INDENT][INDENT]}
      
      if (draw.IsSelected)
      {[/INDENT][INDENT=2]draw.Stroke = TestStroke;[/INDENT][INDENT]}[/INDENT]
        }
      sidlercom80
      NinjaTrader Ecosystem Vendor - Sidi Trading

      Comment


        #4
        Hello sidlercom80,

        Likely this will be the last object index in the DrawObjects collection.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi _ChelseaB, is there an eventhandler that is activated when adding a drawing object (line, rectangle etc.) to a chart? I would like to know if, for example, a line has been added to the chart.
          sidlercom80
          NinjaTrader Ecosystem Vendor - Sidi Trading

          Comment


            #6
            Hello sidlercom80,

            There is not. It would require unsupported code to add a property changed notification.

            Fortunately, there is an example with that worked out though.

            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi _ChelseaB, thank you for your help. I looked at the example and found that the line in the script (SamplePropertyChangedIndicator.cs) is always zero. The script is not executed from here, why?

              Click image for larger version

Name:	Screenshot_1.jpg
Views:	252
Size:	169.8 KB
ID:	1184499
              sidlercom80
              NinjaTrader Ecosystem Vendor - Sidi Trading

              Comment


                #8
                Hello sidlercom80,

                Possibly the object drawn was not a SamplePropertyChangedDrawingTool?

                What did you draw?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I wanted to draw a normal line, or rectangle. Do I get something wrong? Does the line have to be drawn from the "SamplePropertyChangedDrawingTool.cs" to be recognized?
                  sidlercom80
                  NinjaTrader Ecosystem Vendor - Sidi Trading

                  Comment


                    #10
                    Hello sidlercom80,

                    The sample code is comparing to SamplePropertyChangedDrawingTool.
                    using (SamplePropertyChangedDrawingTool line = e.NewItems[0] as SamplePropertyChangedDrawingTool)

                    If you want to find a line, then compare to a line and not the SamplePropertyChangedDrawingTool.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Thank you, I got it, thank you for your patience ;-)
                      sidlercom80
                      NinjaTrader Ecosystem Vendor - Sidi Trading

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      606 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      353 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      105 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      560 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      561 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X