TTM Squeeze scan 2nd blue bar after 2 or more cyan


Category:
0
0

Hi Pete,

Your TOS snippet below is to scan TTM Squeeze for the 2nd yellow bar after 2 or more red bars. Can you help me edit it to scan 2nd blue bar after 2 or more cyan bars? Thanks for any help!

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 histRed = hist < 0 and hist < hist[1];
def histYellow = hist < 0 and hist > hist[1];
plot scan = histYellow and histYellow[1] and histRed[2] and histRed[3];

RESOLVED
Marked as spam
Posted by (Questions: 3, Answers: 1)
Asked on September 27, 2020 8:43 am
1029 views
0
Private answer

Update: There is a newer version of this type of scan which enables you to select any number of consecutive bars and any combination of colors. You will find that solution posted here:

https://www.hahn-tech.com/ans/ttm-squeeze-histogram-any-color-change-any-bar-count/

First order of business is to provide a link to that previous post you referenced:

https://www.hahn-tech.com/ans/ttm-squeeze-scan-for-second-yellow-bar-after-2-or-more-red-bars/

Please realize that if you mention a previous post without providing a link to you will be frustrating a very large segment of our audience.

Seems I have created a monster. How many different combinations of different colored bars do you suppose folks will think of? And each one requires a custom solution. If I thought it was popular enough, I might consider building a premium scan for this that allows a full range of flexibility for selecting various combinations of different colored bars by adjusting some simple user inputs at the top if the code. But I don't see a need yet.

Bars on the TTM Squeeze histogram are colored according the to the following very simple rules:

  1. Cyan: higher than previous bar and above zero
  2. Blue: lower than previous and above zero
  3. Red: lower than previous and below zero
  4. Yellow: higher than previous and below zero

So we take the code you copied from the previous post and substitute the rules for blue and cyan. I have retained the previous lines of code so that this solution contains all four colors. There are two scan signals. One for the original that was provided in the previous. The new one has been added for this current request.

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];
# use this to scan for second yellow bar after two or more consecutive red
#plot scan = histYellow and histYellow[1] and histRed[2] and histRed[3];
# use this to scan for second blue bar after 2 or more consecutive cyan
plot scan = histBlue and histBlue[1] and histCyan[2] and histCyan[3];

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 27, 2020 11:11 am
0
Thanks Pete!!! Sorry for not providing the post link. I'll remember that for the future.
( at September 27, 2020 12:43 pm)
0
I have tried the code above and it works exactly as I expected for the Yellow and Red colors of the histogram, which are both below the zero line of the TTM histogram indicator. I can not get the code to work properly for the Blue and Cyan colors which are above the zero line. In order to get the results I expect for the last two lines of the code above, I need to change the plot scan line to : plot scan = histCyan and histCyan[1] and histBlue[2] and histBlue[3]; so the logic of the the statement is true: # use this to scan for second blue bar after 2 or more consecutive cyan. Obviously the simple rules for the TTM Squeeze histogram colors is correct, so I just don't get it. If I rearrange the > and < logic for the Cyan and Blue colors, that makes the last 2 lines of the above code correct. I'm a pretty lousy coder, so if I am missing something, please help me. Thanks in advance, Pat.
( at December 13, 2020 10:41 pm)
0

Please use the search tool of this forum to find solutions before requesting assistance. The Cyan colored histogram bars of the TTM_Squeeze has already been posed on multiple occasions in various forms.

https://www.hahn-tech.com/ans/scan-base-off-of-ttm-squeeze-color-of-histogram/

https://www.hahn-tech.com/ans/ttm_squeeze-first-cyan-bar-after-three-bars-of-any-other-color/

https://www.hahn-tech.com/ans/ttm-squeeze-scan-2nd-blue-bar-after-2-or-more-cyan/

( at December 14, 2020 8:59 am)
0
Thanks Pete for making me open my eyes literally. I knew your code was right, as it had to be. I have had visual issues for years with dark blue on computer screens as it is difficult for me to see clearly. Two years ago I switched the TTM histogram colors to include Green instead of dark blue across the whole TOS platform. I removed the dark blue and put green on the left and cyan on the right, my bad. Visually this was easy on my eyes and green means up on a candlestick chart. The color change was perfect until the other day when I found your code and I had to have that scan. I just realized my mistake today so I put the TTM colors back to default. Thanks again. I guess its time for me to make a donation.
( at December 14, 2020 2:53 pm)