Is it possible to make an indicator / scan that would show when there has been 3 of the same price as a high / low. Example below on SQ from todays trading session.
It hit 63.00 3 times in a row , I'm looking for something that would instead of "Breakout Price" would highlight "Pivot" every time a price has 3 consecutive highs
Is it possible to make an indicator / scan that would show when there has been 3 of the same price as a high / low. Example below on SQ from todays trading session.
It hit 63.00 3 times in a row , I'm looking for something that would instead of "Breakout Price" would highlight "Pivot" every time a price has 3 consecutive highs
Is it possible to make an indicator / scan that would show when there has been 3 of the same price as a high / low. Example below on SQ from todays trading session.
It hit 63.00 3 times in a row , I'm looking for something that would instead of "Breakout Price" would highlight "Pivot" every time a price has 3 consecutive highs
you mentioned scan and display words, so i'm not sure what you want.
i made this up chart study.
this will look for x bars in a row, at the same high, or same low price, and draw arrows, on the main chart.
can choose how many bars are to be near the same price.
it checks if adjacent bars have a price within x % . the default is 0.02%. set to 0 if you want prices exactly the same.
can choose to also look for a pivot. it just looks at the bars before the same bars, so i'm calling this condition a half pivot. (it doesn't look at the bars after the same bars).
can show dots for the same price conditions and half pivots.
Code:
# same_price_for_x_bars_0
# https://usethinkscript.com/threads/scan-that-would-show-when-there-has-been-3-of-the-same-price-as-a-high-low.13246/
# scan that would show when there has been 3 of the same price as a high / low
#-----------------------------------
def na = double.nan;
def bn = barnumber();
input min_qty_of_same_price = 3;
def minq = min_qty_of_same_price;
# matching price tolerance percent
input match_tol_percent = 0.02;
def ishimatch_per = absvalue(high[1] - high) <= (high * (match_tol_percent/100));
def islomatch_per = absvalue(low[1] - low) <= (low * (match_tol_percent/100));
# were there x bars in a row, that had a price within y %?
def hix = if bn <= minq then 0 else (sum(ishimatch_per, minq-1) == (minq-1));
def lox = if bn <= minq then 0 else (sum(islomatch_per, minq-1) == (minq-1));
input pivot_len = 5;
# the previous bars form half a pivot
input check_for_half_pivot = yes;
input arrows = yes;
input dots_same_price = yes;
def vert1 = 0.003;
plot zhix = if (dots_same_price and hix) then (high * (1 + (2 * vert1))) else na;
zhix.SetPaintingStrategy(PaintingStrategy.POINTS);
zhix.SetDefaultColor(Color.yellow);
zhix.setlineweight(3);
zhix.hidebubble();
plot zlox = if (dots_same_price and lox) then (low * (1 - (2 * vert1))) else na;
zlox.SetPaintingStrategy(PaintingStrategy.POINTS);
zlox.SetDefaultColor(Color.blue);
zlox.setlineweight(3);
zlox.hidebubble();
#---------------------------
# half a pivot check, look at prev x bars
# check if prev highs were lower, or prev lows were higher
#input check_for_pivot = yes;
#input pivot_len = 5;
def hipiv = if !check_for_half_pivot then 1 else (high[minq-1] > highest(high[minq], pivot_len));
def lopiv = if !check_for_half_pivot then 1 else (low[minq-1] < lowest(low[minq], pivot_len));
input dots_pivot = yes;
plot zhipiv = if (dots_pivot and hipiv) then (high * (1 + (3 * vert1))) else na;
zhipiv.SetPaintingStrategy(PaintingStrategy.POINTS);
#zhipiv.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
zhipiv.SetDefaultColor(Color.red);
zhipiv.setlineweight(3);
zhipiv.hidebubble();
plot zlopiv = if (dots_pivot and lopiv) then (low * (1 - (3 * vert1))) else na;
zlopiv.SetPaintingStrategy(PaintingStrategy.POINTS);
#zlopiv.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
zlopiv.SetDefaultColor(Color.green);
zlopiv.setlineweight(3);
zlopiv.hidebubble();
#-----------------------------------
def downx = (hix and hipiv);
def upx = (lox and lopiv);
#input arrows = yes;
plot zdownx = if (arrows and downx) then (high * (1 + (0.5 * vert1))) else na;
zdownx.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#zdownx.SetPaintingStrategy(PaintingStrategy.POINTS);
zdownx.SetDefaultColor(Color.red);
zdownx.setlineweight(3);
zdownx.hidebubble();
plot zupx = if (arrows and upx) then (low * (1 - (0.5 * vert1))) else na;
zupx.SetPaintingStrategy(PaintingStrategy.ARROW_up);
#zupx.SetPaintingStrategy(PaintingStrategy.POINTS);
zupx.SetDefaultColor(Color.green);
zupx.setlineweight(3);
zupx.hidebubble();
#
you mentioned scan and display words, so i'm not sure what you want.
i made this up chart study.
this will look for x bars in a row, at the same high, or same low price, and draw arrows, on the main chart.
can choose how many bars are to be near the same price.
it checks if adjacent bars have a price within x % . the default is 0.02%. set to 0 if you want prices exactly the same.
can choose to also look for a pivot. it just looks at the bars before the same bars, so i'm calling this condition a half pivot. (it doesn't look at the bars after the same bars).
can show dots for the same price conditions and half pivots.
Code:
# same_price_for_x_bars_0
# https://usethinkscript.com/threads/scan-that-would-show-when-there-has-been-3-of-the-same-price-as-a-high-low.13246/
# scan that would show when there has been 3 of the same price as a high / low
#-----------------------------------
def na = double.nan;
def bn = barnumber();
input min_qty_of_same_price = 3;
def minq = min_qty_of_same_price;
# matching price tolerance percent
input match_tol_percent = 0.02;
def ishimatch_per = absvalue(high[1] - high) <= (high * (match_tol_percent/100));
def islomatch_per = absvalue(low[1] - low) <= (low * (match_tol_percent/100));
# were there x bars in a row, that had a price within y %?
def hix = if bn <= minq then 0 else (sum(ishimatch_per, minq-1) == (minq-1));
def lox = if bn <= minq then 0 else (sum(islomatch_per, minq-1) == (minq-1));
input pivot_len = 5;
# the previous bars form half a pivot
input check_for_half_pivot = yes;
input arrows = yes;
input dots_same_price = yes;
def vert1 = 0.003;
plot zhix = if (dots_same_price and hix) then (high * (1 + (2 * vert1))) else na;
zhix.SetPaintingStrategy(PaintingStrategy.POINTS);
zhix.SetDefaultColor(Color.yellow);
zhix.setlineweight(3);
zhix.hidebubble();
plot zlox = if (dots_same_price and lox) then (low * (1 - (2 * vert1))) else na;
zlox.SetPaintingStrategy(PaintingStrategy.POINTS);
zlox.SetDefaultColor(Color.blue);
zlox.setlineweight(3);
zlox.hidebubble();
#---------------------------
# half a pivot check, look at prev x bars
# check if prev highs were lower, or prev lows were higher
#input check_for_pivot = yes;
#input pivot_len = 5;
def hipiv = if !check_for_half_pivot then 1 else (high[minq-1] > highest(high[minq], pivot_len));
def lopiv = if !check_for_half_pivot then 1 else (low[minq-1] < lowest(low[minq], pivot_len));
input dots_pivot = yes;
plot zhipiv = if (dots_pivot and hipiv) then (high * (1 + (3 * vert1))) else na;
zhipiv.SetPaintingStrategy(PaintingStrategy.POINTS);
#zhipiv.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
zhipiv.SetDefaultColor(Color.red);
zhipiv.setlineweight(3);
zhipiv.hidebubble();
plot zlopiv = if (dots_pivot and lopiv) then (low * (1 - (3 * vert1))) else na;
zlopiv.SetPaintingStrategy(PaintingStrategy.POINTS);
#zlopiv.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
zlopiv.SetDefaultColor(Color.green);
zlopiv.setlineweight(3);
zlopiv.hidebubble();
#-----------------------------------
def downx = (hix and hipiv);
def upx = (lox and lopiv);
#input arrows = yes;
plot zdownx = if (arrows and downx) then (high * (1 + (0.5 * vert1))) else na;
zdownx.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#zdownx.SetPaintingStrategy(PaintingStrategy.POINTS);
zdownx.SetDefaultColor(Color.red);
zdownx.setlineweight(3);
zdownx.hidebubble();
plot zupx = if (arrows and upx) then (low * (1 - (0.5 * vert1))) else na;
zupx.SetPaintingStrategy(PaintingStrategy.ARROW_up);
#zupx.SetPaintingStrategy(PaintingStrategy.POINTS);
zupx.SetDefaultColor(Color.green);
zupx.setlineweight(3);
zupx.hidebubble();
#
you mentioned scan and display words, so i'm not sure what you want.
i made this up chart study.
this will look for x bars in a row, at the same high, or same low price, and draw arrows, on the main chart.
can choose how many bars are to be near the same price.
it checks if adjacent bars have a price within x % . the default is 0.02%. set to 0 if you want prices exactly the same.
can choose to also look for a pivot. it just looks at the bars before the same bars, so i'm calling this condition a half pivot. (it doesn't look at the bars after the same bars).
can show dots for the same price conditions and half pivots.
Code:
# same_price_for_x_bars_0
# https://usethinkscript.com/threads/scan-that-would-show-when-there-has-been-3-of-the-same-price-as-a-high-low.13246/
# scan that would show when there has been 3 of the same price as a high / low
#-----------------------------------
def na = double.nan;
def bn = barnumber();
input min_qty_of_same_price = 3;
def minq = min_qty_of_same_price;
# matching price tolerance percent
input match_tol_percent = 0.02;
def ishimatch_per = absvalue(high[1] - high) <= (high * (match_tol_percent/100));
def islomatch_per = absvalue(low[1] - low) <= (low * (match_tol_percent/100));
# were there x bars in a row, that had a price within y %?
def hix = if bn <= minq then 0 else (sum(ishimatch_per, minq-1) == (minq-1));
def lox = if bn <= minq then 0 else (sum(islomatch_per, minq-1) == (minq-1));
input pivot_len = 5;
# the previous bars form half a pivot
input check_for_half_pivot = yes;
input arrows = yes;
input dots_same_price = yes;
def vert1 = 0.003;
plot zhix = if (dots_same_price and hix) then (high * (1 + (2 * vert1))) else na;
zhix.SetPaintingStrategy(PaintingStrategy.POINTS);
zhix.SetDefaultColor(Color.yellow);
zhix.setlineweight(3);
zhix.hidebubble();
plot zlox = if (dots_same_price and lox) then (low * (1 - (2 * vert1))) else na;
zlox.SetPaintingStrategy(PaintingStrategy.POINTS);
zlox.SetDefaultColor(Color.blue);
zlox.setlineweight(3);
zlox.hidebubble();
#---------------------------
# half a pivot check, look at prev x bars
# check if prev highs were lower, or prev lows were higher
#input check_for_pivot = yes;
#input pivot_len = 5;
def hipiv = if !check_for_half_pivot then 1 else (high[minq-1] > highest(high[minq], pivot_len));
def lopiv = if !check_for_half_pivot then 1 else (low[minq-1] < lowest(low[minq], pivot_len));
input dots_pivot = yes;
plot zhipiv = if (dots_pivot and hipiv) then (high * (1 + (3 * vert1))) else na;
zhipiv.SetPaintingStrategy(PaintingStrategy.POINTS);
#zhipiv.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
zhipiv.SetDefaultColor(Color.red);
zhipiv.setlineweight(3);
zhipiv.hidebubble();
plot zlopiv = if (dots_pivot and lopiv) then (low * (1 - (3 * vert1))) else na;
zlopiv.SetPaintingStrategy(PaintingStrategy.POINTS);
#zlopiv.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
zlopiv.SetDefaultColor(Color.green);
zlopiv.setlineweight(3);
zlopiv.hidebubble();
#-----------------------------------
def downx = (hix and hipiv);
def upx = (lox and lopiv);
#input arrows = yes;
plot zdownx = if (arrows and downx) then (high * (1 + (0.5 * vert1))) else na;
zdownx.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#zdownx.SetPaintingStrategy(PaintingStrategy.POINTS);
zdownx.SetDefaultColor(Color.red);
zdownx.setlineweight(3);
zdownx.hidebubble();
plot zupx = if (arrows and upx) then (low * (1 - (0.5 * vert1))) else na;
zupx.SetPaintingStrategy(PaintingStrategy.ARROW_up);
#zupx.SetPaintingStrategy(PaintingStrategy.POINTS);
zupx.SetDefaultColor(Color.green);
zupx.setlineweight(3);
zupx.hidebubble();
#
I tried to modify the code to use ticks instead of percentage, since percentage isn't reliable when looking for tiny increments in price differences
Here's my changes, but this doesn't seem to be working reliably, as I'm seeing arrows paint when the last 3 bars are greater than 4 ticks:
input match_tol_ticks = 0.4;
def ishimatch_per = absvalue(high[1] - high) <= match_tol_ticks;
def islomatch_per = absvalue(low[1] - low) <= match_tol_ticks;
Disabling "check for half pivots" does produce more accurate results, but still seeing scenarios (albeit few) where arrows are painting when the prior 3 candles are greater than 4 ticks at either the highs/lows e.g. 5, or not painting when less than 4 ticks.
Am I'm missing something?
Separately, is there a way to paint an arrow only if it's near (within a certain range of ticks) of a Price Level that's been manually drawn on a chart?
If detecting proximity to drawn Price Level isn't an option, then programmatically calculated references such as: Prior Day's Close/High/Low, Overnight High/Low etc.
Let me know if there's a better way to implement this:
def PreviousDayHigh = high(period = "day" )[1];
def PreviousDayLow = low(period = "day" )[1];
input PointsFromReference = 1;
#Using Mobius study for "GlobeX Overnight High / Low"
plot zdownx = if (arrows and downx and (Between(high, OvernightHigh - PointsFromReference, OvernightHigh + PointsFromReference) or Between(high,PreviousDayHigh - PointsFromReference, PreviousDayHigh + PointsFromReference))) then (high * (1 + (0.5 * vert1))) else na;
plot zupx = if (arrows and upx and (Between(low, OvernightLow - PointsFromReference, OvernightLow + PointsFromReference) or Between(low,PreviousDayLow - PointsFromReference, PreviousDayLow + PointsFromReference))) then (low * (1 - (0.5 * vert1))) else na;
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.