Swing Retracement Scan

Optuma Forums Optuma Scripting Swing Retracement Scan


Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #50815
    • Topics: 53
    • Replies: 428
    • Posts: 481

    The following script will search for 50% retracements (+/- 2%) up from the previous downswing, often seen as an important resistance level. The swings have been based on daily 3 bar Gann Swings, but all the settings (eg retracement levels, tolerance, swing parameters) can be adjusted as needed. The timeframe can be set in the Scanning Manager window.

    In this example, BXP has retraced 48.41% of the previous swing, so might be worth keeping an eye on to see if it breaks through or bounces off:


    Of course, downward retracements are just as important. He’s an example of a retracement from a high of 36 – 40% – ie close to the Fibonacci 38.2% level. Note the changes to variables V2 and V3:


    • Topics: 0
    • Replies: 1
    • Posts: 1

    Hello Darren,

    Please, help!. What’s the code for the watchlist to show Retracement% in a numeric form?

    Thank you,


    • Topics: 53
    • Replies: 428
    • Posts: 481

    Hi Miguel,

    To calculate the ratio of the current swing to the previous use this for a 3 bar swing (NOTE: this is slightly different from the script above in that inside bars are included in the swing counts).

    Note however that it calculates the last confirmed swing end value, which will be different from the current close. For example AAPL’s most recent swing end value of $212.14 occurred 3 bars ago, which is 67.94% of the previous swing. The next swing hasn’t been confirmed yet, so the last close of $206.50 is only 48.35% of the previous swing.

    To calculate the retracement to the most recent close instead change variable V2 above (line 10) to the following:

    V2 = CLOSE()-SS1;

    Save the workbook attached.


    • Topics: 9
    • Replies: 13
    • Posts: 22

    Hi Darren, a query please, when I use showbar for the script with modifications of percentage retrace(btw 50% and 90% as example) and no use of close position, it does not identify all times, it only finds the examples where for example in a bear trend it turns back down from a retrace and makes a new swing in the same bear direction, how do I modify it so that it identifies the occasion when the confirmed retracement swing reaches or is in the range of between 50 and 90% irrespective of whether it turns back down or ends up taking out the swing top etc.



    • Topics: 53
    • Replies: 428
    • Posts: 481

    Hi Tim,

    The first post above has 2 scripts – the first calculates the retracement from a low, and the other from a swing high. Is that what you are referring to? If not, please provide the script you are using, along with a screenshot showing what you wish to achieve.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.