Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating Swing Volume

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Calculating Swing Volume

    Dear Support,

    Looking for a sample expression to calculate a swing total volume.

    I am using the following example code to return the sum of the values for the Volume taken over the swing period between the swing high and the swing low. Then the value is printed as Draw.Text over the Swing high:

    double swingVolume = SUM(Volume, SwingHighBar - SwingLowBar)[CurrentBar - SwingHighBar]); where the period is the difference between swing high/low index bars

    This approach works fine. however sometimes an error is generated that the "period" for "SUM" is a negative value.

    Any idea or referring to a sample script to calculate the Swing total volume correctly is appreciated.

    Thanks.



    #2
    Hi aligator, thanks for your note.

    The negative value is coming from this calculation:
    SwingHighBar - SwingLowBar

    So the trivial way of fixing it would be to only do the calculation when SwingHighBar >= SwingLowBar

    Unfortunately, I'm not aware of any script doing this already.

    Please let me know if I can assist any further.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    612 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    355 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    561 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    564 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X