Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Chart Object Infomation

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

    Chart Object Infomation

    Hi NT-8,

    I am looking to get some info on the objects rendered on one of my charts .. I can do the following .. but what other info is stored and how to list all stored data for each onject ?

    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    
      base.OnRender(chartControl, chartScale);
      IList<Gui.NinjaScript.IChartObject> myObjects = ChartPanel.ChartObjects;
      foreach (Gui.NinjaScript.IChartObject thisObject in myObjects)
      {
          if(thisObject.Name == "someobject name){
               Print(String.Format("name :{0} type: {1}", thisObject.Name, thisObject.GetType() ));
          }  
       }
    
    }
    thanks in advance!




    #2
    Hello 12tkram,

    It would depend on what object you are looking at as to what info would be available. For drawing tools you can review the relevant help guide page for that tool to see what properties it may have, alternatively you can look at the public properties in the drawing tools code using the NinjaScript editor.

    There are some examples of getting drawing tool properties in the following link: https://ninjatrader.com/support/help...ub=drawobjects

    An example of Lines properties: https://ninjatrader.com/support/helpGuides/nt8/line.htm

    There are other inherited properties from the drawing tool base class which can be accessed in a generic way using DrawingTool type.

    Other items that show up in the general chart objects list may be more difficult to find help information about, for those types you can try to make a dummy variable to explore using intelleprompt.
    An example would be like the following:

    Line line;
    then type: line.
    The period after line variable will cause the intelleprompt for that type will appear.

    In the code you provided all objects are Gui.NinjaScript.IChartObject so if you wanted specific properties from a specific type you would have to also cast from the Gui.NinjaScript.IChartObject to the correct type. The above linked drawing objects example shows some casts being used.



    I look forward to being of further assistance.

    Comment


      #3
      Thanks Jesse and I think thats the problem, the docs do not go into enough details on the trypes of objects or how to dump all the info for each specific object type, or even how to determine what the object type is or how it was drawn .. is there a trace facility I could use ? I could filter the specific objects by name ( they show using the loop code above, but they do not show up as a specific type of object i.e. line/text etc ) then dump all info for that object ?

      Maybe if I explain what I am trying to achieve, I have an indicator that prints different objects on a chart, I would like to count each object to keep a tally or each type, but I don't know how to group them using the info I get out of the loop becauase they all show up with the same name and type, so dumping all the info for each object could give me a handle on how to group them so I can keep a count, then I can alert on specific types and counts etc .. does that make sense ?

      thanks again for your response so far

      Comment


        #4
        Hello 12tkram,

        The docs really don't go into that type of detail. NinjaScript is just C# so having a good foundation of previous C# experience will help a lot for exploring objects. What you are asking about is exploring types which can be done in the NinjaScript editor or visual studio by using the intelleprompt/intellesense. In visual studio you can also use the class explorer.

        To count each type of object you wouldn't need to know anything about the objects, just what type they are to categorize them in your loops conditions. If you mean drawing objects you could just use the loop sample that we have in the help guide for that specifically.


        Code:
        foreach (DrawingTool draw in DrawObjects.ToList())
        {
            if (draw is DrawingTools.Line)
            {
            }
        }
        You can also see the following example which is how you would find objects if you exported your code as an assembly which requires you to not use casts. You can get the type as a string instead:

        Code:
        foreach (IDrawingTool line in DrawObjects.ToList())
        {
            if (line.ToString().Equals("NinjaTrader.NinjaScript.D rawingTools.HorizontalLine"))
            {
                  Print(String.Format("Horizontal Line {0} detected!", (line as dynamic).Tag));
            }
        }


        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        597 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        555 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X