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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    93 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    138 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    123 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    73 views
    0 likes
    Last Post PaulMohn  
    Working...
    X