Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

finding certain objects within an indicator

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

    finding certain objects within an indicator

    I have a script that I wrote and works well, but the issue arrives when I add a second indicator.

    //this script is within the OnRender
    foreach (Gui.NinjaScript.IChartObject thisObject in ChartPanel.ChartObjects)

    {}

    I am looking for a certain object on the ChartPanel, but how can I look for the ChartObject ONLY within the indicator not the whole chart?

    #2
    Hello ballboy11,

    I've modified the sample from the help guide to show if the object is attached to this indicator.

    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    base.OnRender(chartControl, chartScale);
    IList<Gui.NinjaScript.IChartObject> myObjects = ChartPanel.ChartObjects;
    
    Print("myObjects.Count(): " + myObjects.Count());
    
    foreach (Gui.NinjaScript.IChartObject thisObject in myObjects)
    {
    Print(String.Format("{0} is of type {1}", ((thisObject as IDrawingTool) != null) ? (thisObject as IDrawingTool).Tag : thisObject.Name, thisObject.GetType()));
    if ((thisObject as IDrawingTool) != null && (thisObject as IDrawingTool).AttachedTo.ChartObject == this)
    {
    Print("attached to this indicator");
    }
    }
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you I needed this part of the script

      && (thisObject as IDrawingTool).AttachedTo.ChartObject == this

      Comment

      Latest Posts

      Collapse

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