Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing only appears on the last occurence of the pattern

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

    Drawing only appears on the last occurence of the pattern

    Hi,

    First of all - I have no coding experience. I would like to modify existing indicator so that instead painting bars - it would place a Diamond below or above the bar.

    In this indicator I've located a place

    case 2:
    BarBrushes[1] = _Color;
    BarBrushes[0] = _Color;
    break;

    When I place a phrase: "Draw.Diamond(this, "tag1", true, 0, Low[0] - TickSize, Brushes.Red);", above "break", Diamond actualy appears in correct spot but only on the last spot on the chart where the pattern occured. Meanwhile bars remained Painted for all the duration that is availalbe on the chart.
    How to make this Diamond to appear on all occurences on the chart instead of only the last one?

    Regards

    #2
    Hello Pabulon,

    Thank you for your post.

    The tag for a drawing object is a unique ID used to reference that specific drawing object. If you reuse the same tag, each time you call a drawing object the same drawing object will be referenced and the existing drawing object will be modified instead of a new object being created.

    For example, if you tag your drawing object “myTag”, each time you use “myTag” the same drawing object will be modified.

    To create a new drawing object, use a new unique string as the tag each time you call a Draw method. As an easy way to make a new string unique add ‘CurrentBar’ to the string.

    Help Guide: NinjaScript > Language Reference > Common > OnBarUpdate() > CurrentBar

    The code below will create a new red dot one tick below the low each time it is called.

    Code:
    Draw.Dot(this, "myTag" + CurrentBar, true, 0, Low[0] - TickSize, Brushes.Red);
    Please let us know if you have any further questions. ​

    Comment


      #3
      Wonderful advice, thank You very much.

      Is there a way of adding OutlineBrush in this single line:

      Code:
      Draw.Dot(this, "myTag" + CurrentBar, true, 0, Low[0] - TickSize, Brushes.Red);
      because Brushes.Red only deals with the Area

      Comment


        #4
        Hello Pabulon,

        Dots and Diamonds do not take an outline brush parameter. They can only be drawn in with one single color, there is no way to specify a different color for the outline with these methods unfortunately.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        64 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        40 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        166 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        101 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        162 views
        2 likes
        Last Post CaptainJack  
        Working...
        X