Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

take action on a true statement, but only on the more recent occurence

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

    take action on a true statement, but only on the more recent occurence

    Hi,
    i have a "count if" statement, the confirmation of which instructs nt to count the candles backwards from [0]. However, the statement proves true in clusters due to the sequential nature.
    How might I only draw text with regards to the most recent occurence in the group? Please see attached.
    thanks,
    David

    if(CountIf(() => Close[0] < Close[4], 9) == 9)
    {
    Draw.Text(this, Convert.ToString(CurrentBars[0]) + @" cdCount_9", "9", 0, (Low[0] + (-4 * TickSize)), Brushes.Lime);
    Draw.Text(this, Convert.ToString(CurrentBars[0]) + @" cdCount_8", "8", 1, (Low[0] + (-4 * TickSize)), Brushes.Lime);
    Draw.Text(this, Convert.ToString(CurrentBars[0]) + @" cdCount_7", "7", 2, (Low[0] + (-4 * TickSize)), Brushes.Lime);
    Draw.Text(this, Convert.ToString(CurrentBars[0]) + @" cdCount_6", "6", 3, (Low[0] + (-4 * TickSize)), Brushes.Lime);
    Draw.Text(this, Convert.ToString(CurrentBars[0]) + @" cdCount_5", "5", 4, (Low[0] + (-4 * TickSize)), Brushes.Lime);
    Draw.Text(this, Convert.ToString(CurrentBars[0]) + @" cdCount_4", "4", 5, (Low[0] + (-4 * TickSize)), Brushes.Lime);
    Draw.Text(this, Convert.ToString(CurrentBars[0]) + @" cdCount_3", "3", 6, (Low[0] + (-4 * TickSize)), Brushes.Lime);
    Draw.Text(this, Convert.ToString(CurrentBars[0]) + @" cdCount_2", "2", 7, (Low[0] + (-4 * TickSize)), Brushes.Lime);
    Draw.Text(this, Convert.ToString(CurrentBars[0]) + @" cdCount_1", "1", 8, (Low[0] + (-4 * TickSize)), Brushes.Lime);
    }​
    Attached Files

    #2
    Hello trader3000a,

    The reason that it appears in clusters is that the condition continues to be true for those bars. Each new bar where the condition is true you are drawing a new set of objects.

    The tag name being used changes per bar so that would be one item to start with, if you maintain the same tag name then the objects which were drawn on previous bars would get updated and moved. If you can use a variable for the name which stays the same for that period of time you could limit the drawing to 1 set of objects because the last time the condition is true it will update the objects so they represent the last instance of the condition.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    63 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    87 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    47 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    105 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    63 views
    0 likes
    Last Post PaulMohn  
    Working...
    X