Volatility Squeeze or Price Contraction


Category:
0
0

Hi Pete,

I’d like to scan for stocks where the closing price stays within a 1.5% band for 3 to 5 weeks.  Is this something you can help with for Thinkorswim?

Thanks,

Jay

Marked as spam
Posted by (Questions: 7, Answers: 5)
Asked on October 11, 2019 4:43 pm
552 views
0
Private answer

This is not a "volatility squeeze". Volatility is a completely separate measure of historical price than what you are requesting.

https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/G-L/HistoricalVolatility.html

I've stated this in your previous post but got no response so I deleted your post. What you are describing here is called "price contraction". There are many technical tools which measure this. You can simply work with the existing tools and adjust the settings until you reach the desired result. There is really no reason to write up a custom code to solve this. However....

For your particular case you could do something like this:

input numberOfDays = 15;
def upperBand = Highest(high, numberOfDays);
def lowerBand = Lowest(low, numberOfDays);
plot priceContraction = (upperBand - lowerBand) / close <= 0.015;

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 11, 2019 7:02 pm
0
Thank you, Pete. When I add this as a scan, it says "At least one plot should be defined." What should be the plot statement? Agreed on your comment about volatility vs price contraction, though I use the term in alignment with how Mark Minervini (Market Wizard) describes these tight areas.
( at October 13, 2019 6:14 am)
0
Sorry about that. I have updated my answer to change the last line from a def to a plot.
( at October 13, 2019 8:14 am)
0
The above defines the percentage based on the high and low of the 15-day period. I believe what I need is "closing prices are within a 1.5% +/- band for 3 to 5 weeks", which would be: (Close of today - close of yesterday)/close of today
( at October 13, 2019 10:35 am)
0

Change these two lines:

def upperBand = Highest(high, numberOfDays);
def lowerBand = Lowest(low, numberOfDays);

To this:

def upperBand = Highest(close, numberOfDays);
def lowerBand = Lowest(close, numberOfDays);

( at October 13, 2019 12:55 pm)
0
Sorry for such simple question… how would you modify the last line ”plot priceContraction = (upperBand – lowerBand) / close <0.015" to exclude stocks less than 0.3%? I tried adding "and > 0.003;” to the end but it didn’t work. Thank you so much. JR Zaro
( at October 13, 2019 7:45 pm)