Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Identifying drawing Tools in Strategies

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

    Identifying drawing Tools in Strategies

    Hi,
    I am developing a strategy, I add some drawing tools to my strategy (Horizontal line) and it works perfectly. However, when I add a horizontal line while the strategy is running, it cannot be identified in the strategy. Does exist any form that the strategy can identify horizontal lines without restarting the strategy?

    Code:
     protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
            {
                base.OnRender(chartControl, chartScale);
    
                foreach (DrawingTool draw in DrawObjects)
                {
                    if (draw is DrawingTools.HorizontalLine)
                    {
                        DrawingTools.HorizontalLine line = (DrawingTools.HorizontalLine)DrawObjects[draw.Tag];
    
                    }
                }
           }
    This the code that i have to identify the drawing tools on the Onrender method.

    Regards.

    #2
    Hello Richardmm,

    Thank you for the post.

    Kindly see this indicator that labels all horizontal lines on the chart. This indicator's OnRender method has what you will need to get all horizontal lines on the chart.



    We iterate through the ChartPanel's ChartObjects to find the horizontal line.

    Here is a stripped down version of the logic used to detect horizontal line objects:

    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    		{
    			foreach (Gui.NinjaScript.IChartObject thisObject in ChartPanel.ChartObjects)
    		  	{
    			  
    			  if(thisObject is NinjaTrader.NinjaScript.DrawingTools.HorizontalLine)
    			  {
    			  	 HorizontalLine l1 = thisObject as NinjaTrader.NinjaScript.DrawingTools.HorizontalLine;
    				 Print("Found a horizontal line");
    			  }
    			}
    		}
    To import the indicator mentioned above, please see this link:


    Please let me know if you have any questions about the material used here.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    87 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    132 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    65 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    118 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X