Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChartControl.ChartObjects contains not all drawing objects

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

    ChartControl.ChartObjects contains not all drawing objects

    Hi,
    when I try to get all drawing objects, I get only the objects placed on viewable area of chart and to the left of it. All objects placed to the right of the viewable area does not includes in ChartControl.ChartObjects if it did not shown on the chart after chart refresh.
    How I can get it?

    My code:
    Code:
    foreach (ChartObject co in ChartControl.ChartObjects)
    {
    
    //My code
    }

    #2
    Hello Higeker,

    Thanks for opening the thread.

    Using the sample code provided in the ChartObjects documentation, I have been able to loop through a list containing draw objects in ChartPanel.ChartObjects. I am also observing that this is printing for draw objects that are beyond the visible are of a chart.

    Are you still running into the same issues when applying this code to an indicator?

    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
      base.OnRender(chartControl, chartScale);
     
      IList<Gui.NinjaScript.IChartObject> myObjects = ChartPanel.ChartObjects;
     
      foreach (Gui.NinjaScript.IChartObject thisObject in myObjects)
      {
          Print(String.Format("{0} is of type {1}", thisObject.Name, thisObject.GetType()));
      }
    }


    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you for answer!
      I use NT7 and I did not found OnRender there.
      I try to get all chart objects from timer event handler.

      Comment


        #4
        Hello Higekker,

        Oops, I guess I'm in the wrong forum! Thanks for pointing that out.

        I used your same loop to print the Tag of co, and I can see prints for chart drawing objects that have been placed past the current bar whether or not that Chart Object is visible.

        I have made a barebones indicator with your loop in OnBarUpdate() to achieve this. Here is what I did:
        Code:
        protected override void OnBarUpdate()
        {
        	foreach (ChartObject co in ChartControl.ChartObjects)
        	{
        		Print(co.Tag);
        	}
        }
        Please let me know if you are not getting prints for your Chart's drawing objects. Also, are these drawing objects all manually drawn or from NinjaScripts? Can you confirm if one is printing or the other?

        I look forward to assisting further.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cre8able, Today, 01:01 PM
        0 responses
        2 views
        0 likes
        Last Post cre8able  
        Started by manitshah915, Today, 12:59 PM
        0 responses
        3 views
        0 likes
        Last Post manitshah915  
        Started by ursavent, Today, 12:54 PM
        0 responses
        3 views
        0 likes
        Last Post ursavent  
        Started by Mizzouman1, Today, 07:35 AM
        3 responses
        17 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by RubenCazorla, Today, 09:07 AM
        2 responses
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X