Scanner for TTM Squeeze fired

P

Parker427

New member
I need this too! So I go to Scan, Add filter, study, custom and add this coding or? Also it says that the "buxltrendchange" part for both lines don't work. "No such variable" or something like that
 
D

Diamondlil

New member
VIP
@wtf_dude sorry, I'm a newbie. Trying to figure this out. Where exactly would I put those 2 lines of code into? Tried putting into the TTM Squeeze script but it won't let me.
 
wtf_dude

wtf_dude

Active member
@wtf_dude sorry, I'm a newbie. Trying to figure this out. Where exactly would I put those 2 lines of code into? Tried putting into the TTM Squeeze script but it won't let me.
Oh no, you have to put it with the code I posted earlier. Just create a new study, call it something like AdvancedSqueezeScanner and paste all of this and then use it on the scan tab. Should be go to go.

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 BreakoutEitherDirection = 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 BullTrendReversal = momobulldown is true and momobulldown[1] is false;
Plot BearTrendReversal = momobearup is true and momobearup[1] is false;

plot Squeeze_ChangetoBull = BearTrendReversal and squeeze is true;
plot Squeeze_ChangetoBear = BullTrendReversal and squeeze is true;

#End Code
 
D

Diamondlil

New member
VIP
:) Wow! thank you! Hopefully I can get that going. Appreciate it!
 
P

Parker427

New member
@wtf_dude This code also doesn't work, TOS. says "
No such variable: Momo at 13:28
No such variable: Momo at 13:40
No such variable: Momo at 14:18
No such variable: Momo at 14:31"
 
wtf_dude

wtf_dude

Active member
This code also doesn't work, TOS. says "
No such variable: Momo at 13:28
No such variable: Momo at 13:40
No such variable: Momo at 14:18
No such variable: Momo at 14:31"
You had to have copied it wrong. Works fine on my end. Momo is defined on line 16.
 
P

Parker427

New member
You had to have copied it wrong. Works fine on my end. Momo is defined on line 16.
I just copied and pasted it like 10 times. Now TOS says "Exactly one plot expected" and won't let me pass the "OK" button.
 
wtf_dude

wtf_dude

Active member
I just copied and pasted it like 10 times. Now TOS says "Exactly one plot expected" and won't let me pass the "OK" button.
oh dude no, you need to paste this to as a new study on the CHART tab. Then when you go to scan tab it will appear as a choice. You can't paste it on the scan tab because the formatting is different and adding from the chart area allows the option of dropdown menus
 
P

Parker427

New member
oh dude no, you need to paste this to as a new study on the CHART tab. Then when you go to scan tab it will appear as a choice. You can't paste it on the scan tab because the formatting is different and adding from the chart area allows the option of dropdown menus
Ohh okay. It works. Where do I find it on the scan tab?
 
wtf_dude

wtf_dude

Active member
Ohh okay. It works. Where do I find it on the scan tab?
Select add condition, then Study, then you'll add it by whatever name you saved it as, then select whatever you want from the dropdown menu next to Plot, then select "is true" in the middle column, and click OK.
 
P

Parker427

New member
Thank you so much!! When you put “is true” then “1 bar ago”, it shows squeezes that already fired. Is it possible to get in before the squeeze fires? Maybe a bar or two before. Therefore, we buy, bar or two later, it fires to the upside.
 
D

Diamondlil

New member
VIP
@wtf_dude what adjustment would I need to make for bullish moves only? Thank you.
 
D

Diamondlil

New member
VIP
Sorry but need help here. I think I'm missing something. I want to scan for only "buy alerts" with this indicator. Do I need to edit the condition input when setting up the scan? Kindly provide step by step if possible. Appreciate that very much! Thank you!

* Also, comment appears in indicator code: "invalid statement: 2 at 1:1" How do I correct this? Thank you again! *
I think it is referring to this:

2
def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
 
Last edited:
wtf_dude

wtf_dude

Active member
Sorry but need help here. I think I'm missing something. I want to scan for only "buy alerts" with this indicator. Do I need to edit the condition input when setting up the scan? Kindly provide step by step if possible. Appreciate that very much! Thank you!

* Also, comment appears in indicator code: "invalid statement: 2 at 1:1" How do I correct this? Thank you again! *
I think it is referring to this:

2
def HiLo = Min(high - low, 1.5 * Average(high - low, ATRPeriod));
Don't need to edit anything. Just switch the dropdown menu where it says Plot to "BreakoutBull" and that will show you breakouts to the upside coming out of the squeeze. If you want just the histogram changing directions and coming back up to bull, switch the menu to "beartrendchange". If you want the histogram changing directions to bull WHILE STILL in a squeeze, change it to "squeeze_changetobull"
 
wtf_dude

wtf_dude

Active member
I'd be glad to change the names of the options if everybody can agree on titles that are more clear? Wasn't trying to make the thing confusing hahah
 
V

Vimal Mittal

Member
@wtf_dude I would like to see a snap shot of this in study in chart. I see waves with different color on chart. Green for breakout in daily chart?
 
P

Parker427

New member
Can someone code a simple scan that tells you when the TTM Squeeze is in a squeeze and it’s neutral? (Histogram). It can be rising momentum into a neutral squeeze, descending momentum into a neutral squeeze or Just be in a squeeze and histogram being neutral
 
Joseph Patrick 18

Joseph Patrick 18

New member
I figured it out thanks!

Joe
 
Last edited:
V

Vimal Mittal

Member
Oh no, you have to put it with the code I posted earlier. Just create a new study, call it something like AdvancedSqueezeScanner and paste all of this and then use it on the scan tab. Should be go to go.

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 BreakoutEitherDirection = 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 BullTrendReversal = momobulldown is true and momobulldown[1] is false;
Plot BearTrendReversal = momobearup is true and momobearup[1] is false;

plot Squeeze_ChangetoBull = BearTrendReversal and squeeze is true;
plot Squeeze_ChangetoBear = BullTrendReversal and squeeze is true;

#End Code
There is an error when i copy and paste to scan editor. It says "Exactly one plot expected"?
How to fix it. Thanks.
 
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