Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

draw-remove

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

  • tonynt
    replied
    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, 04:02 AM. Reason: clearify

    Leave a comment:


  • koganam
    replied
    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.

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    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

    Leave a comment:


  • tonynt
    replied
    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.

    Leave a comment:


  • koganam
    replied
    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.

    Leave a comment:


  • tonynt
    replied
    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.

    Leave a comment:


  • koganam
    replied
    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.

    Leave a comment:


  • tonynt
    replied
    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 ).

    Leave a comment:


  • koganam
    replied
    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 ).

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    Tony, the tag is different. You include the CurrentBar in the creation tag, this has to be reflected in the remove as well.

    Leave a comment:


  • tonynt
    replied
    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

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    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

    Leave a comment:


  • tonynt
    replied
    koganam,

    thanks for your reply.

    Yes, this was the simple question at the beginning and the easy solution. I wrote in every post "DrawHorizontalLine" but from NT-support I got the answer how to draw the arrows for entries and exits (which of course are drawn by NT, and no need to to in a script) therefore the discussion.

    So, I try to draw the entries,stops and targets with lines in my script (like visible if you would do the trade with charttrader). But I still have the issue that eg my DrawHorizontalLine("E",.....); is not removed from the chart eg
    ...when flat.... RemoveDrawObject("E");

    My HorizontalLines are there forever;-)

    Any hint for me how to remove? Thanks in advance.

    Best
    Tony
    Last edited by tonynt; 10-11-2012, 03:44 AM. Reason: clearify

    Leave a comment:


  • koganam
    replied
    Originally posted by tonynt View Post
    Adam,

    thank you for your reply.

    Referring the drawing of the horizontal line at entryprice I do not understand what you mean. What do I have to change in my "DrawHorizontalLine("Line1" + Current Bar, true, Low[0]-2+TickSize, Color.White, DashStyle.Dash,2);" when I dont want to have drawn the line at Low [0] or below Low [0] BUT at the price where entry is done?

    Thanks
    Tony
    So change the Low[0]-2+TickSize to your entry price. Am I missing something here?

    Leave a comment:


  • NinjaTrader_AdamP
    replied
    Tony,

    You could do something like this :

    DrawHorizontalLine("MyLine", GetCurrentBid() , Color.Green);

    Or you can trade "GetCurrentBid()" with "GetCurrentAsk()"

    OR "Close[0]" if CalculateOnBarClose = false since this will be the "last" price.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by MatthewLesko, Today, 12:12 AM
0 responses
3 views
0 likes
Last Post MatthewLesko  
Started by Teebone21, Yesterday, 11:28 PM
0 responses
2 views
0 likes
Last Post Teebone21  
Started by newton1, Yesterday, 08:28 PM
0 responses
2 views
0 likes
Last Post newton1
by newton1
 
Started by jjanguda, Yesterday, 06:20 PM
0 responses
7 views
0 likes
Last Post jjanguda  
Started by TaZ22, Yesterday, 11:32 AM
5 responses
29 views
0 likes
Last Post bltdavid  
Working...
X