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 geddyisodin, Yesterday, 05:20 AM
    8 responses
    51 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by cmtjoancolmenero, Yesterday, 03:58 PM
    10 responses
    36 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by DayTradingDEMON, Today, 09:28 AM
    4 responses
    24 views
    0 likes
    Last Post DayTradingDEMON  
    Started by George21, Today, 10:07 AM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by Stanfillirenfro, Today, 07:23 AM
    9 responses
    25 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X