Can I get a value from alert or drawing?

Matz371

New member
Hello! May I ask a question that, how can I get a value from an alert or a drawing such as a price level, and it into a script? Thank you!

I would like to use the value as a reference number in other studies.

Otherwise, can I input or refer to a different value for a different individual stock?

Thank you very much for your help!
 

Attachments

  • IMG_9654.jpeg
    IMG_9654.jpeg
    192.5 KB · Views: 132
  • IMG_9653.jpeg
    IMG_9653.jpeg
    153 KB · Views: 121
Solution
Otherwise, can I input or refer to a different value for a different individual stock?

are you wanting to draw horizontal lines at some price level?

you can have a study ask for number(s).
you can have a study ask for number(s) that are associated with a specific symbol. then when that symbol is viewed on the chart, those line(s) will be drawn.

go to the edit studies and change the parameters of this study to 3 stocks that you look at and enter 2 prices for each stock.
it will draw 2 lines on 3 different charts.


Code:
def na = double.NaN;

input symbol1 = "SPY";
input sym1_level1 = 0;
input sym1_level2 = 0;
input symbol2 = "SPY";
input sym2_level1 = 0;
input sym2_level2 = 0;
input symbol3 = "SPY";
input sym3_level1 = 0...
@Matz371

The TOS platform does not have the ability to interact w/ lines and other graphics created w/ the drawing tools.
This means that you can not "get a value from an alert or a drawing such as a price level into a script"
 

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

@Matz371, you did a great job posting your question. It was clear and had easy to understand pictures to go along with it. Some questions on the forum are extremely difficult, if not impossible to understand.

Regarding @MerryDay's comment, even in other platforms like NinjaTrader it's extremely difficult to get these kinds of values. You have to loop through all of them (using the C# language) and then determine what to do with it. It's no surprise ThinkScript (a scripting language, not a programming language) doesn't have this ability. That said, don't feel too bad about it given how complex this is even in much more complex applications like NinjaTrader.
 
Otherwise, can I input or refer to a different value for a different individual stock?

are you wanting to draw horizontal lines at some price level?

you can have a study ask for number(s).
you can have a study ask for number(s) that are associated with a specific symbol. then when that symbol is viewed on the chart, those line(s) will be drawn.

go to the edit studies and change the parameters of this study to 3 stocks that you look at and enter 2 prices for each stock.
it will draw 2 lines on 3 different charts.


Code:
def na = double.NaN;

input symbol1 = "SPY";
input sym1_level1 = 0;
input sym1_level2 = 0;
input symbol2 = "SPY";
input sym2_level1 = 0;
input sym2_level2 = 0;
input symbol3 = "SPY";
input sym3_level1 = 0;
input sym3_level2 = 0;

plot z1;
plot z2;
if (GetSymbol() == symbol1) then { 
z1 = sym1_level1;
z2 = sym1_level2;
 } else if (GetSymbol() == symbol2) then { 
z1 = sym2_level1;
z2 = sym2_level2;
 } else if (GetSymbol() == symbol3) then { 
z1 = sym3_level1;
z2 = sym3_level2;
} else {
z1 = na;
z2 = na;
}
#


ref
https://usethinkscript.com/threads/horizontal-lines-in-thinkorswim.3472/page-2#post-38179
 
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
264 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