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

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:



    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:



        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 arvidvanstaey, Today, 02:19 PM
              4 responses
              11 views
              0 likes
              Last Post arvidvanstaey  
              Started by samish18, 04-17-2024, 08:57 AM
              16 responses
              59 views
              0 likes
              Last Post samish18  
              Started by jordanq2, Today, 03:10 PM
              2 responses
              9 views
              0 likes
              Last Post jordanq2  
              Started by traderqz, Today, 12:06 AM
              10 responses
              18 views
              0 likes
              Last Post traderqz  
              Started by algospoke, 04-17-2024, 06:40 PM
              5 responses
              47 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X