Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by tsantospinto, 04-12-2024, 07:04 PM
    5 responses
    67 views
    0 likes
    Last Post tsantospinto  
    Started by cre8able, Today, 03:20 PM
    0 responses
    6 views
    0 likes
    Last Post cre8able  
    Started by Fran888, 02-16-2024, 10:48 AM
    3 responses
    49 views
    0 likes
    Last Post Sam2515
    by Sam2515
     
    Started by martin70, 03-24-2023, 04:58 AM
    15 responses
    115 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by The_Sec, Today, 02:29 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X