Price Up/Down Price Ratio

R

Rider

New member
For a watchlist column I am trying to identify the price ratio of up bars divided by down bars over a period of time (say 21 days). I have the following code for the up days but do not know how to add the period of 21 days. Thanks for the help!

def price = close;
def barup = close> close [1];
def bardwn = close< close [1];
def barUpcount = (if barup > bardwn then barup[1] +1 else 0);

plot barsupcount = (if barupcount >0 then barupcount else 0);
 

Similar threads

Top