Scanner for TTM Squeeze fired

S

shoecharlie

New member
Any ideas on how to tweak the scanner for the TTM Squeeze to find stocks that have already fired off rather than still being in a red dot squeeze. In laymans terms, a scanner that will tell me when the red dot squeeze changes and has its first green dot.

I am looking for a scanner that works on the 1 hr chart

any suggestions ??
 
wtf_dude

wtf_dude

Active member
Here ya go. Paste this into the thinkscript editor for study scan. Won't need to add any conditions. I coded it in

Code:
# Momentum Squeeze
# Mobius
# Added Squeeze Label with directional color
# Label is green when momentum is ascending, red when descending

declare lower;

input lengthe = 20; #hint length: Length for average calculation
input price = close;
input SDmult = 2.0;
input ATRmult = 1.5;

   def K = (Highest(High, lengthe) + Lowest(low, lengthe)) /
               2 + ExpAverage(close, lengthe);
  def Momo = Inertia(price - K / 2, lengthe);

def SD = StDev(close, lengthe);
def Avg = Average(close, lengthe);
def ATR = Average(TrueRange(high, close, low), lengthe);
def SDup = Avg + (SdMult * Sd);
def ATRup = Avg + (AtrMult * ATR);

def Squeeze = SDup < ATRup;
        
def zero = if IsNaN(close) or !IsNaN(Squeeze) then Double.NaN else 0;

Plot breakout = squeeze[1] is true and squeeze is false;
 
S

shoecharlie

New member
thanks !!! i will try it out.

Thanks wtf_dude for your work !!! but its not exactly what i was looking for .... what i am wanting is when the red dot changes to green .. so like the picture, when the red dots , change to green...

also would be super cool, to have a secondary condition of a scan that said when the momentum histogram color changed from dark green to dark blue (upside).... or from red to yellow (downside)

think you could put something together? is it possible?

 
wtf_dude

wtf_dude

Active member
@shoecharlie The default setting when you copy paste in a new scanner is for day. You would need to manually change over the D to 1h box in the upper left hand corner. I checked that it's firing off correctly on the day scan

Ok, so did an overhaul since I haven't really seen a more advanced squeeze scanner.
This will give you a scan for:
A breakout either direction, breakout down, breakout up, or trend(color) reversals on bull and bear sides.

Be sure to copy the code in the charts tab to make it a study, don't copy it into the scan tab.
When you add the saved study into the scanner:
Pick the drop down of whatever you want to scan and pick "is true"
Be sure to change the aggregation box to whatever time frame you want

Code:
# AdvancedSqueezeScanner
# Momentum Squeeze open coding by Moebius, based on John Carter
# Scan by WTF_Dude
# Added Squeeze Label with directional color
# Label is green when momentum is ascending, red when descending

declare lower;

input length = 20; #hint length: Length for average calculation
input price = close;
input SDmult = 2.0;
input ATRmult = 1.5;

   def K = (Highest(High, length) + Lowest(low, length)) /
               2 + ExpAverage(close, length);
  def Momo = Inertia(price - K / 2, length);

def SD = StDev(close, length);
def Avg = Average(close, length);
def ATR = Average(TrueRange(high, close, low), length);
def SDup = Avg + (SdMult * Sd);
def ATRup = Avg + (AtrMult * ATR);

def Squeeze = SDup < ATRup;
        
def zero = if IsNaN(close) or !IsNaN(Squeeze) then Double.NaN else 0;

def momobullup = Momo > Momo[1] and Momo > 0;
def momobulldown = Momo > 0 and Momo < Momo[1];
def momobeardown =  Momo > Momo[1] and Momo > 0;
def momobearup = Momo < 0 and Momo > Momo[1];


Plot Breakout = squeeze[1] is true and squeeze is false;
plot BreakoutBull = squeeze[1] is true and squeeze is false and momobullup;
plot BreakoutBear = squeeze[1] is true and squeeze is false and momobulldown;

Plot BullTrendChange = momobulldown is true and momobulldown[1] is false;
Plot BearTrendChange = momobearup is true and momobearup[1] is false;
 
S

shoecharlie

New member
I am unsure what you mean to download it to the chart tab... i have no idea where to do that ....can you point me in the right direction?
 
wtf_dude

wtf_dude

Active member
I am unsure what you mean to download it to the chart tab... i have no idea where to do that ....can you point me in the right direction?
If you're running a scan, you're on the scan tab. If you want to look at your charts, you go to the chart tab. The menu where you pick what studies you want on your chart, theres a button to create a new study, and that's where you paste that code in and give it a name like SqueezeScan. Then when you load a custom study scan you can pick that option
 
L

Likos

Member
2019 Donor
A get a message it says at least one condition needs to be corrected.
 
wtf_dude

wtf_dude

Active member
A get a message it says at least one condition needs to be corrected.
That would mean you're setting up the scan incorrectly. The code itself doesn't have a condition. You want the study to be matched as "is true" and that would be the condition
 
H

HighBredCloud

Well-known member
VIP
That would mean you're setting up the scan incorrectly. The code itself doesn't have a condition. You want the study to be matched as "is true" and that would be the condition
I think a lot of people here are used to the #comment out instead of setting the true/false from the menu...hence the confusion.
 
wtf_dude

wtf_dude

Active member
I think a lot of people here are used to the #comment out instead of setting the true/false from the menu...hence the confusion.
Right, I get it, I just find that it's safer to make a drop down option menu rather than risk messing with code to pick a condition.
 
L

Likos

Member
2019 Donor
Right, I get it, I just find that it's safer to make a drop-down options menu rather than risk messing with code to pick a condition.
I'm too used to copying & pasting the code in the editor than the drop-down menu, but how's that down? Add study, custom, and then what?
 
wtf_dude

wtf_dude

Active member
I'm too used to copying & pasting the code in the editor than the drop-down menu, but how's that down? Add study, custom, and then what?
Then select whatever you named my study as on the chart tab. Then on the "add conditions" screen it will give you a drop down menu with different options to choose from like squeeze breakout bull, squeeze breakout bear, bull trend change, etc. Select the option you want to scan for and then choose "is true" in the middle column. Good to go
 
Joseph Patrick 18

Joseph Patrick 18

New member
Then select whatever you named my study as on the chart tab. Then on the "add conditions" screen it will give you a drop down menu with different options to choose from like squeeze breakout bull, squeeze breakout bear, bull trend change, etc. Select the option you want to scan for and then choose "is true" in the middle column. Good to go

Hi wtf...quick question...do I delete the "CLOSE" condition on the condition wizard tab or keep that in the code also?? (ie...plot Data = close and 100 is true;) or......do I delete the close condition and just keep the "is true" value...(plot Data = 100 is true;)....and also this is a lower study and you will see colored triangular arrows correct? thanks Joseph
 
wtf_dude

wtf_dude

Active member
Man, I threw this together hoping it would make things EASIER, not more complicated lol.
Joseph, this is a scanner, not an indicator. There is already an indicator to use in TOS if you want (TTM_Squeeze)

Check out the image below to see how you would load this up. All you would change is the Plot dropdown. You can pick trend change, breakout to the upside, downside, etc. HOPEFULLY, this should clear everything up haha

For some reason, its not letting me upload the image itself so just check the link....

 
Joseph Patrick 18

Joseph Patrick 18

New member
@wtf_dude LOLnah it's just me...I am new to this so I first try to figure it out on my own and then if I can't I'll finally give in and ask...I went back and forth and read and reread and jumped from chart to scanner but couldn't get it right...but thanks so much for your time and help its greatly appreciated!

K got it...thanks...here it is if people are still confused...

STEP 1) Go to CHARTS...click on the Bunsen burner icon STUDIES and open it...then bottom left hand side of chart that pops up click on CREATE....top left rename newstudy to say TOS_SQUEEZE_SCANNER then copy and paste from post # 7 above in the same window highlighting the "plot data=close" and pasting code....then OK and Ok...

STEP 2) Go to SCAN tab and click on it...clear all of the filters by pressing X on right hand side...then open a new FILTER by clicking on FILTER then STUDY...then click on the box that pops up (should be ADX Crossover) click on it then scroll down to CUSTOM...then click on it..then new box opens up with ads crossover and click on DELETE...which will remove that option...then bottom left click on ADD CONDITION...then SELECT CONDITION then STUDY....THEN SCROLL DOWN TO WHATEVER YOU NAMED THE "CHART" "STUDIES" FILE (in this example it would be TOS_SQUEEZE_SCANNER)...click on that then a menu will pop up and then click on "IS TRUE" then click SAVE button...then top left of original box look for AGGREGATION BUTTON (should have a D on it for DAY...) and click on in then look for aggregation period that you want ...I use 3 and 5 minute period...then click OK and that's it...and if it was done correctly you should see..."TOS_SQUEEZE_SCANNER breakout "is true" in the filter scan box....then to save it right above that box on the right hand side click on the 3 lines hamburger and click on SAVE SCAN QUERY..and name it whatever you want...you will then also see (in my example TOS_SQUEEZE_SCANNER) also in your WATCHLISTS WHEN YOU SCROLL THRU THEM YOU WILL SEE THE NEW SCANNER...GOOD LUCK AND THANKS TO WTF :)
 
D

Dom173

New member
VIP
@wtf_dude thanks for your help here. Is it possible to tweak this to alert when a chart is entering a squeeze? This way I have time to watch and react. Then maybe an arrow or on chart indicator to confirm a breakout of the squeeze. Hope that makes sense. thanks again
 
M

mailbagman2000

Member
@wtf_dude works exactly as you said to do. Thanks, got a lot of good idea for covered calling writing
 
D

Diamondlil

New member
VIP
Hi @wtf_dude not sure if I'm posting this in the right place, hoping you can help ...
Looking for code for a study (to then put in a scan) where TTM Squeeze histogram goes positive while still in a squeeze.
Thanks if you can help!
 
wtf_dude

wtf_dude

Active member
Just throw these 2 lines in the code and it will give you 2 additional dropdown functions for that:

plot SqueezeChangetoBull = beartrendchange and squeeze is true;
plot SqueezeChangetoBear = bulltrendchange and squeeze is true;
 
Thread starter Similar threads Forum Replies Date
P Code a scanner for the TTM Squeeze? Questions 1
S Two Bands and Price using LRC scanner - TTM LRC Questions 3
M Weekly scanner for %change and RS rating Questions 0
S Within 1 bars in scanner Questions 3
D Hurst scanner with 200sma filter Questions 4

Similar threads

Top