Uturn script
study("U-Turn", overlay=false) Strength = input(title="Strength", type=integer, defval=4) SwingHighPos = abs(round(highestbars(high, (Strength * 2) + 1))) SwingHighMet = SwingHighPos == Strength PivotHigh = SwingHighMet ? high[Strength] : nz(PivotHigh[1]) BuySetup = iff(BuySetup[1] == false, SwingHighMet, iff(high > PivotHigh[1], false, true)) SwingLowPos = abs(round(lowestbars(low, (Strength * 2) + 1))) SwingLowMet = SwingLowPos == Strength PivotLow = SwingLowMet ? low[Strength] : nz(PivotLow[1]) SellSetup = iff(SellSetup[1] == false, SwingLowMet, iff(low < PivotLow[1], false, true)) ScanValue = iff(nz(BuySetup[1], false) and high > PivotHigh[1] and close < open, -1, iff(nz(SellSetup[1], false) and low < PivotLow[1] and close > open, 1, 0)) plot(ScanValue, color=red)