Finally, an Alert Based on TTM Trend
Responding to numerous requests from viewers like you, this video shows how to add an Alert to the TTM Trend.
The TTM Trend is a licensed Study listed in Thinkorswim under the category name John Carter. For some reason the built in version does not provide audible alerts when the colors change from red to blue and back again. Well fortunately Thinkorswim provides a way to accomplish this without violating any copyright laws.
In this brief video you will see how the TTM Trend indicator is referenced from inside a custom study. We’ll explain how this is possible and then show you how to simply add a few lines of code to include the Alert feature.
Lean More:
Would you like to learn how to master the chart settings on Thinkorswim? Click here for our 3 part series: Thinkorswim Chart Settings Tutorial
DISCLAIMER: I AM NOT A CERTIFIED FINANCIAL ADVISOR AND NOTHING IN THIS VIDEO OR TEXT IS AN ADVERTISEMENT OR RECOMMENDATION TO BUY OR SELL ANY FINANCIAL INSTRUMENT. NOR IS THIS VIDEO OR TEXT INTENDED TO INSTRUCT YOU ON HOW TO MAKE BUY OR SELL DECISIONS USING ANY OF THESE INDICATORS.
*Thinkorswim is a chart analysis platform offered by TD Ameritrade: www.tdameritrade.com
TD Ameritrade provides financial services including the trading of Stocks, Futures, Options and Forex.
Please be sure to share this page with your friends and colleagues. Leaving comments below is the best way to help make the content of this site even better.
Watch the video, Thinkorswim Alert TTM Trend below:
input compBars = 6;
input paintBars = yes;
def upTrend = TTM_Trend(compBars, paintBars).TrendUp;
def downTrend = TTM_Trend(compBars, paintBars).TrendDown;
def bullReversal = upTrend and downTrend[1] == yes;
Alert(bullReversal, "Bullish Trend", Alert.BAR, Sound.RING);
def bearReversal = downTrend and upTrend[1] == yes;
Alert(bearReversal, "Bearish Trend", Alert.BAR, Sound.RING);
Can you modify the code to send a text message like the Chart alert feature in TOS? Looks like a simple trade after 18:00 works well, but I don’t want to sit in my office from 18_00 to 22:00 Sun/Thurs night. 🙂 Thanks.
Chart studies are not able to send sms/email notifications. The following post from our Q&A forum describes the various types of alerts available on Thinkorswim along with their capabilities: https://www.hahn-tech.com/ans/generate-alerts-from-macdstrat-chart-strategy/
With the regular TTM_Trend indicator, my colors for up and down bars are changed to blue and red as you see on your screen. But with this new script, the color changes to green and orange as I had it before adding TTM_Trend. How can I change the colors too. Also, tried adding the older script completely and see if the colors change, but they did not. Is there any other setting I need to set or change my code?
The version published with this video does not change the colors of the bar and only produces alerts. If you want the bars to be painted you will need to also add the original.
hi Pete,
pasting this code snippet into Study Alerts, getting this error: “No such function: TTM_Trend at 4:17”
works fine when I test it. Must be a copy/paste error.
can you let me know what build # you are running?
Thinkorswim automatically updates every time you log in. So the build number is always going to be the most current. Current build number is 1960. But that is absolutely not the issue.
Only get alarms on 1 hr. charts for me. I trade futures and like to use range charts,does range charts cause a problem?
Should work on range charts. Give it a try and let us know.
Rebooted, working ok, Thank You1
oops forgot to add my attemt at fixing the code that came in on youtube. The line after input alert line is red but I don’t know if that’s the only thing wrong bec you fix one thing and something else becomes red. Please fix Thanks
#”TTM_TrendAlert”
input price = CLOSE;
input length = 20;
input nK = 1.5;
input nBB = 2.0;
input alertLine = 1.0;
input TTM_Trend = TTM_Trend(close, length, nK, nBB, alertLine).TrendAlert;
def TTM_trend = TTM_Trend(close, length, nK, nBB, alertLine).TrendAlert;
plot TTM_Trend = TTM_Trend(close, length, nK, nBB, alertLine).TrendAlert;
def upTrend = TTM_Trend(price, length, nK, nBB, alertLine).TrendUp;
def downTrend = TTM_Trend(price, length, nK, nBB, alertLine).TrendDown;
def bullReversal = upTrend and downTrend[1] == yes;
def bearReversal = downTrend and upTrend[1] == yes;
Alert(bullReversal, “Bullish Trend”, alertLine, Sound.Ring);
Alert(bearReversal, “Bearish Trend”, alertLine, Sound.Ring);
This is not the code that I provided on the website. I just tested the code from the website and it works perfectly. If you are getting errors you are probably not copying the entire code. From the code you just posted here, it looks like you have tried to add some inputs that only apply to the TTM_Squeeze.
This came the comment section of your TTM_Trend video on yout tube https://www.youtube.com/watch?v=qkZADjIydOI&lc=UgztN69fTH9UOU11ta54AaABAg.8hHyxIWtNyD8hI6d2yZe9K
I like the way he modified your code and tried to fix it unsuccessfully but I’m not a coder.. Im good at copy and paste. Please fix Please fix Please fix it. Thanks
I’m sorry but I don’t have a clue what you are requesting. Seems you are trying to fix something? What is broken?
Thanks so much for putting this together. Question, how the code needs to be modified to use it with marketwatch alerts. For instance condition 1: TTM_trend is up Condition 2: MACD is crossing up. Thank you.
Is there a way to get a text message from this Alert. When I copy to the alert editor it doesn’t like the TTM_Trend variable.
Thanks.
JB
The only other alternative is to use it to create and save a custom scan. Then create a dynamic alert from that scan.