scan for double top and double bottom

FFGARCIA

New member
Dear all,

Can someone help me convert the following chart indicator code into a scanner?

Thank you in advance!

# https://usethinkscript.com/threads/double-top-and-double-bottom-for-thinkorswim.11391/
# Tops \ Bottoms
# Mobius
# Modified C.Ricks 12/22/22

input Percent_A_to_C = .1;
input nP = 13;
input DisplayLabels = Yes;


def AC = Percent_A_to_C / 100;
def h = high;
def l = low;
def bar = BarNumber();
def Ps = 1 + AC;
def Ns = 1 - AC;

def hh = fold j = 1 to nP + 1
with q = 1
while q
do h > GetValue(h, -j);

def PivotH = if (bar > nP and
h == Highest(h, nP) and
hh)
then h
else Double.NaN;

def PH1 = if !isNaN(PivotH)
then h
else PH1[1];

def PH2 = if PH1 != PH1[1]
then PH1[1]
else PH2[1];

def CheckH1 = if between(PH2, PH1 * Ns, PH1 * Ps)
then 1
else 0;

plot CondH1 = HighestAll(if CheckH1
then PH2
else double.nan);
CondH1.SetDefaultColor(Color.WHITE);


plot PivotHDot = PivotH;
PivotHDot.SetDefaultColor(Color.WHITE);
PivotHDot.SetPaintingStrategy(PaintingStrategy.POINTS);


# Double Bottom

def ll = fold jl = 1 to nP + 1
with ql = 1
while ql
do l < GetValue(low, -jl);

def PivotL = if (bar > nP and
l == Lowest(l, nP) and
ll)
then l
else Double.NaN;

def PL1 = if !isNaN(PivotL)
then l
else PL1[1];

def PL2 = if PL1 != PL1[1]
then PL1[1]
else PL2[1];

def Check1 = if between(PL2, PL1 * Ns, PL1 * Ps)
then 1
else 0;

plot Cond1 = HighestAll(if Check1
then PL2
else double.nan);
Cond1.SetDefaultColor(Color.White);


plot PivotLDot = PivotL;
PivotLDot.SetDefaultColor(Color.White);
PivotLDot.SetPaintingStrategy(PaintingStrategy.POINTS);


AddChartBubble(DisplayLabels && PivotLDot, low, "DB", Color.YELLOW, yes);
AddChartBubble(DisplayLabels && PivotHDot, high, "DT", Color.WHITE, yes);


# End Code
 

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