Up/Down volume

Optuma Forums Optuma Scripting Up/Down volume

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #67237
    Pentti
    • Topics: 2
    • Replies: 2
    • Posts: 4

    I have following Pine script in TradingView to calculate Up/Down volume ratio and I would like covert it to Optuma script.

    upVol = sum(change(close) > 0 ? volume : 0, 50)
    downVol = sum(change(close) < 0 ? volume : 0, 50)
    ratio = upVol/downVol

    I guess ACC function could be used to calculate volume over last 50 days but how to separate up/down days volume?

    ACC(VOL(), BARS=50)

    #67247
    Darren
    • Topics: 69
    • Replies: 742
    • Posts: 811

    Hi Pentti,

    You can use IF statements to separate up from down days, and sum the values for each:

    Use in a Show View and set the Positive/Negative Barriers to 1 to show the ratio:

    Capture

    #67257
    Pentti
    • Topics: 2
    • Replies: 2
    • Posts: 4

    Thank you Darren!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest