Possible to automate creating chart alerts?

dj45

Member
I have a spreadsheet of levels for different symbols. Is there a way to automate entering these levels on TOS charts either as alerts or as horizontal lines? I have some familiarity with Python, but less so with Thinkscript.
 
Solution
Last edited:
Solution
here is one way,
this study sets a few price levels for a couple of stocks
https://usethinkscript.com/threads/horizontal-lines-in-thinkorswim.3472/page-2#post-38179

take a look at other posts in the thread for other ideas
Thanks, this is great. I'm able to generate the thinkscript code for a bunch of symbols using python and my source spreadsheet. Then copy/paste the thinkscript code. Since I only have to do this weekly, the manual steps involved aren't a big deal.

I guess it's still not possible in thinkscript to add a label to the horizontal lines (meaning a label that is on the line itself, to the left side of the chart)?
 
Thanks, this is great. I'm able to generate the thinkscript code for a bunch of symbols using python and my source spreadsheet. Then copy/paste the thinkscript code. Since I only have to do this weekly, the manual steps involved aren't a big deal.

I guess it's still not possible in thinkscript to add a label to the horizontal lines (meaning a label that is on the line itself, to the left side of the chart)?
a label, no. labels only appear at the top of charts.

if you mean , place something on an axis, then no.

a bubble can be placed anywhere on the chart, to display almost anything.
 
a label, no. labels only appear at the top of charts.

if you mean , place something on an axis, then no.

a bubble can be placed anywhere on the chart, to display almost anything.
Yeah, a label on the line would be ideal. So I see the line, and the number on the right axis, and can look over to the left axis to see what this line represents. But sounds like that's still not possible in thinkscript. I'll just use the line formatting to differentiate these lines from other lines on the chart.
 
Thanks, this is great. I'm able to generate the thinkscript code for a bunch of symbols using python and my source spreadsheet. Then copy/paste the thinkscript code. Since I only have to do this weekly, the manual steps involved aren't a big deal.

I guess it's still not possible in thinkscript to add a label to the horizontal lines (meaning a label that is on the line itself, to the left side of the chart)?

i was making an outline on how to use excel formulas to generate thinkscript code text, that could be copied into tos...
but it sounds like you have that part figured out, with python. i would like to see the python code , or part of it.
i started reading about python, but have a long way to go.

a bubble can be placed anywhere on a chart. the problem is thinkscript doesn't know what parts of the chart are visible. if a bubble is placed at barnumber 10, near the left side of chart, at the close price - 2, it may not be visible, unless you manually scroll and zoom and pan.

here is a random post that has, horizontal lines, and bubbles with text, pointing to the lines.
https://usethinkscript.com/threads/zigzag-high-low-stats-for-thinkorswim.1073/page-7#post-96188
 
Last edited:
i was making an outline on how to use excel formulas to generate thinkscript code text, that could be copied into tos...
but it sounds like you have that part figured out, with python. i would like to see the python code , or part of it.
i started reading about python, but have a long way to go.
The spreadsheet that contains source data (symbols and levels to plot) is in Google Sheets, so that's where the python script is fetching from. There is a Sheets API; if you want more info on this, let me know.

I then manually copy the value of 'finalString' into the thinkscript, which just has the first couple of lines of the script you pointed me to (the 'plot' lines and 'nan' line) and then this pasted 'finalString'.

Code:
# fetch from spreadsheet
fetch = sheet.values().get(spreadsheetId=spreadsheet_ID, range =readRange).execute()
EMlist = fetch.get('values', [])

scriptText = 'if (GetSymbol() == "AAA") then {P1 = 69; P2 = 70;} ' # using unlikely to be used ticker to start scriptText before jumping into loop

for i in range(len(EMlist)):
    if EMlist[i]: # so we only deal with lists containing content, not empty lists
        addString = 'else if (GetSymbol() == "' + EMlist[i][0] + '") then {P1 = ' + EMlist[i][3] + '; P2 = ' + EMlist[i][4] + ';} '
        scriptText = scriptText + addString
      
endString = 'else {p1 = nan; p2 = nan;}'
finalString = scriptText + endString

As an aside, if you can write thinkscript, you can easily learn python. I find python fairly easy to understand, while thinkscript is borderline indecipherable to me! It's so different from typical programming languages, and since I'm not immersing myself in it, every time I look at it, it's like trying to read ancient hieroglyphics.
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
491 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top