{Swing Percent signal}
{ Plots +1 when the price moves up X% from its recent low, plots -1 when the
price moves down X% from its recent high}
swingpercent := Input("Enter swing %",0,100,4);
If(PREV = 1, If(LOW < HighestSince(1,PREV <> 1,HIGH)*(1-swingpercent/100), -1,PREV), If(PREV = -1, If(HIGH>LowestSince(1,PREV <> -1,LOW)*(1+ swingpercent/100), +1,PREV), If(PREV = 0, If(HIGH>Lowest(LOW)*(1 + swingpercent/100), +1, If(LOW<Highest(HIGH)*(1-swingpercent/100), -1, PREV)),PREV)))
