Tuesday, June 17, 2014

How to Make a Simple Indicator in ThinkorSwim

This is a simple buy arrow indicator program to help teach a few basic concepts on how to make indicators for the ThinkorSwim platform. Our indicator will place an arrow on the chart when the simple moving average crosses above a weighted moving average. We will be able to adjust the length of the moving averages to test different parameters but we will set it up with 5 and 9 as our default values. Lets get started! The first things you need to do is start-up your ThinkorSwim platform and open the chart tab. Now click the Edit Studies button at the top of the chart.







The Studies window will open. Now click the New... button at the bottom left corner of the window. This will open the space we need to write our program.











At the top is a Studies Name box type in a name for your study I used SMA_X_WMA . There is default code in the window "Plot Data = Close;" you need to delete this code and write our code in its place.
The first line is # SMA_X_WMA this is a comment and is not used by the computer it is only there to help the programmer or people trying to understand the code.
The next two lines provide input to the program. This allows the user to make changes to the length of the moving averages. Type:

input SMA_Length  = 5;
input WMA_Length = 9;
These two line define variables SMA_Length and WMA_Length and assign a default value for each. Note do not forget the ; at the end and I used the _ since spaces are not allowed in variable names.
Next we Define two more variables avg and wavg Type:

Def avg = Average(Close, SMA_length);
Def wavg = wma(close, WMA_length); 
The first line defines the simple moving average of the close for the length provided by the SMA_Length variable. and the second line defines the weighted moving average of the close over the length provided by the WMA_Length variable.
Now we need to plot our arrows on the chart. We do this by Typing:

plot crossing = avg > wavg and avg[1] <= wavg[1];
This code provides the logic used for our indicator it is saying if the simple moving average crosses above the weighted moving average and that it was previously below then it will draw crossing on the chart. The last bit of code will define what gets plotted on the chart. Type:

crossing.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

Now you can Click the OK button the lower right of the window this takes us back to the Studies window.
















Now you can select any changes to the parameters that you want to change. Next click Apply and then OK to see your indicator on the chart.

This is Not Trading Advice only information on how to make a simple indicator.

3 comments:

  1. There is no need to get daily updates of Forex market, If you are working on the DecisionBar Trading Software because it is designed to provide you the accurate signals about Trading!

    Day Trading Software

    ReplyDelete
  2. This time period is often as short as 15 minutes or so long as a whole day time. Binary Trading Options At the end of times period, an investor will receive a contact stating the current price from the options in query.

    ReplyDelete