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 SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      35 views
      0 likes
      Last Post SalmaTrader  
      Started by CarlTrading, 07-05-2026, 01:16 PM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 06-17-2026, 10:32 AM
      0 responses
      13 views
      0 likes
      Last Post CaptainJack  
      Started by kinfxhk, 06-17-2026, 04:15 AM
      0 responses
      19 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 06-17-2026, 04:06 AM
      0 responses
      22 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X