ThinkScript Tutorial: Make a Full-Featured Indicator in Thinkorswim, Start to Finish!
Education
Introduction
In this tutorial, we will walk you through step-by-step on how to create your first indicator in Thinkorswim using the ThinkScript language. We will be creating a range indicator to show the range of each bar on the chart and compare volatility levels. Additionally, we will calculate the average range, create color schemes, and set up an alert system. By the end of this tutorial, you will have a fully functional and customizable indicator that you can integrate into your trading system.
Step-by-Step Guide
- Start by opening the "Edit Studies and Strategies" window and create a new blank study.
- Name the study and add a few "a"s to the beginning of the name to place it at the top of the studies list.
- Add a plot that displays the closing price of each bar on the chart.
- Edit the study's sources and define a variable called "range" to store the range of each bar (high minus low).
- Use the "input" keyword to allow the user to customize the high and low prices used in the range calculation.
- Replace the plot of the closing price with a plot of the range variable.
- Add more complexity to the range calculation if desired, such as using the absolute value of the open and close prices.
- Create an average variable using the "moving average" function and allow the user to customize the average type, length, and offset.
- Connect the user-defined settings to the moving average calculation.
- Replace the original plot of the range variable with a plot of the average variable.
- Adjust the plot styles, colors, and thickness for both the range and average plots.
- Add color-coding to the range plot based on whether it is above or below the average.
- Allow the user to customize the colors for the range plot.
- Create special colors for the average plot based on whether it is rising or falling.
- Allow the user to customize the high and low range colors, as well as the rising and falling average colors.
- Add an alert that triggers when the range is above a user-defined threshold (e.g. two times the average).
- Allow the user to customize the alert threshold.
- Display the current range value in a label on the chart.
- Allow the user to customize the color of the label.
- Add hints to the script and inputs to provide guidance and clarification for users.
- Test the indicator and make any necessary adjustments.
- Save the indicator and use it in your trading system.
Keyword: ThinkScript, Thinkorswim, Indicator, Range, Volatility, Average, Color Scheme, Alert System, Customization, Scripting Language
FAQ:
- Can I customize the threshold for the range alert? Yes, you can customize the threshold for the range alert using the "alert average multiple" input. This allows you to specify how much above the average the range must be to trigger the alert.
- Can I change the colors of the range and average plots? Yes, you can change the colors of the range and average plots by customizing the "range" and "average" plot styles and using the "range color" and "average color" inputs to define specific colors.
- Can I use other types of moving averages for the average calculation? Yes, you can use other types of moving averages by modifying the "average type" input. Thinkorswim provides a variety of moving average types to choose from, such as simple moving average, exponential moving average, weighted moving average, etc.