Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

get value from IDrawObject

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

    get value from IDrawObject

    saw this snip from Josh a while back ... references some new functionality in NT7 ... curious to know if this made it into the features and how one can read the current value of a draw object:

    NT7 will have some enhancements:
    "
    Draw Objects Enhancements
    Draw objects are now associated to an indicator which means that if a user removes a draw object from the chart, it will also remove the indicator. In addition, all draw objects spawned from an indicator share the indicator's z-order.
    IDrawObject - IDrawObjects are now returned to the caller on all Draw() methods. IDrawObjects expose draw objects properties.
    Work in progress - We will implement programmatic access to draw objects added to a chart manually. For example, you can have a user draw a line on a chart and add a "tag" to this object and you can retrieve this object, read it's value and do something with it."
    cf. http://www.ninjatrader.com/support/f...27&postcount=5

    cheers,
    -e

    #2
    Hi e-man,

    Yes, you can access these using "IDrawObject"
    More info at - http://www.ninjatrader.com/support/h...drawobject.htm

    For a line, you can access "Iline"
    More info at - http://www.ninjatrader.com/support/h...html?iline.htm
    TimNinjaTrader Customer Service

    Comment


      #3
      Hi Tim,

      thanks for the link -- not seeing a signature to pull the current value. is that supported?

      i have drawn a horizontal line and unlocked it so it can be moved around by user. next step is to programatically read the new value. does that make sense?

      cheers,
      -e

      Comment


        #4
        Hi e-man,

        Can you perhaps use IHorizontalLine for that - http://www.ninjatrader.com/support/h...zontalline.htm

        If not, please clarify what you are trying to do.
        TimNinjaTrader Customer Service

        Comment


          #5
          fantastic -- that did the trick.

          just in case anyone else needs the code, the following filters out user-drawn lines and resync's system-drawn values to local variables:

          Code:
          foreach (IDrawObject draw in DrawObjects)
          {
              if (!draw.UserDrawn && draw.DrawType == DrawType.HorizontalLine)
              {
                  IHorizontalLine hline = (IHorizontalLine)draw;
                  double nBand = hline.Y;
                  
                  switch (draw.Tag)
                  {
                      case "line1_name":
                              _Line1_local_var = nBand;
                              break;
                   
                      case "line2_name":
                              _Line2_local_var = nBand;
                              break;
              
                      // repeat for each additional line
                      
                      default:
                              break;
                  }
              }
          }
          this assumes that the lines are "unlocked" ... i adapted this code from the user-guide and call this one time when CurrentBar == 0:
          Code:
          foreach (IDrawObject draw in DrawObjects)
          {
              if (!draw.UserDrawn && draw.DrawType == DrawType.HorizontalLine && draw.Locked)
              {
                  draw.Locked = false;
              }
          }
          cheers,
          -e
          Last edited by e-man; 06-24-2010, 02:57 PM. Reason: missing cast to IHorizontalLine

          Comment


            #6
            Hi e-man,

            Nicely implemented, and thank you for posting!
            TimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            574 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            332 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            553 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X