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 use 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.
Thank you for this info! How can I contact you to ask a question?
ReplyDeletethank you very much kenp
ReplyDeleteHi Filando, can you please email me at danwg78@gmail.com so I can ask you a quick question?
ReplyDeleteHey Filando! Do you do any ToS custom indicator programming? I have one that needs to be tweaked. If you are interested please drop me a line at kibicricket@comcast.net
ReplyDeleteHow to setup Sell indicator?
ReplyDeleteHi Dnitrij, you do it by defining you sell criteria
ReplyDeleteplot crossingDwn = avg < wavg and avg[1] >= wavg[1];
and defining how to plot it
crossingDwn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Thank You, maybe you know how to make sound alert, when I got arrow down or up?
ReplyDeleteHello, I am looking for someone to help me program a thinkorswim indicator. It's a compliation of several existing indicators, but I am not good at this type of thing and would appreciate help. Can you please contact me at autismiscuralbe@gmail.com thank you
ReplyDelete