Close crosses user drawn Level or Trendline

Willhehunt

New member
Trying to be able to step away from screen and receive SMS alerts when condition is met in Study.

Envision indicator that alerts when Price Closes thru a drawn level or trend-line and indicates which direction it closed. Inputs for 3 price levels and two trend lines where you can list level or trend.

Any help would be appreciated. I am a terrible script writer but can modify existing scripts it they somewhat match what I am trying to do.

Thanks, Bill
 
In your case, the easiest method is to use the default drawing tool in TOS.

Here is an example:

Select the Price Level drawing tool.

oZCIqPR.png


Draw your levels.

yi7Pi6S.png


Right-click on each level and select Creat alert...

0BJidYe.png


Customize your alert (there are many settings including SMS, in-app notification, etc).

wuD75Jg.png
 
And just to be sure it's stated, this is not possible with trendlines, only price levels. Since trendlines can appear to exist at different prices depending on the type and timeframe of a chart, it's not possible for TOS to do the math (easily) and determine when it has broken a trendline. As a result, it just isn't possible.
 
In your case, the easiest method is to use the default drawing tool in TOS.

Here is an example:

Select the Price Level drawing tool.

oZCIqPR.png


Draw your levels.

yi7Pi6S.png


Right-click on each level and select Creat alert...

0BJidYe.png


Customize your alert (there are many settings including SMS, in-app notification, etc).

wuD75Jg.png
Ben, I do that now was just wondering if it could be programmed. I guess the biggest need is when price crosses drawn trendline. I let my trades run, and use a trendline to determine if I should close position and it would be nice if i would get SMS when it happens to not have to be glued to screen. Thanks for your reply.
 
Ben, I do that now was just wondering if it could be programmed. I guess the biggest need is when price crosses drawn trendline. I let my trades run, and use a trendline to determine if I should close position and it would be nice if i would get SMS when it happens to not have to be glued to screen. Thanks for your reply.

No, Thinkscript does not allow for interactions with drawn objects. In fact, even in NinjaTrader it's very difficult as you have to loop through each drawing object and perform complex calculations.

I've had the same thought in the past, but it just isn't possible in TOS.
 
Ben, I do that now was just wondering if it could be programmed. I guess the biggest need is when price crosses drawn trendline. I let my trades run, and use a trendline to determine if I should close position and it would be nice if i would get SMS when it happens to not have to be glued to screen. Thanks for your reply.

a diagonal line could be programmed, just need to specify 2 points.
each point needs,
date and time , and a dollar amount.
 
Last edited:
a line could be programmed, just need to specify 2 points.
each point needs,
date and time , and a dollar amount.
The day would always be the same and i could draw the line then pick up times that intersect. Do you know of any code that defines a line that could be intersected and allow for a trigger?
 
The day would always be the same and i could draw the line then pick up times that intersect. Do you know of any code that defines a line that could be intersected and allow for a trigger?
any plotted line can be checked if it crosses another plotted line.

pretty sure i have something to draw a line.... found 1..
https://usethinkscript.com/threads/how-to-plot-a-line-between-2-points.6945/#post-67309

i think there are several studies from sleepyz to draw a line during a day.... can't remember the specifics.

i admit i am not familiar with what kind of notifications will occur from the alert() function.
 
Last edited:
Thanks so much. I looks exactly like what i was describing.. Loaded it this morning and filled in all the inputs but didn't notice any arrows or alert when two close crosses occured. Not sure why. I see the inputs at top of screen and turned on test lines for the inputs and they showed exactly where they should.
One thing i didn't list is this is a 28t Range chart. Not sure that matters.
 
One thing i didn't list is this is a 28t Range chart. Not sure that matters.

evidently it does. sorry, not sure if it can be fixed for non time charts.
i only use time charts, so don't think about the other types.
i changed my chart to tick and it doesn't draw a line. there was an error in top left, that listed a a couple of error messages. you probably have something similar, that might give you a clue.
 
evidently it does. sorry, not sure if it can be fixed for non time charts.
i only use time charts, so don't think about the other types.
i changed my chart to tick and it doesn't draw a line. there was an error in top left, that listed a a couple of error messages. you probably have something similar, that might give you a clue.

Although I don't see a line drawn. But if it will produce alert and arrows that would be great

UPDATE:
No it didn't fire on the 7 min either. Does have a message in left corner "Unable to hide base sub graph, At least one subgraph should be visible."

I noticed a reference to Mobius. Did he help write this? If so, I could reach out to him and see if he has any ideas. Hate to keep bothering you. Not sure what is screen name would be.

I am kind of stumped why this wouldn't completely run on 7 minute chart. Without a debugger I have no idea how to find problem. Here is a screen shot that shows the inputs, the test lines and you can see zpr1 and zpr2 have values. But it doesn't draw line or alert cross. Any ideas how I can find the culprit. Thanks in advance.
 

Attachments

  • Bar Cross Data.pdf
    93.3 KB · Views: 176
Last edited by a moderator:
Although I don't see a line drawn. But if it will produce alert and arrows that would be great

UPDATE:
No it didn't fire on the 7 min either. Does have a message in left corner "Unable to hide base sub graph, At least one subgraph should be visible."

I noticed a reference to Mobius. Did he help write this? If so, I could reach out to him and see if he has any ideas. Hate to keep bothering you. Not sure what is screen name would be.

I am kind of stumped why this wouldn't completely run on 7 minute chart. Without a debugger I have no idea how to find problem. Here is a screen shot that shows the inputs, the test lines and you can see zpr1 and zpr2 have values. But it doesn't draw line or alert cross. Any ideas how I can find the culprit. Thanks in advance.

i don't use range charts, so not sure if my study will work on that type of chart. i can try to do some experiments tonight.


how did you make a 7 minute chart?


mobius created the 3 code lines that calc year, month, day. i made the rest, so he would not be aware of my study. no idea if he monitors this group.


this group is for helping people with thinkscript. maybe someone will be able to help, if the question is phrased correctly?


'what is it about my study , in post10, that doesn't work on range charts?
https://usethinkscript.com/threads/close-crosses-user-drawn-level-or-trendline.15475/#post-125347


debugging,
look at the end of my study. there is a bubble function, that can display some values. that is how you debug ( and with addlabel).
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddChartBubble


this is a post on how to post a LINK to an image.
https://usethinkscript.com/threads/how-to-insert-image-in-a-post-thread.277/page-3#post-98334
 
I will keep testing but can't find anything definitive that is breaking the code. However, it is more of a visual. So I created this little script that will sound and draw arrow on bar reversal. Very useful for runners on a Range cart. Now if I could just figure out the api to have SMS or push alerts to iphone from the alert triggering. I tried the MarketWatcht but very inconsistent when it will fire msg. The way i create a 7 min bar for the instrument is create 7 min timeframe.

# Willhehunt
# Signal each time Bar Changes Direction

def upbarlow = low;
def upbarclose = close;
def downbarhigh = high;
def downbarclose = close;
def TrueRange1 = TrueRange (high, close, low);
def TrueRange2 = TrueRange (high, close, low);

plot UpSignal = upbarclose > upbarlow and downbarhigh [1]> downbarclose [1] and TrueRange1 > 6.99;
plot DownSignal = downbarclose < downbarhigh and upbarlow [1]< upbarclose [1] and TrueRange1 > 6.99;


#AvgExp.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

# Alerts
Alert(UpSignal, "Reversal Bar UP", Alert.Bar, Sound.Chimes);
Alert(DownSignal, "Reversal Bar Down", Alert.Bar, Sound.Bell);
 

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
441 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