Down 10% from All Time Highs

Hi, i am trying to show when the market has declined greater than 10% from an all time high. I would like to eliminate multiple signals after both conditions are met. I tried signalafter but it failed to return anything.

Thanks, Jamie

// Highest All Time High
V1 = HIGHESTHIGH(RANGE=All History);
//10% from All Time High
V2 = V1 * 0.9;
//Down > 10% from All Time high
V3 = LOW() CrossesBelow V2;
//All Time high and down 10%
V3

//SIGNALAFTER(V1,V3)

Hi Jamie,

I’ve used the PERCENTSWING() function instead, which plots % swings over the chart. The swings turn when the threshold has been met, so when it turns down price has declined by at least 10%. Combine with the HIGHESTHIGH and SIGNALAFTER functions and we can use this:

//Set % swing threshold;
V1=PERCENTSWING(PERCENT=10.0);
//Signal when turns down;
R1=SWINGDOWN(V1);
//New ATH signal;
H1=HIGH()>=HIGHESTHIGH(RANGE=All History);
//Signal swing down after ATH
SIGNALAFTER(H1,R1)

The orange lines show 10% declines after a ATH in the $SPX, and the next swing down will trigger at 3229:

Capture