Can TOS bet set up to detect complex chart patterns?

Roddog101

New member
New member here fwiw & currently test driving the TOS platform. Been manually trading for over 20 yrs & change is hard for an older dog like me.
I hate for my first post to be asking for information but here goes.

Can an indicator me made to detect complex chart pattern?

I was reading an article by someone that uses Trade Station & they were able to write a string & makes claims they could detect any pattern you could throw at them.
It was described as Fréchet distance. Not sure the rules here linking to other articles so I will refrain till I get a better feel for the community/rules.
I am not really speaking of standard canned candlestick patterns like abandoned baby etc etc. If doable I have a sample chart I can post.
As you probably know this pattern would never be the exact same candle count/distance etc., but its the general pattern I want to seek out.
My takeaway is this what the guy was able to do this in the article.


Hopefully I have enought screen time under my belt that I can make a contribution here and there in the trading realm but I am a newbie to the TOS platform.
Currently I am still trading on my regular account and using TOS for vol profile charts & doing some testing.
 
The possibilities are endless. You wouldn't know until you start putting something together. That being said, you can start with some of the existing patterns that ThinkorSwim already offers in its platform. Locate the Chart Patterns tab at the upper right-hand corner of your ToS screen. There, you will find three different categories:
  • Candlestick Patterns
  • Classic Patterns
  • Fibonacci Patterns
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Yes I see I played with some of the canned off the shelf patterns. So far none of the off the shelf patterns will show what I am after.
Here are a few examples. Basically want to look for that wedge repeating pattern you see. These are charts I marked up in a hurry intraday but the main goal was to get a visual of the repeating wedges. Notice the heights & widths are almost never exact but my understanding of the Fréchet distance & using some "Fuzzy" logic it could be done...

Any help into the right direction much appreciated.
 
Here's a start
Code:
# insidebar345_01

#  add - look for 3 bar pattern

# insidebar45_01

# find 3,4,5 bar , inside bar patterns
# update from  quadinsidebar_01

# start with ver01.  lines for 5 bar
#  copy 5bar code and chg for  3 bar and 4 bar
# disable 2nd agg

# ---------------------------------

# quadinsidebar_01
# 2020-06-27
# halcyonguy
#  find a quad inside bar (5 bar pattern)
#    1st bar high, bar 0, is higher than the following 4 bars
#    1st bar low, bar 0, is lower than the following 4 bars
#  draw diagonal and horizontal lines
#    draw lines 3 bars beyond pattern
#    calc slope from 1st bar high to 5th bar high. same with lows
#  draw horizontal lines on a 4 bar pattern
#  draw wedges (samll arrows) on bar0
#



#declare upper;
#declare once_per_bar;


# ------------------------------

#  draw diagonal and horizontal lines on a 5 bar pattern
#  draw lines 3 bars beyond


def na = double.nan;
def hi = high;
def lo = low;

# bar count, indenifier bubble, vert offset
def bubvert = 0.998;

input show_3_bar_pattern = yes;
input show_4_bar_pattern = yes;
input show_5_bar_pattern = yes;

#  plot small arrows above and below bar0
input show_small_arrows_bar0 = yes;

#  plot small arrows above and below last bar
input show_small_arrows_last_bar = yes;

input show_bar_count_bubble = yes;
def sbcb =  show_bar_count_bubble;


# ----- 5 bar inside pattern ---------------------------------

# formulas ref'd off of the 1st bar, bar0, the biggest in the pattern
# find a bar bigger than the next 4 bars
def fivebar0 = show_5_bar_pattern and hi > hi[-1] and hi > hi[-2] and hi > hi[-3] and hi > hi[-4] and lo < lo[-1] and lo < lo[-2] and lo < lo[-3] and lo < lo[-4];

# define the 5 bars in an inside bar
#  as time goes on, look back x+ bars at bar0 to see if it was the biggest candle
def fivebar = fivebar0 or fivebar0[1] or fivebar0[2] or fivebar0[3] or fivebar0[4];


#  plot small arrows above and below bar0
plot v5 = fivebar0 and show_small_arrows_bar0;
v5.SetPaintingStrategy(PaintingStrategy.boolean_wedge_UP);
v5.AssignValueColor(Color.white);
v5.SetLineWeight(1);
v5.hidebubble();
plot w5 = fivebar0 and show_small_arrows_bar0;
w5.SetPaintingStrategy(PaintingStrategy.boolean_wedge_down);
w5.AssignValueColor(Color.white);
w5.SetLineWeight(1);
w5.hidebubble();


#  plot small arrows above and below last bar
plot s5 = fivebar0[4] and show_small_arrows_last_bar;
s5.SetPaintingStrategy(PaintingStrategy.boolean_wedge_UP);
s5.AssignValueColor(Color.white);
s5.SetLineWeight(1);
s5.hidebubble();
plot t5 = fivebar0[4] and show_small_arrows_last_bar;
t5.SetPaintingStrategy(PaintingStrategy.boolean_wedge_down);
t5.AssignValueColor(Color.white);
t5.SetLineWeight(1);
t5.hidebubble();

#  sbcb =  show_bar_count_bubble;
addchartbubble(sbcb and fivebar0, (low * bubvert), "5", color.cyan, no);

#  enable slope lines - define bars to draw slope lines.
#  5 bars , and +3 extra bars past the last bar
def en_slope5lines = fivebar or fivebar[1] or fivebar[2] or fivebar[3];

#  calc the slope from 4 gaps, (5 bars)
def bar5gaps = 4;
#  hi slope is neg , lo slope is pos
#  use the 1st bar and last bar to calc slope
def slope5hi2 = (hi[-bar5gaps] - hi[0])/bar5gaps;
def slope5lo2 = (lo[-bar5gaps] - lo[0])/bar5gaps;

#  test data
#addchartbubble(yes,high+0.2, slopehi2 + "\n" + hi[-4] + "\n" + hi[0], color.cyan,yes);
#addchartbubble(yes,low-0.2, slopelo2 + "\n" + lo[-4] + "\n" + lo[0], color.cyan,no);

#  read the slope when fivebar0, and keep it during the 5 bars, and 3 bars after
def slope5hi = if fivebar0 then slope5hi2 else if en_slope5lines then slope5hi[1] else na;
def slope5lo = if fivebar0 then slope5lo2 else if en_slope5lines then slope5lo[1] else na;
# test data  high slope
#addchartbubble(en_slope5lines, high+0.4, slope5hi, color.cyan,yes);

# get barnum at bar0, and keep it during the slope line
def bar0_5number = if fivebar0 then barnumber() else if en_slope5lines then bar0_5number[1] else na;
#addchartbubble(en_slopelines,high+0.2, bar0_number, color.cyan,yes);

#  get the high at bar0, for 5 bar pattern, and keep it during the slope line
def bar0_5high = if fivebar0 then hi else if en_slope5lines then bar0_5high[1] else na;

#  get the low at bar0, for 5 bar pattern, and keep it during the slope line
def bar0_5low = if fivebar0 then lo else if en_slope5lines then bar0_5low[1] else na;

# calc the slope line between 1st and 5th bar highs.
plot diag5hi = if en_slope5lines then ( bar0_5high + (slope5hi * (barnumber() - bar0_5number))) else na;
diag5hi.AssignValueColor(Color.cyan);
diag5hi.SetStyle(Curve.MEDIUM_DASH);
diag5hi.hidebubble();

# calc the slope line between 1st and 5th bar lows.
plot diag5lo = if en_slope5lines then ( bar0_5low + (slope5lo * (barnumber() - bar0_5number))) else na;
diag5lo.AssignValueColor(Color.cyan);
diag5lo.SetStyle(Curve.MEDIUM_DASH);
diag5lo.hidebubble();

# plot a horizontal line at the high of 1st bar
plot horz5hi = if en_slope5lines then bar0_5high else na;
horz5hi.AssignValueColor(Color.cyan);
horz5hi.hidebubble();

# plot a horizontal line at the low of 1st bar
plot horz5lo = if en_slope5lines then bar0_5low else na;
horz5lo.AssignValueColor(Color.cyan);
horz5lo.hidebubble();


# --- 4 bar inside pattern ---------------------------------------


# if a 5 bar exists, dont draw 4 bar lines
#  chk if 4 bar pattern is desired
def draw_4bar = if fivebar then 0 else if show_4_bar_pattern then 1 else 0;

# formulas ref'd off of the 1st bar, bar0, the biggest in the pattern
# find a bar bigger than the next 3 bars
def fourbar0 = draw_4bar and hi > hi[-1] and hi > hi[-2] and hi > hi[-3] and lo < lo[-1] and lo < lo[-2] and lo < lo[-3];
# define the 4 bars in an inside bar
#  as time goes on, look back x+ bars at bar0 to see if it was the biggest candle
def fourbar = fourbar0 or fourbar0[1] or fourbar0[2] or fourbar0[3];

#  plot small arrows above and below bar0
plot v4 = fourbar0 and show_small_arrows_bar0;
v4.SetPaintingStrategy(PaintingStrategy.boolean_wedge_UP);
v4.AssignValueColor(Color.white);
v4.SetLineWeight(1);
v4.hidebubble();
plot w4 = fourbar0 and show_small_arrows_bar0;
w4.SetPaintingStrategy(PaintingStrategy.boolean_wedge_down);
w4.AssignValueColor(Color.white);
w4.SetLineWeight(1);
w4.hidebubble();

#  plot small arrows above and below last bar
plot s4 = fourbar0[3] and show_small_arrows_last_bar;
s4.SetPaintingStrategy(PaintingStrategy.boolean_wedge_UP);
s4.AssignValueColor(Color.white);
s4.SetLineWeight(1);
s4.hidebubble();
plot t4 = fourbar0[3] and show_small_arrows_last_bar;
t4.SetPaintingStrategy(PaintingStrategy.boolean_wedge_down);
t4.AssignValueColor(Color.white);
t4.SetLineWeight(1);
t4.hidebubble();

#  sbcb =  show_bar_count_bubble;
addchartbubble(sbcb and fourbar0, (low * bubvert), "4", color.cyan, no);

#  enable slope lines - define bars to draw slope lines.
#  4 bars , and +3 extra bars past the last bar
def en_slope4lines = fourbar or fourbar[1] or fourbar[2] or fourbar[3];

#  calc the slope from 3 gaps, (4 bars)
def bar4gaps = 3;
#  hi slope is neg , lo slope is pos
#  use the 1st bar and last bar to calc slope
def slope4hi2 = (hi[-bar4gaps] - hi[0])/bar4gaps;
def slope4lo2 = (lo[-bar4gaps] - lo[0])/bar4gaps;

#  test data
#addchartbubble(yes,high+0.2, slope4hi2 + "\n" + hi[-4] + "\n" + hi[0], color.cyan,yes);
#addchartbubble(yes,low-0.2, slope4lo2 + "\n" + lo[-4] + "\n" + lo[0], color.cyan,no);

#  read the slope when fourbar0, and keep it during the 4 bars, and 3 bars after
def slope4hi = if fourbar0 then slope4hi2 else if en_slope4lines then slope4hi[1] else na;
def slope4lo = if fourbar0 then slope4lo2 else if en_slope4lines then slope4lo[1] else na;
# test data  high slope
#addchartbubble(en_slope4lines,high+0.4, slope4hi, color.cyan,yes);

# get barnum at bar0, and keep it during the slope line
def bar0_4number = if fourbar0 then barnumber() else if en_slope4lines then bar0_4number[1] else na;
#addchartbubble(en_slope4lines,high+0.2, bar0_4number, color.cyan,yes);

#  get the high at bar0, for 4 bar pattern, and keep it during the slope line
def bar0_4high = if fourbar0 then hi else if en_slope4lines then bar0_4high[1] else na;

#  get the low at bar0, for 4 bar pattern, and keep it during the slope line
def bar0_4low = if fourbar0 then lo else if en_slope4lines then bar0_4low[1] else na;


# calc the slope line between 1st and 4th bar highs.
plot diag4hi = if en_slope4lines then ( bar0_4high + (slope4hi * (barnumber() - bar0_4number))) else na;
diag4hi.AssignValueColor(Color.cyan);
diag4hi.SetStyle(Curve.MEDIUM_DASH);
diag4hi.hidebubble();

# calc the slope line between 1st and 4th bar lows.
plot diag4lo = if en_slope4lines then ( bar0_4low + (slope4lo * (barnumber() - bar0_4number))) else na;
diag4lo.AssignValueColor(Color.cyan);
diag4lo.SetStyle(Curve.MEDIUM_DASH);
diag4lo.hidebubble();

# plot a horizontal line at the high of 1st bar
plot horz4hi = if en_slope4lines then bar0_4high else na;
horz4hi.AssignValueColor(Color.cyan);
horz4hi.hidebubble();

# plot a horizontal line at the low of 1st bar
plot horz4lo = if en_slope4lines then bar0_4low else na;
horz4lo.AssignValueColor(Color.cyan);
horz4lo.hidebubble();


#  --- 3 bar inside pattern -----------


# if a 5 bar or 4 bar exists, dont draw 3 bar lines
#  chk if 3 bar pattern is desired
def draw_3bar = if fivebar or fourbar then 0 else if show_3_bar_pattern then 1 else 0;


# formulas ref'd off of the 1st bar, bar0, the biggest in the pattern
# find a bar bigger than the next 2 bars
def threebar0 = draw_3bar and hi > hi[-1] and hi > hi[-2] and hi > hi[-3] and lo < lo[-1] and lo < lo[-2] and lo < lo[-3];
# define the 3 bars in an inside bar
#  as time goes on, look back x+ bars at bar0 to see if it was the biggest candle
def threebar = threebar0 or threebar0[1] or threebar0[2] or threebar0[3];


#  plot small arrows above and below bar0
plot v3 = threebar0 and show_small_arrows_bar0;
v3.SetPaintingStrategy(PaintingStrategy.boolean_wedge_UP);
v3.AssignValueColor(Color.white);
v3.SetLineWeight(1);
v3.hidebubble();
plot w3 = threebar0 and show_small_arrows_bar0;
w3.SetPaintingStrategy(PaintingStrategy.boolean_wedge_down);
w3.AssignValueColor(Color.white);
w3.SetLineWeight(1);
w3.hidebubble();


#  plot small arrows above and below last bar
plot s3 = threebar0[3] and show_small_arrows_last_bar;
s3.SetPaintingStrategy(PaintingStrategy.boolean_wedge_UP);
s3.AssignValueColor(Color.white);
s3.SetLineWeight(1);
s3.hidebubble();
plot t3 = threebar0[3] and show_small_arrows_last_bar;
t3.SetPaintingStrategy(PaintingStrategy.boolean_wedge_down);
t3.AssignValueColor(Color.white);
t3.SetLineWeight(1);
t3.hidebubble();


#  sbcb =  show_bar_count_bubble;
addchartbubble(sbcb and threebar0, (low * bubvert), "3", color.cyan, no);

#  enable slope lines - define bars to draw slope lines.
#  3 bars , and +3 extra bars past the last bar
def en_slope3lines = threebar or threebar[1] or threebar[2] or threebar[3];


#  calc the slope from 2 gaps, (3 bars)
def bar3gaps = 2;
#  hi slope is neg , lo slope is pos
#  use the 1st bar and last bar to calc slope
def slope3hi2 = (hi[-bar3gaps] - hi[0])/bar3gaps;
def slope3lo2 = (lo[-bar3gaps] - lo[0])/bar3gaps;

#  test data
#addchartbubble(yes,high+0.2, slope3hi2 + "\n" + hi[-4] + "\n" + hi[0], color.cyan,yes);
#addchartbubble(yes,low-0.2, slope3lo2 + "\n" + lo[-4] + "\n" + lo[0], color.cyan,no);

#  read the slope when threebar0, and keep it during the 3 bars, and 3 bars after
def slope3hi = if threebar0 then slope3hi2 else if en_slope3lines then slope3hi[1] else na;
def slope3lo = if threebar0 then slope3lo2 else if en_slope3lines then slope3lo[1] else na;
# test data  high slope
#addchartbubble(en_slope3lines,high+0.4, slope3hi, color.cyan,yes);

# get barnum at bar0, and keep it during the slope line
def bar0_3number = if threebar0 then barnumber() else if en_slope3lines then bar0_3number[1] else na;
#addchartbubble(en_slope3lines,high+0.2, bar0_3number, color.cyan,yes);

#  get the high at bar0, for 3 bar pattern, and keep it during the slope line
def bar0_3high = if threebar0 then hi else if en_slope3lines then bar0_3high[1] else na;

#  get the low at bar0, for 4 bar pattern, and keep it during the slope line
def bar0_3low = if threebar0 then lo else if en_slope3lines then bar0_3low[1] else na;


# calc the slope line between 1st and 3rd bar highs.
plot diag3hi = if en_slope3lines then (bar0_3high + (slope3hi * (barnumber() - bar0_3number))) else na;
diag3hi.AssignValueColor(Color.cyan);
diag3hi.SetStyle(Curve.MEDIUM_DASH);
diag3hi.hidebubble();

# calc the slope line between 1st and 3rd bar lows.
plot diag3lo = if en_slope3lines then (bar0_3low + (slope3lo * (barnumber() - bar0_3number))) else na;
diag3lo.AssignValueColor(Color.cyan);
diag3lo.SetStyle(Curve.MEDIUM_DASH);
diag3lo.hidebubble();

# plot a horizontal line at the high of 1st bar
plot horz3hi = if en_slope3lines then bar0_3high else na;
horz3hi.AssignValueColor(Color.cyan);
horz3hi.hidebubble();

# plot a horizontal line at the low of 1st bar
plot horz3lo = if en_slope3lines then bar0_3low else na;
horz3lo.AssignValueColor(Color.cyan);
horz3lo.hidebubble();
#
 
When you're logged on to think or swim desktop platform look to the right side where it says patterns. Click on that it will bring you to another window and you can select all of the patterns. Once you select them you can view those on 15 minute chart 30 minute chart 1 hour chart and daily chart.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
295 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