Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculate swing max from min distance over last 10 bars

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

    Calculate swing max from min distance over last 10 bars

    Hi, I really need some help in my strategy. I want to know how to calculate what the greatest swing amount was (max to min) over the last 10 bars. I don't want to include the endpoints (open price of first bar and close price of last bar), I am just looking for the highest swing price amount from the highest swing.

    My reason for this is I want to gather a set of data to determine what the average price change is so that I can set a trailing stop properly.

    I know I can use the swing() function, but I need some assistance to get me on the right track.

    Really appreciate any help!

    David

    #2
    Welcome to our forums David - we would unfortunately not be aware of a shared study that would already implement this. The Swing indicator would allow you to access prior instances of swings (either giving the swing value or the bars back on which the swing was found), so from the you could for example calculate the avg in a custom list for those swing found. But since the swing would update past calculations as new data is seen in realtime, it can be challenging to work with programmatically (more a visual tool for the swing structure identification).



    Another more direct approach to set stops and targets could be perhaps working with the avg daily range of your market like this study in our sharing proposes - http://www.ninjatrader.com/support/f...d=1&linkid=242

    Comment


      #3
      ok got it. I will go a different direction. Thank you.

      Comment


        #4
        What about using Average True Range for this?

        Hi ktmdave,

        Not sure if you're still monitoring this thread, but I was reading your post and I had a thought about ATR. Have you see the ATR Trailing Stop indicator available in the NinjaTrader Version 7 indicators section of this forum?

        You mention you're looking for an "average" of the last x number of trades. That's going to be exactly what ATR will give you.

        A trader I know uses ATR to let him know the maximum swing he can expect in the next bar. He does this be referencing the ATR (average true range) of the previous four 5-minute candles and he sets his profit target and stop loss according to that number.

        In other words, on the ES for example, if the ATR is 2, he knows that's all he should expect in terms of future swings in the near term.

        Not sure if this is helpful, or if you're even monitoring the thread, but if you are, you may want to give the ATR indicator or its methods a look to see if it can do what you're looking to do. It seems to me it would do it. And definitely check out that ATR Trailing Stop indicator available by going to the main page of this forum and clicking on "Version 7 Indicators" and then doing a search on "ATR."

        Hope this helps you!

        -V

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sjsj2732, Yesterday, 04:31 AM
        0 responses
        31 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        286 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        283 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        133 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        91 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X