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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      670 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      379 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      582 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X