Thinkscript study alert for above average spike in volume?

A

Asianraisin

New member
hello,
I am trying to set up a thinkscript study alert for high (8x higher than average) intraday volume. I'm trying to do this on the 1 min time frame. The goal is to catch the beginning of large moves like with what happened with Disney today or with Twilio and Boeing earlier this week.
What I've done so far is created a study alert (marketwatch > study alerts) and put the following code in:

def afterStart = secondsfromtime(9000)>0;
def beforeEnd = secondstilltime(1430)>0;
def conditionTrue = volume > 8*average(volume, 390);
plot alert = afterStart and beforeEnd and conditionTrue;

I am trying to get alerted for volume 8x higher than average from the hours 9am cst to 2:30pm cst.(to avoid the early morning and late afternoon vol spikes). 390 representing the 390 mins in a trading day.
Does this look right? I'm not sure if I'm doing this correctly. Is there any way to backtest this through OnDemand?
Thank you very much for taking time to look at my post.
 
Last edited by a moderator:
T

tomsk

Well-known member
VIP
Warehouse
@Asianraisin You are close, please note that you probably meant "0900" rather than "9000" in your start time
I have use a bracketed time, note that times are interpreted by TOS in EST so you may wish to adjust that accordingly.
Here then is your scan.

def Active = SecondsFromTime(0900) > 0 and SecondsTillTime(1430) >= 0;
plot scan = Active and volume > 8*average(volume, 390);
 
A

Asianraisin

New member
thank you very much for your reply. I'm going to test it out today.

edit: just tried it out and after creating the alert, it immediately triggers and the alert is now registered as "triggered" instead of "active". Do you have any suggestions for how to fix it so that it operates properly? do i need to specify the aggregation period as 1 minute?
 
Last edited:
MBF

MBF

Active member
VIP
Warehouse
thank you very much for your reply. I'm going to test it out today.

edit: just tried it out and after creating the alert, it immediately triggers and the alert is now registered as "triggered" instead of "active". Do you have any suggestions for how to fix it so that it operates properly? do i need to specify the aggregation period as 1 minute?
Try this @Asianraisin go to scan, select add filter, go to study, go to the tiny pencil on the right, hit delete, go to thinkscript editor on the top left, copy and paste the code above into it, change the aggregation to 1 minute at the very top left, hit okay, and scan, nothing will come up right now because market closed but you can now save this as a scan by ... clicking the little notebook next to "no matching symbols" click alert when scan results change, name your scan and you should be able to find it under your watchlist. In the morning things should pop up if its working correctly. You can maybe find out early before the open if it is working by turning on the EXT next to the aggregation you've chosen.
 
A

Asianraisin

New member
Try this @Asianraisin go to scan, select add filter, go to study, go to the tiny pencil on the right, hit delete, go to thinkscript editor on the top left, copy and paste the code above into it, change the aggregation to 1 minute at the very top left, hit okay, and scan, nothing will come up right now because market closed but you can now save this as a scan by ... clicking the little notebook next to "no matching symbols" click alert when scan results change, name your scan and you should be able to find it under your watchlist. In the morning things should pop up if its working correctly. You can maybe find out early before the open if it is working by turning on the EXT next to the aggregation you've chosen.
awesome, I appreciate you walking me through this. would you suggest I add this as a scanner rather than as a study alert? I suppose one major advantage to adding as a scanner as opposed to a study alert is you don't have to create an alert for each individual ticker.
 
Last edited:
T

tomsk

Well-known member
VIP
Warehouse
@Asianraisin Use a dynamic Watchlist wand you'll get SMS, emails and audible alerts if you select them all
From the scanner - use the function "Alert when scan results change"
Contact TOS support for a walkthrough of this feature if you're not familiar.
 
MBF

MBF

Active member
VIP
Warehouse
awesome, I appreciate you walking me through this. would you suggest I add this as a scanner rather than as a study alert? I suppose one major advantage to adding as a scanner as opposed to a study alert is you don't have to create an alert for each individual ticker.
@Asianraisin I usually only use alerts when price crosses support or resistance. This is better as a scan but I would use it only on your favorite stocks, until you get used to it, TOS I mean. For instance if I were to use this scan I would have a CORE list that I have scanners for in the morning and at night so at the top of the scan you will see "Scan in" I put in my Core list and then leave the intersect with blank. It will only scan those and pop those up as they follow your scan inputs.
 

Top