limits on script command


Category:
0
0

Is there a way to get a script i.e. “script foo {}” to actually plot or change the values of a plot? Is there better documentation than the tos site?

Marked as spam
Posted by (Questions: 3, Answers: 5)
Asked on July 22, 2017 5:13 pm
733 views
0

I need a bit more clarification. Are you talking about this: http://toslc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/script.html

( at July 22, 2017 6:51 pm)
0

that’s it. the example doesn’t show much. I want to pass a plot in to modify parameters or have it directly plot an output to the chart or return a plot that it created so i can plot the returned plot.

barring that, other than knowing how to use the command, i want to keep from duplicating code for n-different plots that only differ in name, color and value. -thanks Stephen

( at July 22, 2017 7:34 pm)
0
Private answer

Ok, then yes. The script statement in Thinkorswim is very much like a function or a procedure, as they are called in other languages. And it is designed to facilitate reusable bits of code to reduce meaningless repetitions in your code. To ‘clean things up’, so to speak.

Let me say here that for the average user of Thinkorswim this is an extremely advanced topic. So if your head starts to spin while reading this post, please don’t let it worry you. For computer programers, this is a very basic topic. One that is commonly used to streamline code and make it more readable.

I’m not sure of your background. But I can probably come up with some more helpful analogies to explain things further. Or direct you to some other resources to increase your understanding of how these things are used.

In basic terms, you have one or more inputs that are defined at the beginning. Then the code within the script statement performs calculations on the data from those inputs, while also having access to any variables previously declared. The final line of code within the script statement is the output value.

This is very much like a common function in an Excel spreadsheet…. Data in, data out.

Once the script has been created, you can call to it multiple times, passing different parameters as inputs each time. There happens to be a bug in this feature of Thinkscript. I ran across it while trying to reduce lines of code in my multiple timeframe studies. I submitted my findings to Thinkscript support and they confirmed it does not behave correctly if you are using it in more than one higher time.

Hope this helps. Please feel free to provide more details and I will do what I can to increase your understanding.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on July 22, 2017 9:38 pm
0

I’ll work on it more and see what I can do.

My experience is 2 months in tos script 25 years programming

( at July 23, 2017 3:56 am)
0

Stephen: TOS has updated their tutorials and a Thinkscript user ”manual”/snippet exists. However, I am new to this forum and do not want to alienate Mr.Hahn’s terms of use. (I appreciate Mr. Hahn’s work).

( at July 23, 2017 8:08 am)
0

By all means Tom, if you want to link to material provided by TD Ameritrade that is not only acceptable but highly encouraged. Thanks for your concern to comply with our terms of use.

Stephen,
25 years of programming, wonderful. Please let me know some of the languages and I’ll provide you some examples or descriptions to help you connect the dots. Thinkscript is very much like JavaScript. It is an interpreted language. They may have compiled the built in functions but everything we have access to is just like JavaScript. The Script{} statement is the closest thing we have to a function and Fold is the only thing we have for looping. Extremely limited language compared to other platforms. But very simple to work with.

( at July 23, 2017 8:28 am)