Here’s a block of code that I am going to be implementing in scripts in future. It’s a generic alert configuration code. It assumes that you have another line in your code that defines what the alert trigger is, like so:
def alerttrigger = high>high[1];
The line above says I want an alert if the bar’s high is above the last bar’s high, for example. You can replace it with whatever you want to be alerted about.
Here’s the alert code:
#
# Alerts:
#
def alerttrigger = 1; #replace the 1 with your definition
# BLOCK CODE BELOW
input alerttext = “Alert Text”;
input UseAlerts = {false, default true};
input AlertType = {default “BAR”, “ONCE”, “TICK”};
def at=AlertType;
input AlertSound = {“Bell”, “Chimes”, default “Ding”, “NoSound”, “Ring”};
alert(alerttrigger AND UseAlerts, alerttext, if at==1 then Alert.ONCE else if at==2 then Alert.TICK else Alert.BAR, AlertSound);
To use it in your scripts, change the “def alerttrigger = 1;” line in your code to what you want to alert about, and then drop the entire code block at the end of your script file. Instant configurable alerts!
Tags: alerts
January 11, 2010 at 3:41 pm
[...] Read the Prospectus Trading, Think or Swim, Ninjascript and other Rocket Science « Thinkscript Tip: Alert Code Block for Think or Swim [...]
January 12, 2010 at 10:23 pm
[...] would tend to use the upper one only, but you may want the other one, so I did it. I also added the alert code block that I highlighted earlier, so you can let it run on a chart and get alerted if a divergence shows [...]
February 2, 2010 at 7:02 pm
[...] function, depending on if the percentage was above or below the alert level. I added my alerts block code, changed the alert parameter to percentage>=alert level, and that’s a [...]
May 9, 2010 at 9:38 pm
Alert Code Block for Think or Swim:
Thank you for this code. What changes do I need to make in order to received audible alert?
I am only getting text alert with the above code. I would like to have a sound.
Thanks again.
May 10, 2010 at 2:55 pm
Alert Code Block for Think or Swim:
Thank you for this code. What changes do I need to make in order to received audible alert?
I am only getting text alert with the above code. I would like to have a sound.
Thanks again.
December 29, 2010 at 2:18 pm
Can you help me add the ‘email’ portion to the script?
June 20, 2011 at 11:42 am
I want to know how to trigger a bash or shell script from an alert.
Is there a way?
Thanks,
Charles
June 20, 2011 at 12:42 pm
Not that I know of
May 9, 2012 at 6:52 am
scripts, themes…
[...]Thinkscript Tip: Alert Code Block for Think or Swim « Read the Prospectus[...]…