Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

draw-remove

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

    #16
    Bertrand,

    thank you for your reply. The lines are plotted correctly with
    DrawHorizontalLine("E" + CurrentBar, true, Position.AvgPrice - 2*TickSize, Color.Cyan, DashStyle.Solid,2);
    and should be removed with
    if(Position.MarketPosition == MarketPosition.Flat)
    {RemoveDrawObject("E");}

    What is wrong with this?

    Thanks
    Tony

    Originally posted by NinjaTrader_Bertrand View Post
    Tony, if you drawn lines are not removed properly, there would be 2 areas to check into -

    a) the tag being used for the drawing object
    b) the condition to remove

    Comment


      #17
      Tony, the tag is different. You include the CurrentBar in the creation tag, this has to be reflected in the remove as well.
      BertrandNinjaTrader Customer Service

      Comment


        #18
        Originally posted by tonynt View Post
        Bertrand,

        thank you for your reply. The lines are plotted correctly with
        DrawHorizontalLine("E" + CurrentBar, true, Position.AvgPrice - 2*TickSize, Color.Cyan, DashStyle.Solid,2);
        and should be removed with
        if(Position.MarketPosition == MarketPosition.Flat)
        {RemoveDrawObject("E");}

        What is wrong with this?

        Thanks
        Tony
        Your tag is quasi-dynamic/unique. From what you describe, it seems that you want exactly one line for entry and one line for exit. If so, then use fixed tags: e.g., "Entry" and "Exit" respectively. Otherwise, you have to capture the tag at entry, so that you can reference the correct tag to delete. The alternative is to make those IHorizontalLine objects, in which case, you can remove the object by specifying its name. (That latter is not in the documentation, but exposed by Intellisense ).

        Comment


          #19
          Thank you for your reply, both.

          I didn´t understand that "currentbar" is part of the name. Clear now.

          Sorry that question now: what is the difference of drawing with "x+Currentbar" or only "x"? (I searched for an answer to this now, but couldnt find)

          Thanks
          Tony

          Originally posted by koganam View Post
          Your tag is quasi-dynamic/unique. From what you describe, it seems that you want exactly one line for entry and one line for exit. If so, then use fixed tags: e.g., "Entry" and "Exit" respectively. Otherwise, you have to capture the tag at entry, so that you can reference the correct tag to delete. The alternative is to make those IHorizontalLine objects, in which case, you can remove the object by specifying its name. (That latter is not in the documentation, but exposed by Intellisense ).

          Comment


            #20
            Originally posted by tonynt View Post
            Thank you for your reply, both.

            I didn´t understand that "currentbar" is part of the name. Clear now.

            Sorry that question now: what is the difference of drawing with "x+Currentbar" or only "x"? (I searched for an answer to this now, but couldnt find)

            Thanks
            Tony
            The value of CurrentBar changes with every bar drawn (monotonically increasing with a difference of 1), so "x + CurrentBar" is not a fixed value; "x" on the other hand is necessarily fixed.

            Comment


              #21
              koganam,

              thanks for your reply. So, I assume the "x+currentbar" is important if you need to count inside the script (?) For the drawing the line "x" and "x+currentbar" seem to be the same after testing. Or do you know a practical example when "x+currentbar" make sense then?

              Best
              Tony

              Originally posted by koganam View Post
              The value of CurrentBar changes with every bar drawn (monotonically increasing with a difference of 1), so "x + CurrentBar" is not a fixed value; "x" on the other hand is necessarily fixed.

              Comment


                #22
                Originally posted by tonynt View Post
                koganam,

                thanks for your reply. So, I assume the "x+currentbar" is important if you need to count inside the script (?) For the drawing the line "x" and "x+currentbar" seem to be the same after testing. Or do you know a practical example when "x+currentbar" make sense then?

                Best
                Tony
                Maybe I am not understanding what you are saying. Adding CurrentBar as part of the tag serves to create a unique tag, tied to the bar on which the event which caused the drawing to be made to occur. Every one of the drawings is then unique and represents a different object. The net effect would be to create a new drawing on every bar on which the draw condition is met, as opposed to the situation where there is only a fixed tag, in which case at any given time, there can exist only the one and most current drawObject.

                How you create objects is a direct result of what you intend. If you want multiple objects, you need to use unique tags to identify said objects: if you want a single mutable object, you need an immutable tag.

                Comment


                  #23
                  Hello,

                  thanks for your reply. I think the misunderstanding is on my end. As one can do unique tags with Draw...("A") or Draw ("B").....or Draw("Z999")............. why should one need to add the current bar to make it unique? There´s only one ("A"). Isnt that unique?

                  Thanks and best regards
                  Tony

                  Originally posted by koganam View Post
                  Maybe I am not understanding what you are saying. Adding CurrentBar as part of the tag serves to create a unique tag, tied to the bar on which the event which caused the drawing to be made to occur. Every one of the drawings is then unique and represents a different object. The net effect would be to create a new drawing on every bar on which the draw condition is met, as opposed to the situation where there is only a fixed tag, in which case at any given time, there can exist only the one and most current drawObject.

                  How you create objects is a direct result of what you intend. If you want multiple objects, you need to use unique tags to identify said objects: if you want a single mutable object, you need an immutable tag.

                  Comment


                    #24
                    You don't have to use CurrentBar added to generate unique tags, but it's used for it's simplicity normally.

                    You just have to keep in mind if you reuse an old tag > it will just update the old object - where as using a new, unique tag > it would create a new object. So in your case, if you're ok with just seeing the last (current) drawing, keep using one tag and just update.

                    http://www.ninjatrader.com/support/f...ead.php?t=3419
                    BertrandNinjaTrader Customer Service

                    Comment


                      #25
                      Originally posted by tonynt View Post
                      ........... why should one need to add the current bar to make it unique? There´s only one ("A"). Isnt that unique?

                      Thanks and best regards
                      Tony
                      You do not need to do anything. How you make your tags unique is up to you. As every bar can have only one identifying value as to its count in the chart, using CurrentBar simply guarantees that the tag will be unique, and removes the need to think and remember what tags have already been used, so as to avoid reusing them or otherwise ensure uniqueness.

                      I prefer simple methods; your preference may be different. I was simply explaining why the way that you had written your code was producing the results that you were seeing, not telling you that you need to ensure uniqueness in any particular way.

                      Comment


                        #26
                        Thank you for your help!

                        Understood now what is the advantage of currentbar!

                        My questions to different kind of drawing were because I try to simulate the chart-trader in my scripts (draw line for entry and initial stop, remove line of initial stop once...and draw a new line with stopvariable1........)

                        Thank you guys for your help and thank you koganam for your clear explanation.

                        Have a great weekend!
                        Tony

                        Originally posted by koganam View Post
                        You do not need to do anything. How you make your tags unique is up to you. As every bar can have only one identifying value as to its count in the chart, using CurrentBar simply guarantees that the tag will be unique, and removes the need to think and remember what tags have already been used, so as to avoid reusing them or otherwise ensure uniqueness.

                        I prefer simple methods; your preference may be different. I was simply explaining why the way that you had written your code was producing the results that you were seeing, not telling you that you need to ensure uniqueness in any particular way.
                        Last edited by tonynt; 10-12-2012, 03:02 AM. Reason: clearify

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by ezrollin, Today, 08:51 PM
                        1 response
                        24 views
                        0 likes
                        Last Post bltdavid  
                        Started by Rubix, Today, 09:31 PM
                        0 responses
                        15 views
                        0 likes
                        Last Post Rubix
                        by Rubix
                         
                        Started by ark321, Today, 05:12 PM
                        1 response
                        22 views
                        0 likes
                        Last Post NinjaTrader_EricB  
                        Started by futurenow, Today, 09:08 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post futurenow  
                        Started by fafafdenis, Today, 04:56 PM
                        1 response
                        5 views
                        0 likes
                        Last Post NinjaTrader_EricB  
                        Working...
                        X