Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

IDrawObject-accessing generated draw objects

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

    IDrawObject-accessing generated draw objects

    I am using the standard

    foreach (IDrawObject draw in DrawObjects)
    {
    // do whatever here...

    }

    code in order to enumerate drawing objects on my chart The NT documentation says we can access the objects that have been manually drawn or script drawn.

    I have an indicator that draws arrows for price turns. I was wanting to analyze them via a script. It seems I can only pulls the drawing objects via this technique that I manually place on the chart and none of the objects my script put on the chart.

    Does anyone have a code example or can tell me how to access the script generated draw objects?

    Thanks,
    Ed

    #2
    sideflakeopal,

    I am happy to assist you.

    I just wanted you to know I am doing some tests on my end to see if I can replicate the behavior.

    Meanwhile, here are some links to reference samples on using drawing objects :



    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Adam,

      Thanks. I had already looked at the reference samples.

      I ended up stepping through my code via the VS debugger and never got an object that I had not drawn manually.

      I used a very simple set up:
      6 range YM chart, 500 bars of data, I drew some arrows, some text, and then put anaSuperTrend (on the forum) and it puts up arrows where it sees trend turns. Lot of arrows.

      I have attached the hack I had written to do this so you can see what I am doing. It looks pretty simple to me.

      When I step into this the number of IDrawObjects always matches the number of items I have drawn on the chart manually even if anaSuperTrend has written tons of them.

      Thanks again,

      Ed
      Attached Files

      Comment


        #4
        Hi Ed, are the programmatic ones you wish to access created by the IDrawObject interface then?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Originally posted by sideflakeopal View Post
          I am using the standard

          foreach (IDrawObject draw in DrawObjects)
          {
          // do whatever here...

          }

          code in order to enumerate drawing objects on my chart The NT documentation says we can access the objects that have been manually drawn or script drawn.
          the above code can read the objects as drawn manually or drawn by itself (i.e. the same ninja script code which reads the objects). it cannot read objects as drawn by other ninjascripts.

          instaed of DrawObjects use ChartControl.DrawObjects

          Comment


            #6
            Bertrand,

            You can look at anaSuperTrend.cs and see how they are created. The Arrow drawing methods are used.

            Ed

            Comment


              #7
              Thanks for clarifying Ed, I looked into it and bukkan is spot on here - we are purposely not allowing scripts to access another scripts drawing objects, so malicous code could not influence smoothly running ones.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                You might consider documenting that.

                Reading only and not modifying arrow or whatever locations and such off of charts, which is what I thought was ok would allow me to run performance analysis on indicators without having to code them up as a strategy. That would have been nice.

                I can do that manually, getting the values off the charts, so it is not like there is any information hidden. That is really a stone age process.

                Thanks,

                Ed

                Comment


                  #9
                  Thanks for the feedback here Ed, I'll make sure this gets clearer noted in our docs.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by sideflakeopal View Post
                    You might consider documenting that.

                    Reading only and not modifying arrow or whatever locations and such off of charts, which is what I thought was ok would allow me to run performance analysis on indicators without having to code them up as a strategy. That would have been nice.

                    I can do that manually, getting the values off the charts, so it is not like there is any information hidden. That is really a stone age process.

                    Thanks,

                    Ed
                    DrawObjects with no qualifier (or any objects for that matter), default to this.DrawObjects. You might want to try using ChartControl.DrawObjects. The usual caveat that all ChartControl is undocumented and unsupported by NT support applies.

                    Comment


                      #11
                      Originally posted by koganam View Post
                      ChartControl.DrawObjects.
                      Thank You, koganam!
                      I'd like to correct a little Your post - not ChartControl.DrawObject, but ChartControl.ChartObject.

                      This code works grate for me:

                      Code:
                      [COLOR="Blue"]foreach[/COLOR]( ChartObject o [COLOR="blue"]in[/COLOR] ChartControl.ChartObjects ){ 
                      [COLOR="blue"]if[/COLOR]( o.DrawType == DrawType.Text ){ IText txt = (IText)o;  Print( txt.Text ); }
                      }
                      Last edited by fx.practic; 10-29-2013, 09:23 AM.
                      fx.practic
                      NinjaTrader Ecosystem Vendor - fx.practic

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by PaulMohn, Today, 12:36 PM
                      1 response
                      12 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by yertle, Yesterday, 08:38 AM
                      8 responses
                      36 views
                      0 likes
                      Last Post ryjoga
                      by ryjoga
                       
                      Started by rdtdale, Today, 01:02 PM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_LuisH  
                      Started by alifarahani, Today, 09:40 AM
                      3 responses
                      16 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by RookieTrader, Today, 09:37 AM
                      4 responses
                      19 views
                      0 likes
                      Last Post RookieTrader  
                      Working...
                      X