Swing Low Time Count

Hi,

I want to calculate the time between two consecutive 10% percent DOWN swing lows.

Here is the chart to illustrate what I want:
screenshot - 0000
As you can see between the 02/24/22 10%-percent swing low and the 06/17/22 10%-percent swing low we had 79 trading day or 113 calendar days, between the 06/17/22 10%-percent swing low and the 10/13/22 10%-percent swing low we had 81 trading day or 118 calendar days, and between the 10/13/22 10%-percent swing low and the 10/27/23 10%-percent swing low we had 261 trading day or 379 calendar days,

How can I calculate with a script the trading day between two consecutive 10% percent DOWN swing lows?

I have tried a lot of scripting settings with BARINDEX, VALUEWHEN, and so on but nothing worked.

// Setup Swing Parameters
Line1 = PERCENTSWING(PERCENT=10.0) ;

// Getting the Swing Direction and Convert SwingList to BarList
Line2 = SWINGDOWN(Line1) and CLOSE() > 0 ;

// TEST SETTINGS
Line3 = SWINGEND(Line1) ;
Line4 = SWINGEND(Line1, 1) ;

Line4

Any suggestion is apprreciated:

Best wishes,
Thomas

Hi Thomas,

Swing lows can be found when the low price is the same as the swing end (Line2). Then we can count the bars or days between each event:

Line1=PERCENTSWING();
Line2=LOW()==SWINGEND(Line1);
TIMESINCESIGNAL(Line2==1,UNIT=Days)

Capture

Hi Darren,

Thank you very much for your help.

I would like to take this opportunity to wish you and the entire Optuma-Team a Happy New Year.

Coming back to the swing analysis, your script works of course.

However, I would like to make a slight change and use the closing price instead of the high/low price.

My modified script looks like this:

// Setting the Swing Percentage using Close
Line1 = PERCENTSWING(PERCENT=10.0, CALCUSINGTOOL=Close) ; 

// Getting the Swingend Values
Line2 = CLOSE()==SWINGEND(Line1) ;

// Count Trading Days Since Last Close of Swing Low;
Line3 = TIMESINCESIGNAL(Line2==1) ; 
Line3

Herre is the chart:
screenshot - 0002

As you can see, with the modified script, ALL swings are used to calculate the length of the swings in days. This is in a way obvious as there is no condition mentioned in the script that only the downswings should be used.

Again, I tried some settings with SWINGEND IsDown or DOWNSWING, but neither setting worked using the closing price.

Can you please give me some hints on how to calculate the time difference between downswing using the closing price?

Thank you very much,
Thomas

Thanks Thomas.

Add this SWINGDOWN condition:

Line2 = CLOSE()==SWINGEND(Line1) and SWINGDOWN(Line1);