• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

Labels For Squeeze & Time Frame

AlphaOptions

New member
About two years ago I saw where a thinkscripter had developed labels to set general expectations for squeeze history, but I did not save the script unfortunately. While this label is not a trade trigger type of indicator, it can be used to quickly set expectations for squeeze occurrence frequency and duration. I would like to see if I can get some help building it as follows and others might also like to learn from the process as we go. Here are the steps I would propose:
  1. Start with a label (or what will be the initial showing in the ultimate label) that shows the number of bars in the chart being viewed (i.e. there are X number of bars on this chart).
  2. The next part of the label will say there are X total bars in the TTM squeeze on this chart.
  3. The other parts of the label are then just mathematical derivative parts of the label from these two measures which most interesting are:
    1. What percent of bars are in a squeeze (number of squeezes / total bars as a % ) - this shows how frequently this occurs of all bars
    2. How frequently does a squeeze series initiate - so number of unbroken series (prior bar no squeeze but current bar is squeeze) shows the number of not just the frequency of all bar in squeeze but how frequently a squeeze sequence initiates
    3. Average squeeze duration - shows of all the unbroken series how many bars would be in a squeeze - this is perhaps the most useful as you can characterize and instrument (or at least its period in the chart) to set expectations on how long that might last
    4. Other things are also possible like shortest, longest, longest between squeeze series ...
Once the framework design is made, it is conceivable that any indicator occurrence could be substituted for the squeeze.
 

brendab180

New member
2019 Donor
Wanting to have a label (labels) on the bottom secion of my chart that shows me the squeeze information along with what time frame. Can someone help with that. I saw this on someones chart and liked it but can't find how they did it. I use 5 different charts but with just the lower indicators desplayed to the left side of my area and each are with a different time frame. So I can just see the TTm Squeeze for each in each of those timeframes. I have these stacked Then I have an upper chart to the right of that that just shows me the current time frame with my upper part displayed. Trying to figure out how to upload an image. Hope I am doing this right by asking. Thanks for any help.
 

markos

Well-known member
VIP
Hi @brendab180 Attach a chart for free by going to Imgur.com.
Here's a start.
Code:
# Squeeze Count Watchlist
# Mobius
# 11.09.2015
 
def Squeeze = BollingerBands().UpperBand < KeltnerChannels().Upper_Band;

def count = if !Squeeze
            then 0
            else if Squeeze
                 then count[1] + 1
                 else count[1];

AddLabel(1, if Squeeze then count else 0,
            if Squeeze 
            then Color.Black
            else Color.WHITE);
AssignBackgroundColor(if Squeeze then color.green else color.white);
 

markos

Well-known member
VIP
Here's another from the Think Script Lounge via the Universe of Thinkscript in the Tutorial Section.

11:08 Mobius: Here is the TTM Squeeze study that I wrote
Code:
# Momentum Squeeze
# Mobius
# 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 SDmult = 2.0;
input ATRmult = 1.5;

   def c = close;
   def h = high;
   def l = low;
   def K = (Highest(h, length) + Lowest(l, length)) /
               2 + ExpAverage(c, length);
  plot Momo = if isNaN(close)
              then double.nan
              else Inertia(c - K / 2, length);
       Momo.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
       Momo.setLineWeight(3);
       Momo.assignValueColor(if Momo > Momo[1] and Momo > 0
                             then Color.Cyan
                             else if Momo > 0 and Momo < Momo[1]
                             then Color.Blue
                             else if Momo < 0 and Momo < Momo[1]
                             then Color.Red
                             else Color.Yellow);

def SD = StDev(c, length);
def Avg = Average(c, length);
def ATR = Average(TrueRange(h, c, l), length);
def SDup = Avg + (SdMult * Sd);
def ATRup = Avg + (AtrMult * ATR);

plot Squeeze = if isNaN(c)
               then double.nan
               else if SDup < ATRup
               then 0
               else Double.NaN;

     Squeeze.SetPaintingStrategy(PaintingStrategy.Points);

     Squeeze.SetLineWeight(3);

     Squeeze.SetDefaultColor(Color.Red);

plot zero = if IsNaN(c) or !IsNaN(Squeeze) then Double.NaN else 0;
     zero.SetPaintingStrategy(PaintingStrategy.Points);
     zero.SetLineWeight(3);
     zero.SetDefaultColor(Color.Green);

AddLabel(!isNaN(Squeeze), "Squeeze", if isAscending(Momo)
                                     then Color.Green
                                     else Color.Red);

 
# End Code - Momentum Squeeze
 

brendab180

New member
2019 Donor
here is a pic of what I am looking for. I have the chart layout just as it looks but wanting the labels for the time frames where the ttm squeeze bottom charts are. And then like a count. If say time frame 30 min has two red dots at the moment would be in squeeze 2 and then when first green dot would be a time cycle so say time cycle 1 or fired. Something like that. I will try the part you posted to see what it looks like. Thanks for the feed back and helping with sharing a pic. :)
 

Born2Win

New member
VIP
I use John Carter's TTM Label on price chart Label A, B and C. I would appreciate is anyone could help by adding the value of A, B & C to these Labels truncating it to 0.00 digits

Code:
#TTM_Label
declare upper;
def ttmwavea= TTM_Wave().wave1;
def ttmwaveb= ttm_wave().wave2high;
def ttmwavec= ttm_wave().wave2low;
AddLabel(yes, if ttmwavea > 0 then "A-Up" else "A-Dn", if ttmwavea > 0 then
Color.GREEN else Color.RED);
AddLabel(yes, if ttmwaveb > 0 then "B-Up" else "B-Dn", if ttmwaveb > 0 then
Color.GREEN else Color.RED);
AddLabel(yes, if ttmwavec > 0 then "C-Up" else "C-Dn", if ttmwavec > 0 then
Color.GREEN else Color.RED);
 

Attachments

  • 2021-04-16-TOS_CHARTS.png
    2021-04-16-TOS_CHARTS.png
    48 KB · Views: 112

rad14733

Well-known member
VIP
@Born2Win You're not going to believe how easy your request is... If you examine the code you'll see...

Ruby:
#TTM_Label
declare upper;
def ttmwavea= TTM_Wave().wave1;
def ttmwaveb= ttm_wave().wave2high;
def ttmwavec= ttm_wave().wave2low;
AddLabel(yes, if ttmwavea > 0 then "A-Up = " + Round(ttmwavea, 2) else "A-Dn = " + Round(ttmwavea, 2), if ttmwavea > 0 then Color.GREEN else Color.RED);
AddLabel(yes, if ttmwaveb > 0 then "B-Up = " + Round(ttmwaveb, 2) else "B-Dn = " + Round(ttmwaveb, 2), if ttmwaveb > 0 then Color.GREEN else Color.RED);
AddLabel(yes, if ttmwavec > 0 then "C-Up = " + Round(ttmwavec, 2) else "C-Dn = " + Round(ttmwavec, 2), if ttmwavec > 0 then Color.GREEN else Color.RED);
 

JohnWick4

New member
Code:
# adapted this label into 1 piece and made it change color after 6 dots.  Giving Back because I have learned so much already. ENJOY.

input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
def squeezeDots = TTM_Squeeze(price, length, nK, nBB, alertLine).SqueezeAlert;
# the original code here counted the number of green dots, so we comment this out and leave it here for safe-keeping
#def alertCount = if squeezeDots[1] == 0 and squeezeDots == 1 then 1 else if squeezeDots == 1 then alertCount[1] + 1 else 0;
# and here we have modified it to count the red dots
def alertCount = if squeezeDots[1] == 1 and squeezeDots == 0 then 1 else if squeezeDots == 0 then alertCount[1] + 1 else 0;
# NEXT FOUR ROWS COMMENTED OUT AND COMBINED THE LABEL.
# alertCount is the variable that keeps track of our red dots
# we can produce a label that displays Green or Red depending on the state of the squeeze
# AddLabel(yes, "SQ_RED", if alertCount > 0 then Color.GREEN else Color.WHITE);
# next, we can produce a label that displays the number of red dots
AddLabel(yes, Concat("SQ_RED DOTS : ", alertCount), if alertCount >=6 then Color.RED else Color.ORANGE);
 

JohnWick4

New member
I use John Carter's TTM Label on price chart Label A, B and C. I would appreciate is anyone could help by adding the value of A, B & C to these Labels truncating it to 0.00 digits

Code:
#TTM_Label
declare upper;
def ttmwavea= TTM_Wave().wave1;
def ttmwaveb= ttm_wave().wave2high;
def ttmwavec= ttm_wave().wave2low;
AddLabel(yes, if ttmwavea > 0 then "A-Up" else "A-Dn", if ttmwavea > 0 then
Color.GREEN else Color.RED);
AddLabel(yes, if ttmwaveb > 0 then "B-Up" else "B-Dn", if ttmwaveb > 0 then
Color.GREEN else Color.RED);
AddLabel(yes, if ttmwavec > 0 then "C-Up" else "C-Dn", if ttmwavec > 0 then
Color.GREEN else Color.RED);
Born2Win what exactly is this label used for. I use the TTM Squeeze also I don't get it. Please educate me.
 

Born2Win

New member
VIP
Hi John,
I don't use the indicator only these labels. In one of the class I took with John carter he said to look at Wave C. So on smaller timeframes if Wave C is above 0 and green it is an indication the stock is rising.
 

Similar threads

Top