Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawingTools.Line same as HorizontalLine?

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

    DrawingTools.Line same as HorizontalLine?

    Hi there,
    As you can see my code outputed same line twice (with the same tag) even tho it's a horizontal line. Is this normal behavior?
    Thanks.
    Attached Files

    #2
    Hello Leeroy_Jenkins,

    Thank you for your post.

    This would be expected since HorizontalLine inherits from Line. You can use the dynamic approach found on this page to check whether it's a horizontal line:

    https://ninjatrader.com/support/help...assemblies.htm

    Code:
    foreach (IDrawingTool line in DrawObjects.ToList() )
    {
      // Use ToString().Equals() to detect the object's Type
      if (line.ToString().Equals("NinjaTrader.NinjaScript.DrawingTools.HorizontalLine"))
      {
          // Cast line as dynamic and access the object by assuming that it is the Type we expect
          Print(String.Format("Horizontal Line {0} detected!", (line as dynamic).Tag));
      }
    }
    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Got it.
      Is there any effective way to do something if user draws or changes existing drawing (moves, changes color etc)?

      Comment


        #4
        Hello Leeroy_Jenkins,

        Thank you for your reply.

        There's a good discussion on this thread with options on how to find newly drawn lines:

        https://ninjatrader.com/support/foru...nd-drawn-lines

        There wouldn't be an event when a user drawn object is changed to check for those changes, what changes are you looking to detect? You could just loop through periodically and grab the current values for the object.

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Oh I see.

          I'm trying to extend manually drawn Draw.Line() like this line.EndAnchor.SlotIndex += 1 (1 bar further) but it doesn't work.
          I know I can delete manually drawn line and make new one within the code but then I can't delete it bc this draw is a part of indicator.
          Is there any workaround?

          Comment


            #6
            Hm, I managed to change EndAnchor.Price. If wanna change end bar I must change price too bc this line isn't horizontal and price changes accordingly. Now I have to find this new price value.

            Comment


              #7
              Hello Leeroy_Jenkins,

              Thank you for your reply.

              <Anchor>.Time may also be modified.

              Just a heads up, the DrawObjects collection may not be populated when the chart is processing historical data.

              Here's an example script that modifies a user drawn line to extend 5 minutes further back and also modifies the start anchor price:

              Please let us know if we may be of further assistance to you.
              Attached Files
              Kate W.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jdr120, Today, 07:31 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by rcrook23, Today, 03:06 AM
              1 response
              16 views
              0 likes
              Last Post rcrook23  
              Started by jipsonmv, Today, 06:51 AM
              0 responses
              9 views
              0 likes
              Last Post jipsonmv  
              Started by harr5754, Today, 06:28 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by aelagha, Today, 12:21 AM
              0 responses
              20 views
              0 likes
              Last Post aelagha
              by aelagha
               
              Working...
              X