PriorMember
New member
def upDaysVolume = Sum(If(close > close[1], volume, 0), 50);
def downDaysVolume = Sum(If(close < close[1], volume, 0), 50);
def upDownRatio = upDaysVolume / downDaysVolume;
AddLabel(yes, Concat("Up/Down Ratio: ", upDownRatio), if upDownRatio > 1 then Color.GREEN else Color.RED);
This code calculates the up/down ratio by dividing the total volume of trades on days when the stock price increased (up days) by the total volume of trades on days when the stock price decreased (down days) over a period of 50 trading days.
def downDaysVolume = Sum(If(close < close[1], volume, 0), 50);
def upDownRatio = upDaysVolume / downDaysVolume;
AddLabel(yes, Concat("Up/Down Ratio: ", upDownRatio), if upDownRatio > 1 then Color.GREEN else Color.RED);
This code calculates the up/down ratio by dividing the total volume of trades on days when the stock price increased (up days) by the total volume of trades on days when the stock price decreased (down days) over a period of 50 trading days.