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 NullPointStrategies, Today, 05:17 AM
    0 responses
    53 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X