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.

    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.

        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            71 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            143 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            76 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            47 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            51 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X