Sideways Indicator for ThinkorSwim - Avoid Trading in Choppy Markets

BenTen

BenTen

Administrative
Staff
VIP
Warehouse
Here's a simple indicator, it's not going to tell you if the market is going up or down, instead, it will tell you when the market is moving sideways. The indicator was made to solve my problem. I hate executing trades in choppy markets.

I think this indicator is going to be a great assistant when it comes to dealing with choppy markets. It could potentially save your account.



Usage:

Sideways indicator comes in the form of an oscillator. I use the same method that was mentioned in this post. By combining the range between DI+ and DI- lines from the DMI indicator.

When two lines are close to each other it means we have a sideways market. I would avoid trading when this happens. Also, the indicator will highlight the candles when it's experiencing choppiness.

Recommended timeframe: 5m and 15m for intraday traders.

thinkScript Code

Code:
# Sideways Indicator
# Original Code developed by WalkingBallista
# Concept and Idea by BenTen at useThinkScript.com
# Identify choppy market. Can also be used to find consolidation/breakout patterns.
# Version 1.0 (read changelog in the forum)

declare lower;
input length = 14;
input averageType = AverageType.WILDERS;
input price = close;

def hiDiff = high - high[1];
def loDiff = low[1] - low;

def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
def "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;

plot range = AbsValue(AbsValue("DI+")-AbsValue("DI-"));

# Define Consolidation Range
# Change the number 5 to 10 if you want more sideways filter
AssignPriceColor(if range < 5 then Color.Yellow else Color.Current);

Shareable Link

 
Last edited:
mc01439

mc01439

Active member
VIP
Warehouse
@BenTen

Nice indicator. Added labels for 5 bars to replace bar colors and commented out declare lower. I like one indicator for the lower level Can post if you like.
 
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@mc01439 Nice enhancements. Feel free to share :)
 
Billions

Billions

Member
VIP
Warehouse
Hi what is the difference between these two studys
 
mc01439

mc01439

Active member
VIP
Warehouse
One is plotted on a lower window the other only gives you five labels for the past five bars. I prefer the labels for a cleaner chart.
 
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@Billions The lower study should. It will not paint your candles on mobile though.
 
A

Addamk

New member
VIP
How do i donate and become a member.. i would like access to this script
 
V

Vision

New member
VIP
When two lines are close to each other it means we have a sideways market.

What am I missing? There's only one line in your posted chart and on mine.
 
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@Vision

Sideways indicator comes in the form of an oscillator. I use the same method that was mentioned in this post. By combining the range between DI+ and DI- lines from the DMI indicator.
 
Billions

Billions

Member
VIP
Warehouse
@BenTen Hi is there anyways to get this to work on mobile and change the candles color?
 
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@Billions The lower study is compatible with the mobile app but not the candle colors.
 
N

n7ekg

New member
Is there any way for the indicator to draw a box around the range of the candles, as shown on the first images posted? Thanks!
 

Top