# Detecting Swings Strategy Scans ?

##### New member
Can someone convert the 4 strategies from https://tlc.thinkorswim.com/center/reference/Tech-Indicators/strategies/L-P/PriceSwing to 4 separate scans , particularity the RSI + Higher Low / Lower High with adjustable settings for the RSI ?

input swingType = {default "Pivot High-Low", "Bollinger Bands Crossover", "RSI Crossover", "RSI + Higher Low / Lower High"};
input length = 12;
input exitLength = 20;
input deviations = 2.0;
input overbought = 60;
input oversold = 40;
input averageType = AverageType.SIMPLE;

def rsi = reference RSI(length = length, "average type" = averageType);
def bbUpperBand = MovingAverage(averageType, close, length) + deviations * StDev(close, length);
def bbLowerBand = MovingAverage(averageType, close, length) - deviations * StDev(close, length);

def upSwing;
def downSwing;
switch (swingType) {
case "Pivot High-Low":
upSwing = low[1] < low[2] and low[1] < low;
downSwing = high[1] > high[2] and high[1] > high;
case "Bollinger Bands Crossover":
upSwing = close crosses above bbLowerBand;
downSwing = close crosses below bbUpperBand;
case "RSI Crossover":
upSwing = rsi crosses above oversold;
downSwing = rsi crosses below overbought;
case "RSI + Higher Low / Lower High":
upSwing = rsi < oversold and low > low[1];
downSwing = rsi > overbought and high < high[1];
}

def entryPrice = EntryPrice();
def afterEntryCount = if IsNaN(entryPrice[1]) and !IsNaN(entryPrice) then 1 else if !IsNaN(entryPrice) then afterEntryCount[1] + 1 else Double.NaN;

AddOrder(OrderType.SELL_TO_OPEN, downSwing, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "PriceSwingSE");
AddOrder(OrderType.BUY_TO_CLOSE, afterEntryCount > exitLength, tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "PriceSwingLX");
AddOrder(OrderType.SELL_TO_CLOSE, afterEntryCount > exitLength, tickcolor = GetColor(3), arrowcolor = GetColor(3), name = "PriceSwingSX");

Solution
@Tradarr Replace entryprice and everything below it with this.
Code:
``````plot scan1 = upswing;
plot scan2 = downswing;``````
@Tradarr Replace entryprice and everything below it with this.
Code:
``````plot scan1 = upswing;
plot scan2 = downswing;``````

87k+ Posts
173 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?