TTM Squeeze Histogram any color change any bar count


Category:
0
0

Need squeeze that will scan for stocks where there is only 1 or 2 or 3 cyan bars after yellow bars only.  See attached file for visual. I’ve reviewed and tried the other posts on this but none exactly was what I’m looking for.

TTM Squeeze scan 2nd blue bar after 2 or more cyan – Hahn-Tech, LLC

Scan base off of TTM squeeze color of histogram – Hahn-Tech, LLC

Thanks,

Mark Chapman

Attachments:
RESOLVED
Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on November 18, 2024 12:12 pm
7 views
0
Private answer

Since you are requesting a scan, I moved your question out of the "Chart Studies" topic and into the "Stock Scanners" topic.

I also updated the title of your question to reflect the solution I am providing. In hindsight, seems I should have done this for the very first request for TTM Squeeze histogram changing colors. This solution provides two user inputs to control the number of consecutive bars of the first color as well as the number of consecutive bars of the second color. And this script includes four different scan signals, one for each of the four possible color combinations.

This is the master scan for the TTM Squeeze histogram and should provide the solution that fits every possible combination of requests.

Please note that the very first scan signal is for color changing from blue to red. The other three scan signals are commented out because the scan can only do one signal at a time. In order to switch this to the scan signal you requested, simply place a "#" symbol in front of "plot conditionCyanBlue" and remove the "#" symbol from in front of "plot conditionYellowCyan". Then you can adjust the two inputs at the top to whatever number of bars you want to scan to pick up.

input barCountOne = 2; # consecutive bars for color one
input barCountTwo = 2; # consecutive bars for color two
input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
def hist = TTM_Squeeze(price, length, nK, nBB, alertLine).Histogram;
def histCyan = hist > 0 and hist > hist[1];
def histBlue = hist > 0 and hist < hist[1];
def histRed = hist < 0 and hist < hist[1];
def histYellow = hist < 0 and hist > hist[1];
# Scan signal for color changing from cyan to blue
plot conditionCyanBlue = Sum(histCyan[barCountOne], barCountOne) == barCountOne and Sum(histBlue, barCountTwo) == barCountTwo;
# Scan signal for color changing from blue to red
# plot conditionBlueRed = Sum(histBlue[barCountOne], barCountOne) == barCountOne and Sum(histRed, barCountTwo) == barCountTwo;
# Scan signal for color changing from red to yellow
# plot conditionRedYellow = Sum(histRed[barCountOne], barCountOne) == barCountOne and Sum(histYellow, barCountTwo) == barCountTwo;
# Scan signal for color changing from yellow to cyan
# plot conditionYellowCyan = Sum(histYellow[barCountOne], barCountOne) == barCountOne and Sum(histCyan, barCountTwo) == barCountTwo;

Now I will update all of those previous posts on this topic to include a link to this one so that everyone can use this one instead of the others.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on November 18, 2024 12:24 pm