Draw Price Levels

tscript

New member
Plus
Draw Price Levels

I am looking to draw price levels for the daily charts when the price is the same for any opens, highs, lows, & closes. This is what I have in mind, or if something like this can be coded.
  • For the daily charts. 1 month to 3 years.
  • If the price is the same for any correlating opens, highs, lows, & closes, draw a price level connecting those candlesticks on the daily chart.
  • Be able to adjust the color, style, width, ect of the price lines.
  • Be able to adjust a price range surrounding the current price to display the price levels.
Example:​
  • If the current price of a stock is $A and
  • The price range is set to $B.
  • Display the price levels ($C) around the current price ($A) +/- the price range ($B) on the daily chart.
Of course the current price ($A) will change depending on the stock symbol chart looking at, the price range ($B) will remain the same.​
  • Be able to set only the top X# of price levels to be drawn with the most correlating opens, highs, lows, & closes within the price range ($B).
 
Last edited:
please edit your post,
remove 'price' and use open,high,low,close
what has to be the same? todays open to a past open? or todays close compared to any past open,high,low,close? i don't know what you want to compare.
get rid of letters to represent prices. its confusing. just use numbers.
if B is a range, then the levels would be at +B/2 and -B/2 from current ... close?
why use a range, if you want to find when an old price and current price are equal?

take a screen shot with windows snipping tool and edit it to show what you want.
 
here is something to experiment with. maybe its close to what you want.

pick how many bars back to compare. 100
compare 100 old close prices to the current close.
the first time that the difference of the 2 prices are < diff (0.03) then draw a line.
once a match is found, it stops looking for other matches


Code:
#compare_old_prices

#https://usethinkscript.com/threads/draw-price-levels.22242/
#Draw Price Levels

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

def lastbn = HighestAll(If(IsNaN(close), 0, bn));
def lastbar = if (bn == lastbn) then 1 else 0;

#def lastbar = !isnan(close[0]) and isnan(close[-1]);
def last_close = highestall(if lastbar then close else 0);



#define a range of bars
input bars_back = 100;
def bars = (!isnan(close) and isnan(close[-bars_back]));
# addverticalline(bars);

def first = bars and !bars[1];
addverticalline(first, "-", color.cyan);


input diff = 0.03;

# compare the past 100 old close to current close
# the first one that is a close match, will generate a line
# after the first match, it wont look for any other matches
def old_price = if !bars then 0
 else if old_price[1] > 0 then old_price[1]
 else if bars and (absvalue(close - last_close) <= diff) then close
 else old_price[1];



plot z1 = if old_price == 0 then na else old_price;


addlabel(1, "old price $" + round(old_price,2) , color.cyan);
addlabel(1, "price diff $" + diff , color.cyan);
addlabel(1, "last cls " + last_close, color.cyan);


addchartbubble(0, low*0.996,
 old_price + "\n" +
 last_close + "\n" +
 diff
, color.cyan, no);

#
 

Attachments

  • 01a.png
    01a.png
    197.2 KB · Views: 6

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