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

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.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ScottWalsh, Today, 06:52 PM
    3 responses
    20 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    19 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    1 view
    0 likes
    Last Post cre8able  
    Started by Haiasi, Today, 06:53 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by ScottW, Today, 06:09 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X