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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      217 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      133 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      147 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      233 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      192 views
      0 likes
      Last Post CarlTrading  
      Working...
      X