Thinkscript Tip: Alert Code Block for Think or Swim

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:

9 Responses to “Thinkscript Tip: Alert Code Block for Think or Swim”

  1. Volatility-Based Trailing Stop Study Updated (v3) « Read the Prospectus Says:

    […] Read the Prospectus Trading, Think or Swim, Ninjascript and other Rocket Science « Thinkscript Tip: Alert Code Block for Think or Swim […]

  2. RSI Divergence Indicator for Think or Swim « Read the Prospectus Says:

    […] 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 […]

  3. Daily Average Volume Study with Alerts for Think or Swim « Read the Prospectus Says:

    […] 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 […]

  4. Nay Says:

    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.

  5. Nay Says:

    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.

  6. OptionTrader Says:

    Can you help me add the ’email’ portion to the script?

  7. Charles Says:

    I want to know how to trigger a bash or shell script from an alert.

    Is there a way?

    Thanks,
    Charles

  8. Prospectus Says:

    Not that I know of

  9. scripts, themes Says:

    scripts, themes…

    […]Thinkscript Tip: Alert Code Block for Think or Swim « Read the Prospectus[…]…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: