Questions tagged [thinkscript]

thinkScript® is a scripting language built into the thinkorswim securities trading application (often referred to as TOS). With thinkScript®, one can code custom studies, strategies, scans, columns, and more. DO use this tag for questions related to thinkScript® coding. DO NOT use this tag for questions related to securities trading or thinkorswim application usage. Those questions should go to the money or economics StackExchange communities.

Questions That Should Have This Tag

Questions related to thinkScript® coding should have this tag. This tag is not for thinkorswim application usage or securities trading questions. Those questions should be directed toward the money or economics StackExchange communities.

Introduction, Including Some Basic Definitions

thinkorswim (often referred to as TOS) is a professional market monitoring, trading, and learning application for securities, such as stocks, options, bonds, funds, etc.

thinkScript® is a coding language built into the TOS application for creating your own custom:

  • studies:
    indicators and plots to display on charts, such as moving average combinations, crossovers, candlestick patterns, etc

  • strategies:
    buy and sell scenarios to display on charts for backtesting purposes

  • scans:
    filters for finding stocks that meet specified criteria

  • columns:
    values to show for each item returned in scan results, such as specialized volume calculations, for example, or number of times a certain criterion was met, etc

  • and more
    see resources below for detailed information

Resources

56 questions
2
votes
2 answers

How do you step through thinkscript in ThinkOrSwim platform?

I am playing with ThinkScript code on ThinkOrSwim platform. Specifically running this tool on MacOSX. I am wondering if there is a way to debug ThinkScript like you attach a debugger and step through the script line by line.
videoguy
  • 1,732
  • 2
  • 24
  • 49
2
votes
1 answer

How to address a thinkScript IDataHolder array in a scan

Since variables cannot be modified, counters etc. are implemented by IDataHolder arrays where the counter gets the value from an addition of a value to the previous value which is then stored in the current position before advancing to the next…
user250343
  • 1,163
  • 1
  • 15
  • 24
1
vote
1 answer

ThinkScript to Python - iterative for loop, having trouble

I am trying to translate the following code from ThinkScript (TD Ameritrade code) to Python, and am having trouble getting it to output the right shape. ThinkScript: This code in TDA outputs a line bound by "lengtha", -10, 10. Using "fold", it…
thetadecay
  • 23
  • 3
1
vote
1 answer

VPN Indicator ThinkScript to Python

Taking a stab at converting a ThinkScript to Python for the first time, and I think my logic is right, but I am missing something as the two plots for the indicator don't match. Trying to convert the ThinkScript for the VPNIndicator to a Python…
wildcat89
  • 1,159
  • 16
  • 47
1
vote
0 answers

ThinkOrSwim function equivalent in MQL

I have never heard of ThinkOrSwrim till yesterday when someone asked me to convert a ThinkOrSwim script to an MQL4 indicator. A part of the code is as follows: input length = 21; input price = close; input ATRs=1; input trueRangeAverageType =…
1
vote
0 answers

Translating linreg() function from pinescript to thinkscript

I have seen numerous posts in this forum asking about this function in pinescript but so far none of them provide an answer to how the third parameter "offset" is used to modify the computation inside the function. Here is the description of that…
Pete Hahn
  • 21
  • 6
1
vote
1 answer

Thinkscript's GetValue() in PineScript

I cannot for the life of me figure out how to recreate this one line of Thinkscript in Pinescript. I have tried using valuewhen, highest, highestall, highestbars, and pivothigh, but none of them end up achieving the same results as tested in…
1
vote
1 answer

ThinkScript to PineScript Conversion Question

I am working on converting a ThinkScript indicator into PineScript. I am currently having problems with converting ThinkScript's barNumber() function to PineScript. I think I know what to use as its equivalent but I am not sure I understand the…
edgregor
  • 19
  • 5
1
vote
1 answer

All thinkscript Stock Fundamentals API returning NaN?

I'm working on a simple label overlay for thinkorswim's charting software using thinkscript. I'm noticing that all of the "Fundamental" API calls I make return NaN. Those "stock fundamental" API calls are documented here:…
1
vote
1 answer

Thinkscript Probabilty Statistics Study- Need help finishing

I'm trying to figure the probability that if a stock moves .05 up at the open, what are the chances it will move .50 up? Running into a few hiccups. This idea comes from a forex trader, "TheRumpledOne." He calls it the “Buyzone.” Check him out if…
1
vote
1 answer

How to create an Array (IDataHolder) in Thinkscript? (Thinkorswim)

I am trying to create an irregular volume scanner on Thinkorswim using Thinkscript. I want to create an array of volume's in past periods so that I can compare them to the current period's volume (using fold or recursion). However, while the…
1
vote
1 answer

Open and close of the first 1 min bar

I know it's a long shot to ask here, but I am looking for a way to determine if the first 1 minute candle is red, meaning that the bar closes below the open. To do this I simply need the open value and close value of the first one minute bar, but I…
ADSquared
  • 207
  • 3
  • 12
1
vote
2 answers

How can I output/print in thinkscript?

Pretty straight forward. I just want to print in thinkscript. If this question indicates that I'm missing a crucial element of thinkscript by asking this, please let me know that as well.
ScottyBlades
  • 12,189
  • 5
  • 77
  • 85
1
vote
3 answers

How to create a variable that retains its value

In thinkscript charts and scans, any script gets executed many times once for each bar. Program state between such executions is stored in array variables which are accessed directly or by an offset via [] or GetValue(). Many scripts involving some…
user250343
  • 1,163
  • 1
  • 15
  • 24
1
vote
2 answers

If statement in Thinkscript

I am a beginning thinkscript programmer and I am learning the syntax of thinkscript pretty fast. However, I am having trouble with the if statements. I understand you can have one statement inside of an if block but is it possible to have multiple…
Programmer MJM
  • 87
  • 1
  • 10
1
2 3 4