Questions About Alerts In ThinkOrSwim

Brady0524

New member
The thinkscript study I created and shared yesterday, I try to use it in setting alert. But was unable to do it. The "OK" button stayed grayed out and was not available for me to continue to the alert. Then I saw the following message: "rec usage is not allowed in this context"

I'm looking to set up Conditional Study Alerts found under MarketWatch tab. In particular I wish to use the Languerre RSI, along with a few other conditions, to trigger alert to phone. The problem is the Rec Coding. If you enter this L-RSI into the study alert tab you get the statement found in the title. I was wondering if there was a work around. Thanks.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Hi,

I have couple of Indicators that has alerts and I get the alerts and shows up for few seconds then it is gone. Is there any location I can go and see all of them? It was really fast and missing many of them. I'm not seeing them in the below location. Is there any way we have have the alerts stay on the screen little longer?

58g0BjC.png
 
I made a script and added the alert. It looks it works fine - I can hear the bell sound if I close to my laptop. The same script is running on the mobile ThinkorSwim app. But I don't get any notification from mobile script. I would like to get also text alert. I added everything in the settings and it works fine if I add the alert manually. But not from the alert in the script. Is it possible in general to get notification from script?

Edit: Follow the tutorial here https://usethinkscript.com/threads/how-to-receive-thinkorswim-alert-notifications-via-phone.5430/
 
I also have this question. I'm using the latest MacOS and TOS Desktop, latest iOS and TOS mobile.

I get the desktop alert but nothing on the iPhone (running TOS Mobile).

Update: I contacted TOS support about this. They sent me instructions on enabling notifications in the desktop app and on the phone (which I already had in place). So, still no joy getting an alert() from thinkscript on the laptop sent to the iPhone. I am giving up on the idea.
 
Last edited:
@BenTen Hello. I have a similar questions regarding alerts but wasn't sure where to post them. I see that you have helped with various scripts that include sound alerts. I borrowed one and created the following in an attempt to create an audible reference for when "the tape" speeds up.

Code:
# Ticker for audible signal as volume increases
# based on_volume contracts being filled more quickly

def tick = tick_count - tick_count[1];

# Alerts
Alert(tick, " ", Alert.Bar, Sound.Chimes);

This code produces a ding each time the next candle starts. I am currently watching it with a 21T count.
Q1) Is there a way to have the sound produced each time a contract is filled instead of when is reaches a count of 21 and starts the next candle?
Q2) Are there any other sounds that can be implemented besides the standard bell, ding, ring, or chimes? I would prefer a tick or click sound.
 
Q1) Is there a way to have the sound produced each time a contract is filled instead of when is reaches a count of 21 and starts the next candle?

In theory every time a contract fills it produces a volume candle, therefore u can set it to make a alert every time a volume adds +1... (dont know what you are trying to do but it would constantly be going off on most instruments/tickers)

Q2) Are there any other sounds that can be implemented besides the standard bell, ding, ring, or chimes? I would prefer a tick or click sound.

if you have a study and the actual ticker/symbol/instrument loaded on your chart with the study loaded you can get a alert, however in doing this as you have already found out you are out of luck if you are trying to change from the stock standard TOS sounds from within a study by itself as you are restricted to using the 4 or 5 stock ones..

there is a tad bit trickier and more of a " limited workaround" but you can add scan to watch-list, create alert when symbol gets added (the scan would have to meet your criteria and be labeled as "TRUE") for it to trigger, then u can also choose custom sounds from the menu..... unfortunately for tos the scans inside the watch-lists only refresh every couple minutes so if your expecting live tick by tick alerts to be sent as sound your out of luck..


sEY1AWs.png
 
I'm trying to manually set an alert for a chart I pulled up by navigating to..

=> Right Click Chart
=> Select 'Create Alert'
=> Select 'Price' Dropdown
• Select 'Study'
• Select 'Edit'...

The study I have loaded on my chart is below, it finds the distance form the current price to the ATR Trailing Stop as a %. I'm setting the 'alert' for when the price approaches the trailing stop.

Plot distanceToStop is less than VALUE.

When I set the condition for the study in the watchlist, I receive the error "Error Processing Script: No Such Study

Is anyone able to clue me in on what I'm doing wrong?

For reference to everyone here. You cannot create an alert based on a study with a REFERENCE(). Now that the alert has been re-created...there is a new error. yay.

rec usage is not allowed in this context

Any ideas what this means? TOS has little info on it....

Code:
# By Dan Dude
# ATR Trailing Stop - Chart Label
# Copyright forever
input price = close;

def ATR = reference ATRTrailingStop();

#def DistanceBetween = (Sqrt(Sqr(EMASlow / EMAFast))) / 100;

#def distanceToStop = (price / ATR - 1) * 100;

plot distanceToStop =  (Sqrt(Sqr(price / ATR - 1))) * 100;

#def distanceToStopInDollars=  (Sqrt(Sqr(price - ATR)));

input Labels = "Yes";


AddLabel(distanceToStop and yes, "ATR Dist. = " + asPercent(round(distanceToStop,2)), if distanceToStop > .35 then color.light_RED else color.light_green);

#AddLabel(distanceToStopInDollars and yes, "ATR Dist. = $" + asText(round(distanceToStopInDollars,2)), color.light_green);

**END
 
I am trying to create alerts for a the PSAR indicator of a stock inverting from bullish to bearish, but I cannot get it to work. Basically, selecting PSAR as a study alert does not work in ThinkOrSwim, even though you can use basically all other crossover studies for an alert. I copied the script think or swim provides into a custom script, but now and getting the error: c and I cannot figure out why. Any helpful assistance is appreciated. All I have done is embedded the PSAR indicator script inside of a PSAR crossover script.

Code:
#wizard input: crossingType
#wizard text: Inputs: acceleration factor:
#wizard input: accelerationFactor
#wizard text: acceleration limit:
#wizard input: accelerationLimit

input accelerationFactor = 0.02;
input accelerationLimit = 0.2;
input crossingType = {default Bearish, Bullish};

#Begin Embedded PSAR Script
script ParabolicScript {
input accelerationFactor = 0.02;
input accelerationLimit = 0.2;
Assert(accelerationFactor > 0, "'acceleration factor' must be positive: " + accelerationFactor);
Assert(accelerationLimit >= accelerationFactor, "'acceleration limit' (" + accelerationLimit + ") must be greater than or equal to 'acceleration factor' (" + accelerationFactor + ")");

def state = {default init, long, short};
def extreme;
def SAR;
def acc;

switch (state[1]) {
case init:
state = state.long;
acc = accelerationFactor;
extreme = high;
SAR = low;
case short:
if (SAR[1] < high)
then {
state = state.long;
acc = accelerationFactor;
extreme = high;
SAR = extreme[1];
} else {
state = state.short;
if (low < extreme[1])
then {
acc = Min(acc[1] + accelerationFactor, accelerationLimit);
extreme = low;
} else {
acc = acc[1];
extreme = extreme[1];
}
SAR = Max(Max(high, high[1]), SAR[1] + acc * (extreme - SAR[1]));
}
case long:
if (SAR[1] > low)
then {
state = state.short;
acc = accelerationFactor;
extreme = low;
SAR = extreme[1];
} else {
state = state.long;
if (high > extreme[1])
then {
acc = Min(acc[1] + accelerationFactor, accelerationLimit);
extreme = high;
} else {
acc = acc[1];
extreme = extreme[1];
}
SAR = Min(Min(low, low[1]), SAR[1] + acc * (extreme - SAR[1]));
}
}
#End Embedded PSAR Script

plot parSAR = SAR;
parSAR.SetPaintingStrategy(PaintingStrategy.POINTS);
parSAR.SetDefaultColor(GetColor(5));
}
def sar = ParabolicScript(accelerationFactor = accelerationFactor, accelerationLimit = accelerationLimit);

plot signal = Crosses(sar, close, crossingType == crossingType.Bearish);

signal.DefineColor("Bullish", GetColor(5));
signal.DefineColor("Bearish", GetColor(6));
signal.AssignValueColor(if crossingType == crossingType.Bullish then signal.Color("Bullish") else signal.Color("Bearish"));

signal.SetPaintingStrategy(if crossingType == crossingType.Bullish
then PaintingStrategy.BOOLEAN_ARROW_UP
else PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
How can i add an alert to this

Code:
input typicalLength = 5;
input haLength = 8;
input paintBars = yes;

def haOpen = (ohlc4[1] + haOpen[1]) / 2;
def haClose = (ohlc4 + haOpen + Max(high, haOpen) + Min(low, haOpen)) / 4;

plot AvgTyp = ExpAverage(hlc3, typicalLength);
plot AvgHAC = ExpAverage(haClose, haLength);


AvgTyp.SetDefaultColor(GetColor(1));
AvgHAC.SetDefaultColor(GetColor(2));
 
That didn't work, maybe i'm doing something wrong.

Code:
input typicalLength = 5;
input haLength = 8;
input paintBars = yes;

def haOpen = (ohlc4[1] + haOpen[1]) / 2;
def haClose = (ohlc4 + haOpen + Max(high, haOpen) + Min(low, haOpen)) / 4;

plot AvgTyp = ExpAverage(hlc3, typicalLength);
plot AvgHAC = ExpAverage(haClose, haLength);


AvgTyp.SetDefaultColor(GetColor(1));
AvgHAC.SetDefaultColor(GetColor(2));
Alert(AvgTyp crosses above AvgHAC, "Cross Up", alert.bar, sound.chimes);
Alert(AvgTyp crosses below AvgHAC, "Cross Down", alert.bar, sound.chimes);
 
Last edited by a moderator:
@cattle trader @Pensar Alerts implemented through the indicator's source code will not give you the option for text messages. You will only get notified via a sound alert (ex: chime). You would need to go to the MarketWatch tab and set up another alert there.

Note: not all indicators will be supported through MarketWatch.
 
Anyone know how to get around "rec usage is not allowed in this context" for a simple trailing stop for an alert or order?

This is the code I am using:

Code:
Input Discount = .6;
Input Starttime = 0945;
def SecondsPassed = SecondsfromTime(Starttime);
def TSTP = if SecondsPassed >0 then if (Close * (1-Discount/100)) < TSTP[1] then TSTP[1] else Close * (1-Discount/100) else 0;
plot TSTP1 = If Close crosses below TSTP then 1 else 0;
 
I saw someone asked similar question quite a while back on other places, and it seemed to be a limitation of thinkscript. In fact, I have Study and Strategy that use alot of rec, and have been not able to setup email/sms alert for those Study/Strategy. Anyone knows if it is still a limitation of TOS, or has been resolved or some workaround?

I have some kind of silly "workaround" is to use the alert with sound, and wrote a small program to send me an email/sms when there is sound generated from the PC.

Wonder if there is a smarter way to solve the problem?
 
I am familiar with scanner setup and am using it for quite some time. Now, I just want to DYNAMICALLY populate the result of a scan into a watchlist. Easy, I would go to watchlist and select the name of the scan that I previously saved. it seems obvious.

The problem is that the result I see in watchlist is not updated. It means that when I go back to scanner and hit scan button, the result is different than what the watchlist gave....What did I do wrong? why the content of watchlist do not reflect the result of the scanner? do I mess up with timeframe (in my particular example, I have it set to one hour)
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
475 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top