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.
 
Hello. I'm pretty new to this site and ThinkScript but I'm loving it so far. I apologize if this is a dumb question. I have done considerable searching but have not found an answer. Any help is greatly appreciated!

I have a lower study I use that doesn't signal very often. Instead of having to watch the chart all day I wanted to make it give an audible alert when triggered. I was able to figure out how to do that by adding this to the script:

alert( Signal1, "BUY", Alert.BAR, Sound.Bell );
alert( Signal2, "SELL", Alert.BAR, Sound.Chimes );

I've also figured out how to record my own audio file .mp3s and add them to the alerts section for the upper chart (right click, create alert, notify with sound, "play sound" drop-down, edit custom sounds, ...) So I can set an alert on the chart and have it play my custom sounds, but I want to make my LOWER study play custom alert sounds.

I've tried changing:
alert( Signal1, "BUY", Alert.BAR, Sound.Bell );
to
alert( Signal1, "BUY", Alert.BAR, Sound.Custom1 ); and stuff like that to no avail.

Thanks!

You can ONLY use the native sounds in Study and Strategy alerts. However for MarketWatch alerts I understand you can incorporate your own wav file but I have not tried doing that as I'm happy with the default sounds.
 
Last edited:
You can ONLY use the native sounds in Study and Strategy alerts. However for MarketWatch alerts I understand you can incorporate your own wav file but I have not tried doing that as I'm happy with the default sounds.

Well that explains why I couldn't figure it out. Thank you!
 
Hi all. I am setting up some scans of watchlists. Looking for some help or clarification.

I know how to set up the alerts using 'Alert when scan results change', but it looks like you can only have one active Alert on a watchlist scan at a time? Every time that I create a new scan on a different watchlist, then set up the alert parameters . . . it cancels any 'active' alerts in the alert book and only shows the most recent one as active.

Am I missing something? Thanks all.
 
I would like to setup a scan with a study filter to only scan for one symbol - lets say SPY.

The reason for this weird scan is - The study does not generate mobile push alerts correctly (fires randomly), if I setup an alert via marketwatch/create alert.
Hence as a work around, I would like to see if it works correctly when I setup a scan and add the the study as a filter just on SPY and have it generate mobile push alert (using -> notify when a symbol is added).

Appreciate your help in this matter.
 
@ezrollin That's correct, alerts through a watchlist scanner can have up to 15mins delay, but I don't think it's that bad, especially if you're scanning on higher timeframe.
 
When trying to create a marketwatch alert for this indicator it gives an error - "rec usage not allowed in this context"
I assume it is because of BorS=GetValue(BorS,1);
How do I get around this?

What the indicator is doing is - paint only the 1st arrow in short-term trend.
if BorS is already at Buy signal, dont plot.
Only plot BoRs if was previously a Sell signal and now has changed direction to Buy.

Any ideas - how I can make this work so that I can create Marketwatch alerts?

I tried using a scanner for alerting - but it doesnt work (although GetValue doesnt generate an error when creating a scanner)

Appreciate your input!

Script below -

Code:
#declare lower;

input length = 10;
input breakoutLevel = -5;
input breakdownLevel = -95;


def hh = Highest(high, length);
def ll = Lowest(low, length);
def result = if hh == ll then -100 else (hh - close) / (hh - ll) * (-100);

def WR = if result > 0 then 0 else result;
plot UpSignal = if Crosses(WR, breakoutLevel, CrossingDirection.ABOVE) then high else Double.NaN;
plot DownSignal = if Crosses(WR, breakdownLevel, CrossingDirection.BELOW) then high else Double.NaN;

def whichCondition = if UpSignal is true then 1
else if DownSignal is true then -1 else 0;

input offset = 0;
def BorS;
if 0 == 1
{
BorS=0;
}
else
{
  if WhichCondition == 0
  {  
  BorS=GetValue(BorS,1);
  }
  else
  {
  BorS=WhichCondition;
  }
}
plot BBB = if Crosses(WR, breakoutLevel, CrossingDirection.ABOVE) and (BorS==1 and GetValue(Bors,1) != 1) then low else Double.NaN ;

plot SSS = if Crosses(WR, breakdownLevel, CrossingDirection.BELOW) and (BorS==-1 and GetValue(Bors,1) != -1) then high else Double.NaN;

BBB.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BBB.SetDefaultColor(Color.YELLOW);
SSS.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
SSS.SetDefaultColor(Color.PINK);
 
Last edited by a moderator:
Hello all, I just started using the Thinkorswim alerts and love it but do the alerts only work during market hours? I have an alert to sms me when a price hits a certain mark and it only worked until 4pm.

Thanks for the help!
 
Do you have pre-market enabled? You may need to have that while you're looking at the chart. I'm not sure if you also have to enable extended market hours for the alerts as well (is that even an option?).
 
Pre market and after hours are combined into "Extended Hours". Here is a screen shot of enabling both:
vIIZo7n.png
 
Last edited:
Hi,

Is there any code to set price alerts on tickers automatically in a batch instead of doing them one by one?
 
Not really. There is no universal code to just copy/paste. But it shouldn't be that hard for indicator that produce signals.

Here is a quick one as an example:

Code:
# Define Bullish FTR Candle
def IsUp = close > open;
def IsDown = close < open;
plot Bullish_FTR =
    IsUp[4] and
    IsUp[3] and
    IsUp[2] and
    IsDown[1] and
    IsUp[0] and
    high[2] > high[1] and
    close[3] < close[2] and
    open[1] < close[0] and
    low[2] < low[1] and
    open[4] < open[3] and
    close[4] < high[3] and
    open[3] < open[2];

Bullish_FTR.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Bullish_FTR.SetDefaultColor(GetColor(0));

Alert(Bullish_FTR, " ", Alert.Bar, Sound.Chimes);

Full source code if you're interested.
 
Hi,
I'm trying to create an alert that triggers when price crosses below the vwap. I keep getting the following error.

"rec usage is not allowed in this context"

I know this is due to my referencing a prior value but I don't know how to get around it. The thinkscript I am using is as follows.
Code:
close crosses below GtDailyVWAP()

Where the function GtDailyVWAP is:
Code:
def yyyyMmDd = GetYYYYMMDD();
def isPeriodRolled = if yyyyMmDd != yyyyMmDd[1] then 1 else 0;

def volumeSum;
def volumeVwapSum;
def volumeSumPrev;
def volumeVwapSumPrev;

volumeSumPrev = volumeSum[1];
volumeVwapSumPrev = volumeVwapSum[1];

if (isPeriodRolled) {
    volumeSum = volume;
    volumeVwapSum = volume * vwap;
} else {
    volumeSum = volumeSumPrev + volume;
    volumeVwapSum = volumeVwapSumPrev + volume * vwap;
}
def price = volumeVwapSum / volumeSum;

plot VWAP = price;

VWAP.SetDefaultColor(GetColor(0));
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
436 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