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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      89 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      47 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      74 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      72 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      60 views
      0 likes
      Last Post CarlTrading  
      Working...
      X