Creating Squeeze Labels


0
0

Can you help in getting a TTM_Squeeze labels created. Would like to see whatever chart time frame you are on it shows the following:

  1. Current Squeeze (yes/no or colored red/green)
  2. Squeeze count (how many red dots does it current have if #1 condition is met)
  3. How many times did it fire long (long meaning green dot and histogram is +)
  4. How many times did if fire short (short meaning green dot and histogram is -)
  5. Average squeeze length (during that time frame)
  6. Average post run (if long, how long did the light blue histogram last before turning dark blue, opposite for squeeze short using yellow/red colors)
  7. Long post run (whether short or long before changing colors)
  8. Average post squeeze move in % and $
  9. Biggest post squeeze move in % and $

So to answer some of these questions from the chart of ZEN

  1. Current Squeeze (yes)
  2. Squeeze count (4)
  3. How many times did it fire long (1)
  4. How many times did if fire short (0)
  5. Average squeeze length (13 (22+4/2)
  6. Average post run (8)
  7. Long post run (8)
  8. Average post squeeze move in % and $ (not doing the math)
  9. Biggest post squeeze move in % and $ (not doing the math)
Attachments:
Marked as spam
Posted by (Questions: 17, Answers: 35)
Asked on July 9, 2019 11:37 am
21 views
0
Private answer

Hi Ryan,

This request is far more than what services we provide at no charge in our Q&A forum. In the forum I would gladly provide the solution to items 1 and 2 of your request. However in order to complete this full sweet of specifications requires several hours of code writing. You are welcome to submit this as a custom project request. But there will be no solution for this request in the forum.

Thanks!

After receiving feedback from the author of this post I have an update. The code below will take care of items 1 and 2 from the original request. I am borrowing some code from a video I published that shows the current state of the TTM_Squeeze in a watchlist. This code also displays the number of green dots in a row since the last time the TTM_Squeeze fired. This is based on the teachings from John Carter in which the number of red dots does not matter. This is not the first time someone has requested a modification to this so that it counts the number of red dots instead of the number of green dots. In order to allow others to follow along I will provide links.

This link is to the original video for the TTM_Squeeze watchlist dots: https://www.hahn-tech.com/thinkorswim-watchlist-ttm-squeeze/

This link is to the post in the Q&A forum where someone requested the code be modified to count red dots instead of green dots: https://www.hahn-tech.com/ans/ttm-squeeze-scan-that-looks-the-number-of-red-dots-in-a-row/

All I've done here is to take the code from the second link posted above and replaced the plot statements with AddLabel statements. Comments are included in the code to explain everything.

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;
# 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, "Squeeze Status", if alertCount > 0 then Color.RED else Color.GREEN);
# next, we can produce a label that displays the number of red dots
AddLabel(yes, Concat("Red Dots: ", alertCount), Color.WHITE);
Marked as spam
Posted by (Questions: 36, Answers: 1868)
Answered on July 9, 2019 12:15 pm
I will gladly take the items 1 and 2 from you?
( at July 9, 2019 12:18 pm)
I have updated my answer to include a solution to items 1 and 2 from your request.
( at July 9, 2019 5:40 pm)