Alert on color change of TTM Squeeze histogram


0
0

Originally posted by Hilario Dsouza as a comment to the following video: https://www.hahn-tech.com/thinkorswim-watchlist-ttm-squeeze/

Hi Pete, On the TTM squeeze I wanted to setup a trigger (Plot) on the COLOR of the BAR. For Example if the COLOR is LIGHT BLUE or YELLOW then setup an alert. I see you did something similar in the video above. I am planning to use the color of the bar along with the MACD and stochastic indicator. I wrote the initial lines of code, but I am not sure how to get to the Yellow Bars.
Thanks
Hilario
————————————————–
input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;

def yellowbar = TTM_Squeeze(price, length, nK, nBB, alertLine).SqueezeAlert;

Marked as spam
Posted by (Questions: 38, Answers: 3467)
Asked on November 27, 2016 1:14 pm
1850 views
2
Private answer

Hi Hilario,

The first step is to get the value of the Histogram from the TTM Squeeze indicator. Because the change in color is dictated by the value of the histogram compared to it’s relationship to the zero line as well as the value of it’s preceding bar. The color change from Cyan to Blue is defined as the histogram above zero, the current bar lower than previous. The we add an element that checks that the histogram was trending higher before current bar. This way we are only alerted on the first blue bar after a series of Cyan. The signals below the zero line are handled in similar fashion. The last two lines are for the alerts.

declare lower;

input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;

def sqzHist = TTM_Squeeze(price, length, nK, nBB, alertLine).Histogram;

plot cyanToBlue = sqzHist > 0 and sqzHist < sqzHist[1] and sqzHist[1] > sqzHist[2];

plot redToYellow = sqzHist <= 0 and sqzHist > sqzHist[1] and sqzHist[1] < sqzHist[2];

Alert(cyanToBlue, “TTM Squeeze Blue Bar”, Alert.BAR, Sound.Ring);
Alert(redToYellow, “TTM Squeeze Yellow Bar”, Alert.BAR, Sound.Ring);

Marked as spam
Posted by (Questions: 38, Answers: 3467)
Answered on November 27, 2016 1:32 pm

Hi Pete,

Since I’m new to ToS, I just wanted to inquire if

1) the code above should be inserted into a new study and then would be added to a chart and
2) Will this audible alert only be triggered on a displayed chart or can it be applied to a watchlist that uses the TTMSqueeze script you developed (but using a 5 min interval)

Thanks!

( at September 21, 2017 2:13 pm)

This is only applicable to chart studies. So the answer to question 1 is yes. Question 2, this code will only trigger an alert on an active chart. Alerts cannot be applied to a watchlist. However it is possible to create a custom scan and use that to build a dynamic alert that is applied to a list of stocks. We explain how to create dynamic alerts from custom scans towards the end of this video: https://www.hahn-tech.com/thinkorswim-overnight-range-scan-alert/
If you require further assistance please post a new question in the forum.

( at September 21, 2017 9:01 pm)
1
Private answer

Thanks Pete for the details and the code. I did additional modifications and it works great !!

Marked as spam
Posted by (Questions: 4, Answers: 5)
Answered on November 28, 2016 7:28 am

Glad to hear we got this working for you Hilario. Please be so kind as to vote up for the answer we provided so other users can identify the solution to your question. (to vote for an answer, simply click once on the up or down arrow to the left of the answer. The number between the arrows shows the number of up votes for that answer)

( at November 28, 2016 10:14 am)
0
Private answer

would this script work on tradingview?

Marked as spam
Posted by (Questions: 1, Answers: 1)
Answered on January 10, 2018 4:26 pm

No, the languages are quite different so you could not copy and paste this code to TradingView and get it to work. The other reason is that this code makes use of a proprietary study licensed by John Carter. Thinkorswim allows us to make use of the licensed study without exposing the proprietary source code.

( at January 10, 2018 4:49 pm)