logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
sevenvironment  
#1 Posted : Wednesday, June 14, 2023 8:16:05 AM(UTC)
sevenvironment

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 3/27/2023(UTC)
Posts: 6
Location: 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 

MS Support  
#2 Posted : Friday, June 16, 2023 8:46:01 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,960

Thanks: 91 times
Was thanked: 155 time(s) in 150 post(s)
Originally Posted by: sevenvironment Go to Quoted Post

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
Guest (Hidden)
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.