Top Ten Wish-List for ThinkScript

Posted by in Uncategorized | 30 comments

1. Scriptable alerts – both the regular kind and audio alerts
2. Retrieve h/l/c data from a different aggregation period (i.e. Say I want to plot a 50 period moving average from a daily chart on my 5 minute intraday chart – Note that’s NOT the same as a 50×130=6500 period average on the 5 minute chart) See Guido’s post in the comments.
3. Change the paintbar color from thinkScript (I’m running out of combinations of dots, triangles, and squares!)
4. Label the study lines from thinkScript
5. Execute trades from thinkScript (oooo!)
6. Change strategy mode from thinkScript (e.g. from short_entry to long_exit)
7. Capture time and sales data
8. Vertical lines…please
9. Capture put/call ratio data
10. A way to directly plot lines on charts from thinkScript (e.g. plot(close[10], close) might draw a line from the close 10 bars ago to the current bar close)

If you agree then please send an email to ToS and ask for these features:


  1. Message sent!! 😛

  2. Email sent. Although, I am only interested in 1,4,7,8 I requested all of them.

  3. Done.

    1,5,6,9 would be helpful for me.

    On another note, I would LOVE for ToS to allow us to develop our own automated trading systems.

  4. rick f — I seriously couldn’t imagine anything better. I bet it would be extremely difficult for them to produce one, but one can wish. 😉

  5. Guys, i agree with all your suggestions, however, item #2, i.e. referencing other aggregation periods, is already available. That is how the Person Pivots are calculated and their code was released a couple of builds ago… in any case, there are some limitations to this as currently, you may only access DAY, WEEK or MONTH data inside a chart with a smaller time aggregation. Meaning, you can access MONTH data inside a MONTH, WEEK, DAY or intraday chart, you may access WEEK data only inside WEEK, DAY and intraday chart and you may access DAY data only inside a DAY and intraday charts. the way to plot the moving average which is requested as an example is:

    plot sma = average(close(period = “day”),50);

    This will plot a 50 day moving average inside any intraday chart. Do note that you cannot reference a secondary period inside a different function, for example:

    def close1 = close(period = “day”);

    plot sma = average(close1, 50);

    this will not work!

    • Guido,
      Thanks for the response on March 27. I tested
      plot sma = average(close(period = “day”),50);
      and it worked great.

      However when the aggregation component has more than 1 element, the higher time frame aggregation, which in this case is average, gives incorrect result.
      plot WA = average(high(period = “DAY”) – low(period = “DAY”), 50);
      would yield different result on the same day in a daily chart vs. in a 5-minute chart.

      BTW I am trying to draw daily ATR on an intra-day chart.

      Any ideas?

    • Hi Guido,
      I tried putting

      ## plot sma = average(close(period = “day”),50);

      into ToS build 1492 on Ameritrade. “Day” comes up as invalid.

      The other code that I tried that also didn’t work is

      ##input price = close;
      input length = 9;
      input displace = 0;

      plot AvgExp = ExpAverage(price[-displace], length);

      Could you help me get this straight and functional? I’m simply looking for the ability to put, say, a 20 day moving average on a 1 min chart.


  6. Guido,
    Thanks for stopping by and clearing that up. I think my attempts to get this to work used the syntax you’ve shown is non-funtional – though I fail to see how the language interpreter can see a difference between the two.

  7. Eric:

    input length = 5;

    plot sma = average(close(period = “day”),length);

    If it still doesn’t work, replace the ” marks with normal ones from within TOS. It gives a straight line across the chart like Person Pivots does. Could come in useful though.


  8. I too agree on this point. it would be phenomenal to have the ability to develop your own black box system. Unfortunately, this is something that will certainly take some time to develop as you correctly mention, Gar, it is extremely difficult to produce as a black box system is a rather large endeavor since it entails a multitude of trading aspects, i.e. cash management, risk management, position management, not to mention order type management. And, although this is already in the works, i don’t presume that it will be available at least for another 6 – 9 months.

  9. Along the lines of alerts and paint colors, I sent a request today to TOS that they allow for setting of the entire background color of the chart. I usually set mine to a light grey for nice contrast of red and green candles, but if a very specific alert condition is met, in some cases it might be nice to actually change the background color to really alert me. In my case I keep a screen of 28 charts up and have to look for these patterns visually right now. Even having dots appear in such a case would not be as fast as being able to change the whole background color….

  10. I noticed the new release has different audio alerts possible, wonder if they might have given us item 1 on the list as well? Unlikely, but one can only hope…

  11. Simple request – difficult time finding a solution.

    I have a strategy that plots a line like any other

    if the line is crossed on the close of a bar it is considered a crossover

    the formula works fine on other platforms however I am stuck on thinkscript

    The issue is simple yet I am having trouble finding a solution:

    Stage 1 – be Long
    Stage 2 – use highest close since last crossover to caclulate formula to find 1st short – and to find subsequent longs and shorts

    The formula to plot the line it references the highest close since the last crossover of the line (if giving a long signal) and the lowest close since the last crossover of the line (if giving a short signal)

    if i try to use highest(close, xxx) function it will not let me use rec variable or reference a formula it will only allow for a constant for xxx i..e highest(close, 20) for highest close in last 20 bars) versus I may need highest close in 1 bar, 20 bars or 400 bars depending on how long it has been since a crossover

    I even tried programming if/then statements to resolve the constant issue – and it worked for about 40 bars or so but then the script became so larger it would not allow it – so as long as the crossover happens within 40 bars you are good but it not then the indicator messes up

    so i really need to figure out how to reference the highest/lowest close since the last bar close crossover of the plotted line
    any help would be greatly appreciated!

    • You may want to post over in the forum as more people are likely to see it there.

  12. I am stuck can anyone help me figure this out:

    I am trying to simply find a way to reference the highest/lowest close since a crossover

    the basic highest(close, xxx) or lowest(close, xxx) function in think script requires xxx to be a constant but I need it to be a variable


    a 50 day moving average

    if a bar has been above the 50 day moving average for 10, 40, 100, 349 etc… days and then closes below the 50 day ma

    then i need to be able to reference the highest close since it last crossed over from below to above the 50 day ma

    likewise after it has crossed below it – i need to be able to reference the lowest close since it crossed below the 50 day ma
    and going forward be able to do this (reference highest when closes above 50 day ma and reference lowest when closes below 50 day ma)

    i need this in order to be able to calculate my formula

    Step 1: start long
    start 6 bars in
    average of high-low for last 5 days x 1.5 = volmultiplier
    since long – subtract volmultiplier from highest close since beginning of chart
    plot this line on every close
    Step 2 IF price closes below plotted line then add volmultiplier to lowest close since crossover
    if price closes above plotted line then subtract volmultiplier to highest close since crossover
    Step 3 repeat step 2 infinitely

    I am running this on other platforms with no issues but am trying to get all my formulas over to TOS

    • No one can make money long term trading a MA, or even two. See Colby, “Technical Market Indicators.”

  13. plot sma = average(close(period = “day”),50);
    gives me an “Invalid Plot” error.
    Am I doing something wrong with this one line of code or was #2 on the wish list crossed of because it’s never going to happen?

    • I haven’t looked at this in a while. Perhaps some implementation details have changed making the previous syntax incorrect? It was working when this was originally written.

  14. I fooled around with this and took lead from PersonsPivots.
    This does not give me an error, but it does not plot anything either.
    Has anyone else done something with this concept?
    What am I missing?

    input t1=” DAY”;
    input t2=”2 DAYS”;
    input t3=”3 DAYS”;
    input t4=”4 DAYS”;

    Plot PP1 = average(close(period = t1));
    Plot PP2 = average(close(period = t2));
    Plot PP3 = average(close(period = t3));
    Plot PP4 = average(close(period = t4));

    • I think there was a problem with TOS and my computer. It told me there was a connection error so I re-booted and now I’m getting different results.

  15. This seems off-topic in light of the most recent comments, but….

    Are you familiar with the Bressert Double Smoothed Stochastic?

    You can see what it looks like on metatrader here:


    Can this be coded in thinkscript?

  16. This seems off-topic in light of the most recent comments, but…

    Are you familiar with the Bressert double smoothed stochastic?

    You can see what it looks like on metatrader here:
    Can this be coded in thinkscript?

  17. This subject drives me crazy. A person may trade equities and such off a daily chart, but TOS forces you to use your eyes for everything. I trade futures and FX, I want to see those guys trade those off a daily chart, what a joke. I WANT TO BE ABLE to do INTRADAY charts. Ticks, 5 min, 15 minute. Something as simple as making sure an indicator on a 1 minute chart, and 5 minute chart both agree !!! Not hard if I had access to their source. Instead I have to have up like 3 charts and use my eyes to make sure they all agree. Ridiculous.

  18. I have been attempting to program in Thinkscript. I have programmed in a substantial number of computer languages in my lifetime, including many assembly languages. I find Thinkscript very difficult to use. It is like trying to build a city out of Leggo blocks. The lack of true functions makes programming frustrating. There are no true arrays. One can only subscript data points by constants, not variables or expressions. However, I see no better alternative for me, so I will struggle on.

  19. Curious about STUDY ALERTS. I’ve been successfully creating study alerts (based on various technical conditions) for a while now. But they’ve only been for a single symbol at a time. It seems that TOS restricts the application of study alerts to single symbols. Am I correct in this observation?

    I hope I’m wrong because I’d like to create a study alert that can be applied to a watchlist and then send me an email that contains all the matching symbols. Is this possible on the TOS platform (preset feature or via thinkscripting)?

    Thanks so much for any insight or guidance on this.

    • Email alerts can only come from the alert functionality if the Alerts tab not from thinkScript or a column or watchlist.

      • Awww, man! I was afraid of that. Nevertheless, thanks a lot, ThinkScripter, for your quick, clear and candid reply. Now I know to stop wasting my searching for gold in a “silver” mine. LOL.

        Thanks again.

  20. Hi, and it’s great to be here! I agree in that the language should not have this limitation as it is quite useful to first define functions first and then simply reference the name of the pre-defined function inside other equations. Hopefully this limitation can be overcome in the near future…

  21. Thanks Guido.

    Folks, in case you didn’t know, Guido is one of the fine folks at ThinkOrSwim.

    We really appreciate his feedback here.

  22. Based on the volume of emails I get requesting this functionality and strategies, there is a high demand. However, I also feel there are a lot of people who think they are going to code up something or borrow someone else’s something and then just watch their account grow bigger every day.

    Ain’t gonna happen folks….more likely, your account will go to zero (quickly) and ToS will watch their revenue from commissions go through the roof.

    Just my two cents.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>