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 cmoran13, 04-16-2026, 01:02 PM
            0 responses
            43 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            25 views
            0 likes
            Last Post PaulMohn  
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            162 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            98 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            157 views
            2 likes
            Last Post CaptainJack  
            Working...
            X