How to stop indicator drawing on every candle

 

My indicator draws on the first candle that matches the condition, but I don't want it to draw again on every following candle that matches the condition.  Is there some way to have it only draw the first time it matches a condition, but then not again until after the opposite condition is met?


Multiple candles

 
EagleWatchAU :

My indicator draws on the first candle that matches the condition, but I don't want it to draw again on every following candle that matches the condition.  Is there some way to have it only draw the first time it matches a condition, but then not again until after the opposite condition is met?



Enter a variable of type 'bool' and set it on 'condition 1' and omit it on 'condition 2'.

 
Vladimir Karputov #: Enter a variable of type 'bool' and set it on 'condition 1' and omit it on 'condition 2'.

Not good advice, as indicators operate in a loop. The variable must contain the previous bar's value, which means you loose the precondition when you update bar zero each tick.

EagleWatchAU: Is there some way to have it only draw the first time it matches a condition, but then not again until after the opposite condition is met?

Create a non-visible buffer and store your condition there.

 
William Roeder # :

Not good advice, as indicators operate in a loop. The variable must contain the previous bar's value, which means you loose the precondition when you update bar zero each tick.

Create a non-visible buffer and store your condition there.

Yes, it's better to remember the time of the bar at which the condition was met. And at the same time, you still have to have a variable in which the type of condition is stored.

In total, two variables are needed: one 'datetime' variable and one 'bool' type variable.