plot a "price level line"

CW1

New member
Hello, I'm new to the forum and I'm not sure if this is a good place to post this but here goes.
I'm would like to automatically plot a "price level line" (just as if I used the price level tool) on the open of a new bar. The price level line needs to extend to the right only from the bar it plots on. This would be the first step of my project. Thanks
 
Hello, I'm new to the forum and I'm not sure if this is a good place to post this but here goes.
I'm would like to automatically plot a "price level line" (just as if I used the price level tool) on the open of a new bar. The price level line needs to extend to the right only from the bar it plots on. This would be the first step of my project. Thanks

hello and welcome.
yes, you found the questions section, the right spot for questions.

this will plot a line from a price level of 1 bar, and extend to the right.
. can pick how many bars back. 0 = current bar
. can chose price type. default is open

the x formula, looks at future bars, to find the last bar with a price and the bar after it that doesn't have a price.
the line formula saves the price value and keeps it till the right edge of the screen (through the expansion area)

Code:
#barx_openline

def na = double.nan;
def bn = barnumber();

input bars_back = 0;
def x = (!isnan(close[-bars_back]) and isnan(close[-(1+bars_back)]));
input price = open;

def line = if bn == 1 then na
 else if x then price
 else if isnan(close) then line[1]
 else line[1];
plot z = line;

input test_vert = no;
addverticalline(test_vert and x, "-");
#
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
276 Online
Create Post

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