I have been drawing what I call the Prime Lines for years now and find them better than highs/lows and support/resistance, although they do line up with those other indicators at times.
Could someone create an indicator that draws vertical lines that extend to the right when there are 4 or more candle highs and or lows that meet up at any common price point with an adjustable tolerance of 0.03. Also an adjustable look-back period starting at 100.
I have attached a drawing for further explanation.
Thank you Cheeter
I have been drawing what I call the Prime Lines for years now and find them better than highs/lows and support/resistance, although they do line up with those other indicators at times.
Could someone create an indicator that draws vertical lines that extend to the right when there are 4 or more candle highs and or lows that meet up at any common price point with an adjustable tolerance of 0.03. Also an adjustable look-back period starting at 100.
I have attached a drawing for further explanation.
Thank you Cheeter
in order to draw many lines, there would need to be many plot code lines, AND MANY supporting code lines.
most of this study would have to be copied and modified, just to add 2 more lines...
I have been drawing what I call the Prime Lines for years now and find them better than highs/lows and support/resistance, although they do line up with those other indicators at times.
Could someone create an indicator that draws vertical lines that extend to the right when there are 4 or more candle highs and or lows that meet up at any common price point with an adjustable tolerance of 0.03. Also an adjustable look-back period starting at 100.
I have attached a drawing for further explanation.
Thank you Cheeter
in order to draw many lines, there would need to be many plot code lines, AND MANY supporting code lines.
most of this study would have to be copied and modified, just to add 2 more lines.
-------------------
this plots 2 lines,
..from a high with the most interactions
..from a low with the most interactions
....interaction , a price on another bar is within the tolerance of current high or low.
pick how many bars to look at, at the end of the chart (default is 100)
pick a tolerance price number (default is 0.03)
pick a minimum quantity that the counts need to be greater than to be considered (default is 4)
looks at the last x bars on a chart,
..on each bar, it makes 2 comparisons (for 2 lines). 1 from the high and 1 from the low.
..it looks at all the bars after the current bar and,
....counts how many highs and lows are within the tolerance of the high
....counts how many highs and lows are within the tolerance of the low
draws 2 horizontal lines,
..finds the highest count from a high and plots a line
..finds the highest count from a low and plots a line
2 small arrows are drawn,
..green above the bar with the high with most interactions
..red below the bar with the low with most interactions
4 labels are displayed
..2 with quantity of bars with more than the minimum interactions, from a high or low
..2 with the max interactions from a high, and max from a low
Code:
# prime_lines_same_price
# https://usethinkscript.com/threads/prime-lines.16659/
#draws horz lines that extend to the right
#when there are 4 or more candle highs and or lows
#that meet up at any common price point
#with an adjustable tolerance of 0.03.
def na = Double.NaN;
def bn = BarNumber();
#input bars_back = 100;
input bars_back = 20;
input tol = 0.03;
input min_qty = 4;
def big = 99999;
def lines = 4;
def lastbn = highestall(if !isnan(close) then bn else 0);
def lastbar = if bn == lastbn then 1 else 0;
def bb = !IsNaN(close[-bars_back]) and IsNaN(close[-(bars_back + 1)]);
def bbbn = if bn == 1 then big
else if bb then bn
else bbbn[1];
addverticalline(bb, "-", color.cyan);
#----------------
# line 1 hi
def line1hicnt;
def line1hi;
if bn == 1
then {
line1hicnt = 0;
line1hi = 0;
#} else if bn >= (lastbn - bars_back) and line1hicnt[1] == 0 and !IsNaN(close) then {
} else if bn >= (lastbn - bars_back) and !IsNaN(close) then {
# compare high to all prices
line1hicnt = fold i1 = 0 to bars_back
with p1
while !isnan(getvalue(close, -i1))
do p1 + (if (absvalue(getvalue(high, -i1) - high) <= tol or absvalue(getvalue(low, -i1) - high) <= tol) then 1 else 0);
line1hi = if line1hicnt >= min_qty then line1hicnt else 0;
} else {
line1hicnt = line1hicnt[1];
line1hi = line1hi[1];
}
#-------------
# line 1 lo
def line1locnt;
def line1lo;
if bn == 1 then {
line1locnt = 0;
line1lo = 0;
#} else if bn >= (lastbn - bars_back) and line1locnt[1] == 0 and !IsNaN(close) then {
} else if bn >= (lastbn - bars_back) and !IsNaN(close) then {
# compare low to all prices
line1locnt = fold i2 = 0 to bars_back
with p2
while !isnan(getvalue(close, -i2))
do (p2 + (if absvalue(getvalue(high, -i2) - low) <= tol or absvalue(getvalue(low, -i2) - low) <= tol then 1 else 0));
line1lo = if line1locnt >= min_qty then line1locnt else 0;
} else {
line1locnt = line1locnt[1];
line1lo = line1lo[1];
}
#------------------
# count bars with counts that are > the min
def hi1cnts = if bn == 1 then 0 else if line1hicnt >= min_qty then hi1cnts[1] + 1 else hi1cnts[1];
def lo1cnts = if bn == 1 then 0 else if line1locnt >= min_qty then lo1cnts[1] + 1 else lo1cnts[1];
addlabel(1, hi1cnts + " hi qty bars", color.yellow);
addlabel(1, lo1cnts + " lo qty bars", color.yellow);
def hi1 = highestall(line1hi);
def lo1 = highestall(line1lo);
addlabel(1, hi1 + " hi", color.yellow);
addlabel(1, lo1 + " lo", color.yellow);
def hi1bar = if hi1 == line1hi then 1 else 0;
def lo1bar = if lo1 == line1lo then 1 else 0;
plot zhi1b = hi1bar;
zhi1b.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_up);
zhi1b.SetDefaultColor(Color.green);
zhi1b.setlineweight(3);
zhi1b.hidebubble();
plot zlo1b = lo1bar;
zlo1b.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
zlo1b.SetDefaultColor(Color.red);
zlo1b.setlineweight(3);
zlo1b.hidebubble();
def hi1lvl = highestall(if hi1bar then high else 0);
def lo1lvl = highestall(if lo1bar then low else 0);
plot zhi1c = if bn >= (lastbn - bars_back) and !isnan(close) then hi1lvl else na;
plot zlo1c = if bn >= (lastbn - bars_back) and !isnan(close) then lo1lvl else na;
input test1 = no;
addchartbubble(test1, low*0.9995,
line1hi + "\n" +
line1lo + "\n"
# hi1 + "\n" +
# lo1 + "\n"
, color.yellow, no);
#
CVS 5min
40 bars back
4 , minimum quantity of bars to have a price within tolerance ( interaction)
green arrow on bar with the most interactions (most other bars with similar prices)
red arrow on bar with most interactions (most other bars with similar prices)
1st label , 25 hi qty bars , means there are 25 bars that have more than 4 price interaction with other bars after it.
3rd label, 10 hi , there is 1 bar that has 10 interactions with its high price. green arrow.
in order to draw many lines, there would need to be many plot code lines, AND MANY supporting code lines.
most of this study would have to be copied and modified, just to add 2 more lines.
-------------------
this plots 2 lines,
..from a high with the most interactions
..from a low with the most interactions
....interaction , a price on another bar is within the tolerance of current high or low.
pick how many bars to look at, at the end of the chart (default is 100)
pick a tolerance price number (default is 0.03)
pick a minimum quantity that the counts need to be greater than to be considered (default is 4)
looks at the last x bars on a chart,
..on each bar, it makes 2 comparisons (for 2 lines). 1 from the high and 1 from the low.
..it looks at all the bars after the current bar and,
....counts how many highs and lows are within the tolerance of the high
....counts how many highs and lows are within the tolerance of the low
draws 2 horizontal lines,
..finds the highest count from a high and plots a line
..finds the highest count from a low and plots a line
2 small arrows are drawn,
..green above the bar with the high with most interactions
..red below the bar with the low with most interactions
4 labels are displayed
..2 with quantity of bars with the minimum interactions, from a high or low
..2 with the max interactions from a high, and max from a low
Code:
# prime_lines_same_price
# https://usethinkscript.com/threads/prime-lines.16659/
#draws horz lines that extend to the right
#when there are 4 or more candle highs and or lows
#that meet up at any common price point
#with an adjustable tolerance of 0.03.
def na = Double.NaN;
def bn = BarNumber();
#input bars_back = 100;
input bars_back = 20;
input tol = 0.03;
input min_qty = 4;
def big = 99999;
def lines = 4;
def lastbn = highestall(if !isnan(close) then bn else 0);
def lastbar = if bn == lastbn then 1 else 0;
def bb = !IsNaN(close[-bars_back]) and IsNaN(close[-(bars_back + 1)]);
def bbbn = if bn == 1 then big
else if bb then bn
else bbbn[1];
addverticalline(bb, "-", color.cyan);
#----------------
# line 1 hi
def line1hicnt;
def line1hi;
if bn == 1
then {
line1hicnt = 0;
line1hi = 0;
#} else if bn >= (lastbn - bars_back) and line1hicnt[1] == 0 and !IsNaN(close) then {
} else if bn >= (lastbn - bars_back) and !IsNaN(close) then {
# compare high to all prices
line1hicnt = fold i1 = 0 to bars_back
with p1
while !isnan(getvalue(close, -i1))
do p1 + (if (absvalue(getvalue(high, -i1) - high) <= tol or absvalue(getvalue(low, -i1) - high) <= tol) then 1 else 0);
line1hi = if line1hicnt >= min_qty then line1hicnt else 0;
} else {
line1hicnt = line1hicnt[1];
line1hi = line1hi[1];
}
#-------------
# line 1 lo
def line1locnt;
def line1lo;
if bn == 1 then {
line1locnt = 0;
line1lo = 0;
#} else if bn >= (lastbn - bars_back) and line1locnt[1] == 0 and !IsNaN(close) then {
} else if bn >= (lastbn - bars_back) and !IsNaN(close) then {
# compare low to all prices
line1locnt = fold i2 = 0 to bars_back
with p2
while !isnan(getvalue(close, -i2))
do (p2 + (if absvalue(getvalue(high, -i2) - low) <= tol or absvalue(getvalue(low, -i2) - low) <= tol then 1 else 0));
line1lo = if line1locnt >= min_qty then line1locnt else 0;
} else {
line1locnt = line1locnt[1];
line1lo = line1lo[1];
}
#------------------
# count bars with counts that are > the min
def hi1cnts = if bn == 1 then 0 else if line1hicnt >= min_qty then hi1cnts[1] + 1 else hi1cnts[1];
def lo1cnts = if bn == 1 then 0 else if line1locnt >= min_qty then lo1cnts[1] + 1 else lo1cnts[1];
addlabel(1, hi1cnts + " hi qty bars", color.yellow);
addlabel(1, lo1cnts + " lo qty bars", color.yellow);
def hi1 = highestall(line1hi);
def lo1 = highestall(line1lo);
addlabel(1, hi1 + " hi", color.yellow);
addlabel(1, lo1 + " lo", color.yellow);
def hi1bar = if hi1 == line1hi then 1 else 0;
def lo1bar = if lo1 == line1lo then 1 else 0;
plot zhi1b = hi1bar;
zhi1b.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_up);
zhi1b.SetDefaultColor(Color.green);
zhi1b.setlineweight(3);
zhi1b.hidebubble();
plot zlo1b = lo1bar;
zlo1b.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
zlo1b.SetDefaultColor(Color.red);
zlo1b.setlineweight(3);
zlo1b.hidebubble();
def hi1lvl = highestall(if hi1bar then high else 0);
def lo1lvl = highestall(if lo1bar then low else 0);
plot zhi1c = if bn >= (lastbn - bars_back) and !isnan(close) then hi1lvl else na;
plot zlo1c = if bn >= (lastbn - bars_back) and !isnan(close) then lo1lvl else na;
input test1 = no;
addchartbubble(test1, low*0.9995,
line1hi + "\n" +
line1lo + "\n"
# hi1 + "\n" +
# lo1 + "\n"
, color.yellow, no);
#
CVS 5min
40 bars back
4 , minimum quantity of bars to have a price within tolerance ( interaction)
green arrow on bar with the most interactions (most other bars with similar prices)
red arrow on bar with most interactions (most other bars with similar prices)
1st label , 25 hi qty bars , means there are 25 bars that have more than 4 price interaction with other bars after it.
3rd label, 10 hi , there is 1 bar that has 10 interactions with its high price. green arrow.
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.
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.