Days since last 5% swing low

Optuma Forums Optuma Scripting Days since last 5% swing low

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #65575
    Thomas
    • Topics: 151
    • Replies: 204
    • Posts: 355

    Hi,

    I have tried to write a script that counts the days since the last e.g. 5% swing low. A 5% swing low is a correction of at least 5%.

    Unfortunately the script doesn’t works.  I have tried a lot of other variations but no one does what is should. Any help is appreciated.

    Thanks
    Thomas

    • This topic was modified 2 years ago by Thomas.
    #65579
    Darren
    • Topics: 76
    • Replies: 1,038
    • Posts: 1,114

    Hi Thomas,

    SwingEnd() gives the value of the swing, not the date.

    The difficulty with swings is that you have to wait X days until the swing turn has been confirmed (ie until price has moved at least 5%) so using something like TIMESINCESIGNAL(Var1 TurnsUp) won’t work as that counts from when the swing was confirmed, not from the low bar.

    The only way I can think of is to count since the low price was equal to the swing end: TIMESINCESIGNAL(LOW()==Var2)

    Note that this doesn’t take in to account the current swing direction, so if using a watchlist add SWINGUP(Var1)==1 to a column and sort.

    Out of the Dow 30, it’s been 66 days since MSFT had a swing low, followed by 8 others on 40 days. At 9 days ago INTC had the most recent swing low.

    Capture

    1 user thanked author for this post.
    #65581
    Thomas
    • Topics: 151
    • Replies: 204
    • Posts: 355

    Hi Darren,

    Thank you very much for all your work. The script works perfectly with TIMESINCESIGNAL(LOW()==Var2).

    Here is the complete script for calculating with High/Low:

    But there is a special issue if I change the property “Calculate Using” from “High/Low” to “Close”. The results of the script are completely wrong.

    Here is the script for calculating with the Close:

    Is there something I have missed?

    When I use the tool “Percent Swing Chart Overlay (PCSC)” and change the property “Calculate Using” from “High/Low” to “Close” the tool works as it should and changes the calculation from High/Low to Close.

    Thanks again a lot,
    Thomas

    • This reply was modified 2 years ago by Thomas.
    #65589
    Darren
    • Topics: 76
    • Replies: 1,038
    • Posts: 1,114

    Hi Thomas,

    Var2 is now using the closing price rather than the low, so Var3 needs to be changed to CLOSE()==Var2.

    1 user thanked author for this post.
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest