Error

 Previous Topic Next Topic
 sevenvironment #1 Posted : Wednesday, June 14, 2023 8:16:05 AM(UTC) Rank: NewbieGroups: Registered, Registered Users, SubscribersJoined: 3/27/2023(UTC)Posts: 6Location: istanbul hey everyone, i d like to count that condition via barssince , how could i do that ? If(Stoch(14,3)>=20 AND Stoch(14,3)<30,1,0) , i d like to see how many bars between that condition, if not plot  0 , if yes plot count number
 Wanna join the discussion?! Login to your Discussions forum accountor Register a new forum account.
 MS Support #2 Posted : Friday, June 16, 2023 8:46:01 PM(UTC) Rank: Advanced MemberGroups: Moderators, Registered, Registered Users, SubscribersJoined: 10/8/2010(UTC)Posts: 1,949Thanks: 89 timesWas thanked: 155 time(s) in 150 post(s) Originally Posted by: sevenvironment hey everyone, i d like to count that condition via barssince , how could i do that ? If(Stoch(14,3)>=20 AND Stoch(14,3)<30,1,0) , i d like to see how many bars between that condition, if not plot  0 , if yes plot count number  Hello,It might be best to combine ValueWhen and Cumulate functions. You would need to subtract the two conditions from each other, although depending on which one comes first, this could generate a positive or negative count.Code:``ValueWhen(1,Stoch(14,3)>=20,Cum(1)) - ValueWhen(1,Stoch(14,3)<30,Cum(1));`` If you want the number to always be expressed as a positive, you could wrap the Absolute Value function around the above.Code:``Abs(ValueWhen(1,Stoch(14,3)>=20,Cum(1)) - ValueWhen(1,Stoch(14,3)<30,Cum(1)));``
 Users browsing this topic
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.