Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw fib retracement using swing indicator

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

    Draw fib retracement using swing indicator

    I have this bit of code that outputs swing highs and lows. Everything works fine when strength is set to 10 and 20. If I set the strength to 50, I get this error and the strategy shuts down. Testing is currently being done on live data.

    #2
    Hello jableshank,

    Thank you for your post.

    The first thing I would suggest is printing the value of LowBarsAgo right before you try to print Low[LowBarsAgo - what do you get printed for this value?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate,
      Thanks for your reply. in the attached photo, the value can be seen where it says "occurred x bars ago"

      Comment


        #4
        Hello jableshank,

        Thank you for your reply.

        To clarify, we want to try printing that LowBarsAgo value before that "The low at" print so we know what it is before using it as the bars ago to retrieve the low from. If that's coming out to a negative number, since SwingLowBar returns a value of -1 if a swing point is not found within the look back period, and you try to use that to get the Low of a bar in the future that doesn't exist yet, you're going to get an error. If you print that value do you see it printing -1 just before the error occurs?

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Print(Swing(50).SwingLowBar(0, 1, 1000)); is returning -1. However Print(Swing(20).SwingLowBar(0, 1, 1000)); returns 41. I'm not too sure why that is as I can set the Swing indicator strength to 50 on the chart and it clearly shows the highs and lows.

          Comment


            #6
            Hello jableshank,

            Thank you for your reply.

            The greater the Strength value the longer it looks back to find a swing low/high, but the swings also last longer the higher the strength. If you add a Swing set to 50 to a chart, you'll see these really long swing plots - it's simply more unlikely that both a swing high or low will be found in that period. I would suggest printing something else if no swing is found, perhaps just a message saying "no swing low found" or something to that effect. But you'll have to check what those BarsAgo values are before printing them or every time no swing low or swing high is found you'll get this error.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by herzogvladimir2, Yesterday, 08:10 PM
            0 responses
            15 views
            0 likes
            Last Post herzogvladimir2  
            Started by giogio1, 04-13-2025, 01:42 AM
            2 responses
            39 views
            0 likes
            Last Post giogio1
            by giogio1
             
            Started by mmenigma, 01-23-2024, 09:37 AM
            1 response
            92 views
            0 likes
            Last Post Nin8aTrender  
            Started by wbayne333, 02-22-2021, 01:18 PM
            6 responses
            415 views
            0 likes
            Last Post Nin8aTrender  
            Started by gtheaded, 07-03-2020, 03:47 PM
            3 responses
            374 views
            0 likes
            Last Post Nin8aTrender  
            Working...
            X