Price Channel Compression Oscillator for ThinkorSwim

mashume

Expert
VIP
Lifetime
New, but not necessarily ground breaking, here's an idea I've been toying with visualizations for for a while.

This is a way of looking at price channels as an oscillator, with a long-term average to show compression of the price range.

There are several lines going on here:
1. Black - Upper and Lower Price Channel bounds, adjusted to bound the zero line.
2. Red - Price line. This is where in the price channel the adjusted current price is.
3. Blue (solid) - Zero line.
4. Blue (long dash) - Long Average Price Line, for reference.
5. Black (short dash) - Long Average Lower Bound - this is the compression indication.

Some illustrations for eye-candy and explanation:

MoRVSEv.png


This was a ranging day. after clearly expanding the range in the first period of the day (as shown by the red cloud between the average range and the current channel range) the price range began to contract just before mid-day. The blue cloud indicates a compression of the price range or near steady ranges with no drastic movements. The red Price Line moves back and forth between the upper and lower bounds on the price channel and the average price line (long blue dash) really doesn't deviate very far from the zero line.

mePaHHU.png

Down trending day. The price line moved along the bottom of the price channel all day, until late in the session when it barely moved back up to zero. The range continually expanded until just after that, and was larger in magnitude than the long term average range all day.

50Wj3I0.png

Up trend day -- everyone's favourite. The price action line doesn't drop below the zero line with the exception of a short morning pullback until late in the session. The market starts to slow down (as you may see from the range shifting outside it's long term trend to inside the long term trend) just before lunch. The range compresses, and the price line moves below zero near the end of the session.

This indicator seems to provide an interesting view of price action, though I have not developed any entry/exit signals from it, it does show trend exhaustion or indecision with some accuracy.

I have not tested for better / more effective lengths. It is presented as is and for your consideration, and not an endorsement of any particular whispers it may send you.

Link to study:
http://tos.mx/FoU94gV

Code:
Code:
# Price Channel Compression Indicator
# With Price Oscillator
#
# Mashume 10.XII.2020
# Released to UseThinkScript Community
# GNU GPL v3.0 as applicable

declare lower;

input displace = 0;
input length = 20;
input arrows = no;
input Compression_Length = 150;
input price_Av_Len = 49;

def LowerBand = Lowest(low[-displace + 1], length);

def UpperBand = Highest(high[-displace + 1], length);

def PriceAction = HL2;
def up = UpperBand - PriceAction;
def lo = -( PriceAction - LowerBand);
def distance = UpperBand - LowerBand;

plot upper_d = distance * 0.5;
plot lower_d = - upper_d;

upper_d.SetDefaultColor(GetColor(7));
lower_d.SetDefaultColor(GetColor(7));

plot too_high = if CLOSE > UpperBand  and arrows == yes then upper_d else double.nan;
too_high.setPaintingStrategy(paintingStrategy.ARROW_DOWN);
too_high.setDefaultColor(color.black);

plot too_low = if CLOSE < LowerBand and arrows == yes then lower_d else double.nan;
too_low.setPaintingStrategy(paintingStrategy.ARROW_UP);
too_low.setDefaultColor(color.black);

plot zero = 0;
zero.SetDefaultColor(getColor(3));
plot price_line = simpleMovingAvg((PRICEACTION - LowerBand) - (0.5 * distance), 2);
price_line.SetDefaultColor(GetColor(5));
price_line.SetLineWeight(2);

# addcloud(price_line, 0, Color.PLUM, Color.PINK);

plot compression = - ExpAverage(upper_d, Compression_Length);
compression.SetDefaultColor(GetColor(7));
compression.SetStyle(Curve.SHORT_DASH);
addCloud (compression, lower_d, getColor(5), GetColor(3));

plot price_MA = expAverage(price_line, price_Av_Len);
price_MA.SetDefaultColor(GetColor(6));
price_MA.SetStyle(Curve.MEDIUM_DASH);

If it makes you profitable, cool. Let me know in the comments how you use this thing.

Happy Trading,
Mashume
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

That on is the ITF Stochastic, with a modification by me for entries on what I termed "small dips" in the stochastic line.
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2012-2020
# Modded Mashume 2020
#

declare zerobase;

input price = close;
input threshold = 0.5;
input length = 30;
input slowingLength = 5;
input over_bought = 90;
input over_sold = 60;

def rainbow = reference RainbowAverage(price = price, averageType = AverageType.WEIGHTED);
plot Stochastic = sum(rainbow - Lowest(rainbow, length), slowingLength) / (sum(Highest(rainbow, length) - Lowest(rainbow, length), slowingLength) + 0.0001) * 100;

def normStochRainbow = 0.1 * (Stochastic - 50);
plot IFT = 100 / (1 + exp(-2 * normStochRainbow));
plot OverBought = over_bought;
plot OverSold = over_sold;

Stochastic.SetDefaultColor(GetColor(2));
IFT.SetDefaultColor(GetColor(1));
OverBought.setDefaultColor(GetColor(5));
OverSold.setDefaultColor(GetColor(5));

def smalldip = if 
        IFT > IFT[1]
    and IFT[1] < IFT[2]
    and IFT - IFT[1] >= threshold
    and IFT[7] > IFT 
    and IFT[7] > 95 
    and IFT[1] <= 92.5 
    and IFT > over_sold
    then IFT ELSE DOUBLE.NAN;

plot small_dip = smalldip;
small_dip.SetPaintingStrategy(paintingStrategy = PaintingStrategy.ARROW_UP);
small_dip.SetDefaultColor(getColor(3));

happy trading,
-mashume
 
It should be on the left axis. Perhaps that's what you'll need to set. Not quite sure

mashume
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
391 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top