Draw a lines between two points

Solution
Please help to create code to draw a lines between Highest(high,60) and Lowest(low,60).

hello, and welcome,

please elaborate,
'a lines' ? more than one?
horizontal lines , at some price interval, 'between' the high and low?
vertical lines 'between' the high and low?
a diagonal line, from the highest to the lowest ?
Please help to create code to draw a lines between Highest(high,60) and Lowest(low,60).

hello, and welcome,

please elaborate,
'a lines' ? more than one?
horizontal lines , at some price interval, 'between' the high and low?
vertical lines 'between' the high and low?
a diagonal line, from the highest to the lowest ?
 
Last edited:
Solution
Please help to create code to draw a lines between Highest(high,60) and Lowest(low,60).

i guessed that you want a diagonal line,
so i threw this together,

specify some quantity of bars, before the last bar,
find the highest and lowest, in that range of bars,
draw a diagonal line between the highest and lowest,
draw a vertical line at the beginning of the range

works no matter which price is before the other ( will draw a rising line or a falling line)
( picture is with a length of 33)

Code:
#diag_line_hilox

#https://usethinkscript.com/threads/draw-a-lines-between-two-points.20658/
#Draw a lines between two points , highest(high,60) and Lowest(low,60).

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

input len = 60;
# find bar x bars before last bar
def x = (!isnan(close[-(len-1)]) and isnan(close[-(len)]));
def n = 300;

# on the x bar before last bar, find the highest and lowest
#  calc slope of diag line between highest and lowest
def hi;
def lo;
def hibn;
def lobn;
def barz;
def slope;
def first_pr;
if bn == 1 then {
 hi = 0;
 lo = 0;
 hibn = 0;
 lobn = 0;
 barz = 0;
 slope = 0;
 first_pr = 0;
} else if x then {
 hi = highest(high[-(len-1)],len);
 lo = lowest(low[-(len-1)],len);

 hibn = bn + (fold a = 0 to n
  with b
  while (getvalue(high,-a) != hi)
  do b + 1);

 lobn = bn + (fold c = 0 to n
  with d
  while (getvalue(low,-c) != lo)
  do d + 1);

 barz = (hibn - lobn) + 0;
 slope = (hi-lo)/barz;
 first_pr = if hibn < lobn then hi else lo;

} else {
 hi = hi[1];
 lo = lo[1];
 hibn = hibn[1];
 lobn = lobn[1];
 slope = slope[1];
 barz = barz[1];
 first_pr = first_pr[1];
}


def maxx = max(hibn,lobn);
def minx = min(hibn,lobn);

# need to calc price at first hi/lo

def t = if bn < minx then 0
 else if bn == minx then first_pr
 else if bn > minx and bn <= maxx then t[1] + slope
 else 0;

plot z = if t > 0 then t else na;
z.SetDefaultColor(Color.cyan);
z.setlineweight(2);
z.hidebubble();
#z.SetStyle(Curve.MEDIUM_DASH);


input test_vline = yes;
addverticalline(test_vline and x,"-");

input test_bubble = no;
addchartbubble(test_bubble , low*0.995,
bn + "\n" +
high + "\n" +
hi + " hi\n" +
hibn + " hbn\n" +
low + "\n" +
lo + " lo\n" +
lobn + " lbn\n" +
barz + " b\n" +
slope
, color.yellow, no);
#
 

Attachments

  • img1.JPG
    img1.JPG
    49.8 KB · Views: 50

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