Recently i'm developing an indicator, and i need to get the barindex of the first time that indicator has triggered (it would trigger multiple of times, but i only need to get data of first time).
As shown in the picture, the indicator has triggered twice but i only need the barindex of first one and count how many times is has triggered.
Are there any buildin fuction to that (like barssince for counting bars) or any trick ?
Thx a lot for helping me.
@BaoBao1102 similar question has been covered thanks to @bobptz and @mradtke
So something like this,
Condition = // your indicator;
CountConditions = Cum(Condition);
FirstConditionBar = ValueWhen(CountConditions == 1 AND Condition, BarIndex());
I've done it by trick using barssince but your quoted solution is way better!
Thank you very much Portfoliobuilder