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 cmoran13, 04-16-2026, 01:02 PM
    0 responses
    51 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    31 views
    0 likes
    Last Post PaulMohn  
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    165 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    100 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    160 views
    2 likes
    Last Post CaptainJack  
    Working...
    X