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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X