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

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
    BertrandNinjaTrader Customer Service

    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 Rogers101, Today, 11:30 AM
        0 responses
        8 views
        0 likes
        Last Post Rogers101  
        Started by MGHORBEL, Today, 11:16 AM
        0 responses
        1 view
        0 likes
        Last Post MGHORBEL  
        Started by michi08, Today, 08:51 AM
        2 responses
        12 views
        0 likes
        Last Post michi08
        by michi08
         
        Started by flybuzz, Today, 10:33 AM
        0 responses
        3 views
        0 likes
        Last Post flybuzz
        by flybuzz
         
        Started by algospoke, 02-19-2024, 03:25 PM
        6 responses
        42 views
        0 likes
        Last Post Abiodun
        by Abiodun
         
        Working...
        X