Repaints Harmonic Patterns Indicator for ThinkorSwim (ZigZag, Bat, Butterfly, ABCD)

Repaints
I have a question to anyone about using this code.

At the beginning of the page it says,
"All of these harmonic and fractals patterns are identified automatically for you. Once the pattern is detected, it will be drawn and labeled right on your chart."

Suppose I'm only interested in detecting and seeing only one particular pattern - say the wolf wave.
1. Can the detection of all other patterns be turned off? If so how to do it.
-- it would be nice to be able to select from a menu only the one pattern you are interested in seeing.
2. In which case should I be seeing the wolf wave pattern lines and only the wolf wave pattern lines.
3. In the code, is the website for Syracusepro, The address is not working. Do you now his current web address?
 
Last edited:
hi, it's weird but alerts don't work :/
use alerts: Yes
Alerts
Alert 1: Enabled "Repeatedly for each Bar"
Alert 2: Enabled "Repeatedly for each Bar"
Alert 3: Enabled "Repeatedly for each Bar"
Alert 4: Enabled "Repeatedly for each Bar"
Alert 5: Enabled "Repeatedly for each Bar"
Please, any idea how to make them work?
Thanks
 
@hexis777 Will only work while you're viewing the chart. If there is a pattern being developed on $AAPL but you have $MSFT loaded as a chart you won't receive an alert for the $AAPL chart. Best bet is to create a grid and have multiple of your favorite tickers loaded.
 
@DPM Use the one you showed as an example. Leave the main code alone and comment out the patterns you do not want. After you can erase those if you wish. I did that a while back and do not remember anything much about it. Play around and see if you can get what you want. Show how you are progressing if you run into troubles and someone can suggest a solution.
 
  • Like
Reactions: DPM
Hey, i need some help, how do I just cut out the parts I need in this script??
I need the Butterfly pattern:
#---------------------------------------#
#= ==== Butterfly Pattern Function =====#
#---------------------------------------#
script isButterfly {
input _mode = 0;
input xab = 0;
input xad = 0;
input abc = 0;
input bcd = 0;
input d = 0;
input c = 0;
def _xab = xab <= 0.786;
def _abc = abc >= 0.382 and abc <= 0.886;
def _bcd = bcd >= 1.618 and bcd <= 2.618;
def _xad = xad >= 1.27 and xad <= 1.618;
plot ret = _xab and _abc and _bcd and _xad and (if _mode == 1 then d < c else d > c);
}
#---------------------------------------#
 
@RoyalBlue Try this.

Code:
#----------------------------------------------------------------#
#============== Syracusepro Harmonics and Fractals ==============#
#----------------------------------------------------------------#
#===== This program was made with the intention of educational   #
#===== purposes. It contains fractal and harmonic patterns.      #
#===== On the zigzags, the Fibonacci sequence numbers are also   #
#===== included, and shows what makes each patterns valid with   #
#===== their correct names.                                      #
#=========== I hope people interested can make a great program   #
#=========== out of this material. Thanks. ======================#
#----------------------------------------------------------------#

#---------------- Total of 12 Harmonic Patterns -----------------#

#================= Http://www.thinkscriptcode.com ===============#

#---------------------------------------#
#===== Irregular fractals function =====#
#---------------------------------------#
###### mcdon030 addded tolerance per Larry Pesavento
##### and roughly 17 more patterns.
script isRegularFractal {
    input mode=0;
    plot ret = if mode == 1 then high[4] < high[3] and high[3] < high[2] and high[2] > high[1] and high[1] > high[0] else if mode == -1 then low[4] > low[3] and low[3] > low[2] and low[2] < low[1] and low[1] < low[0] else 0;
}

#---------------------------------------#
#===== BWilliams fractals function =====#
#---------------------------------------#
script isBWFractal {
    input mode=0;
    plot ret = if mode == 1 then high[4] < high[2] and high[3] <= high[2] and high[2] >= high[1] and high[2] > high[0] else if mode == -1 then low[4] > low[2] and low[3] >= low[2] and low[2] <= low[1] and low[2] < low[0] else 0;

}

input showPatterns=Yes;
input showBarColors=No;
input filterBW=No;
input ShowHHLL=No;
input ShowTimeFractals1=No;
input showArrows = No;
input tolerance =.06;
input timeframe1={MIN, TWO_MIN, THREE_MIN, FOUR_MIN, FIVE_MIN, TEN_MIN, FIFTEEN_MIN, TWENTY_MIN, THIRTY_MIN, HOUR, TWO_HOURS, FOUR_HOURS,default DAY, TWO_DAYS, THREE_DAYS, FOUR_DAYS, WEEK, MONTH, OPT_EXP};

input showchannel1=No;
input showchannel2=No;
input showchannel3=No;
input showZigZag=Yes;

def bn=barNumber();
def h2=high[2];
def l2=low[2];

def filteredtopf = if filterBW then isRegularFractal(1) else isBWFractal(1);
def filteredbotf = if filterBW then isRegularFractal(-1) else isBWFractal(-1);

plot TopFractals=filteredtopf[-2];
plot BottomFractals=filteredbotf[-2];
#def TopFractals=filteredtopf[-2];
#def BottomFractals=filteredbotf[-2];

TopFractals.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
TopFractals.SetDefaultColor(color.RED);
BottomFractals.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
BottomFractals.SetDefaultColor(color.GREEN );

def b1_0=if bn==0 then -1 else if filteredtopf == 0 then 0 else if b1_0[1]>-1 then b1_0[1]+1 else -1;
def b1_1=b1_0+Getvalue(b1_0,b1_0+1,0)+1;
def b1_2=b1_1+Getvalue(b1_0,b1_1+1,0)+1;

def b2_0=if bn==0 then -1 else if filteredbotf == 0 then 0 else if b2_0[1]>-1 then b2_0[1]+1 else -1;
def b2_1=b2_0+Getvalue(b2_0,b2_0+1,0)+1;
def b2_2=b2_1+Getvalue(b2_0,b1_1+1,0)+1;

def higherhigh = if filteredtopf == 0 or b1_2==b1_1 then 0 else GetValue(high[2],b1_1,0) < GetValue(high[2],b1_0,0) and GetValue(high[2],b1_2,0) < GetValue(high[2],b1_0,0);
def lowerhigh = if filteredtopf == 0 or b1_2==b1_1 then 0 else GetValue(high[2],b1_1,0) > GetValue(high[2],b1_0,0) and GetValue(high[2],b1_2,0) > GetValue(high[2],b1_0,0);
def higherlow = if filteredbotf == 0 or b2_2==b2_1 then 0 else GetValue(low[2],b2_1,0) < GetValue(low[2],b2_0,0) and GetValue(low[2],b2_2,0) < GetValue(low[2],b2_0,0);
def lowerlow = if filteredbotf == 0 or b2_2==b2_1 then 0 else GetValue(low[2],b2_1,0) > GetValue(low[2],b2_0,0) and GetValue(low[2],b2_2,0) > GetValue(low[2],b2_0,0);

AddChartBubble(ShowHHLL and higherhigh,high[-2],"[HH]",color.CYAN,yes);
AddChartBubble(ShowHHLL and lowerhigh,high[-2],"[LH]",color.CYAN,yes);
AddChartBubble(ShowHHLL and higherlow,low[-2],"[HL]",color.GREEN);
AddChartBubble(ShowHHLL and lowerlow,low[-2],"[LL]",color.GREEN);

def hh=if bn==0 then -1 else if higherhigh == 1 then 0 else if hh[1]>-1 then hh[1]+1 else -1;
def ll=if bn==0 then -1 else if lowerlow == 1 then 0 else if ll[1]>-1 then ll[1]+1 else -1;

def higherhhigh = if higherhigh == 0 or hh==-1 then 0 else GetValue(high[2],hh,0) >= high(period=timeframe1) ;
def lowerllow = if lowerlow == 0 or ll==-1 then 0 else GetValue(low[2],ll,0) <= low(period=timeframe1);

AddChartBubble(ShowTimeFractals1 and higherhhigh , high[-2],"[TL]",color.GREEN,yes);
AddChartBubble(ShowTimeFractals1 and lowerllow, low[-2],"[TL]",color.GREEN);

plot TopChannel1=if showchannel1 and filteredtopf then h2[-2] else Double.NaN;
plot BottomChannel1=if showchannel1 and filteredbotf then l2[-2] else Double.NaN;
TopChannel1.SetDefaultColor(color.green);
BottomChannel1.SetDefaultColor(color.red);

TopChannel1.enableApproximation();
BottomChannel1.enableApproximation();

plot TopChannel2=if showchannel2 and higherhigh then h2[-2] else Double.NaN;
plot BottomChannel2=if showchannel2 and lowerlow then l2[-2] else Double.NaN;
TopChannel2.SetDefaultColor(color.BLUE);
BottomChannel2.SetDefaultColor(color.BLUE);

TopChannel2.enableApproximation();
BottomChannel2.enableApproximation();

plot TopChannel3=if showchannel3 and higherhhigh then h2[-2] else Double.NaN;
plot BottomChannel3=if showchannel3 and lowerllow then l2[-2] else Double.NaN;
TopChannel3.SetDefaultColor(color.VIOLET);
BottomChannel3.SetDefaultColor(color.VIOLET);

TopChannel3.enableApproximation();
BottomChannel3.enableApproximation();

addcloud(TopChannel3, BottomChannel3, color.green, color.red);

def istop = if ShowTimeFractals1 then (if higherhhigh  then 1 else 0) else (if filteredtopf then 1 else 0);
def isbot = if ShowTimeFractals1 then (if lowerllow then 1 else 0) else (if filteredbotf then 1 else 0);

def topcount0 = if istop then bn else topcount0[1];
def botcount0 = if isbot then bn else botcount0[1];

def topcount=bn-topcount0;
def botcount=bn-botcount0;

def zigzag = if istop and topcount[1] > botcount[1] then h2 else if isbot and topcount[1] < botcount[1] then l2 else Double.NaN;

#def zz=if showZigZag then zigzag else Double.NaN;
#plot zz=if showZigZag then zigzag else Double.NaN;
plot zz=if showZigZag then zigzag[-2] else Double.NaN;
zz.SetDefaultColor(color.WHITE);
zz.enableApproximation();

AssignPriceColor(if showBarColors and isNaN(zigzag) == 0 then(if h2==zigzag then color.blue else if l2==zigzag then color.CYAN else color.CURRENT) else color.CURRENT);

def z_0=if bn==0 then -1 else if isNaN(zigzag) == 0 then 0 else if z_0[1]>-1 then z_0[1]+1 else -1;
def z_1=z_0+Getvalue(z_0,z_0+1,0)+1;
def z_2=z_1+Getvalue(z_0,z_1+1,0)+1;
def z_3=z_2+Getvalue(z_0,z_2+1,0)+1;
def z_4=z_3+Getvalue(z_0,z_3+1,0)+1;
def z_5=z_4+Getvalue(z_0,z_4+1,0)+1;

#plot rz0=z_0;
#plot rz1=z_1;
#plot rz2=z_2;
#rz0.SetDefaultColor(color.RED);
#plot rgv=Getvalue(z_0,(z_1+1),0);
#rgv.SetDefaultColor(color.GREEN);

#======= Preparing the XABCD Patterns =======#
def x1=GetValue(zigzag,z_5,0);
def x=GetValue(zigzag,z_4,0);
def a=GetValue(zigzag,z_3,0);
def b=GetValue(zigzag,z_2,0);
def c=GetValue(zigzag,z_1,0);
def d=GetValue(zigzag,z_0,0);

#plot rx=x;
#plot ra=a;
#plot rb=b;
#plot rc=c;
#plot rd=d;

#====== Combination to create the patterns ======#

def xab = (AbsValue(b-a)/AbsValue(x-a));
def xad = (AbsValue(a-d)/AbsValue(x-a));
def abc = (AbsValue(b-c)/AbsValue(a-b));
def bcd = (AbsValue(c-d)/AbsValue(b-c));
def xabc = (AbsValue(b-c)/AbsValue(x-a));
def x1xcd = (AbsValue(d-c)/AbsValue(x1-x));## wave5
def x1xab = (AbsValue(b-a)/AbsValue(x1-x));## wave3
def x1xxa = (AbsValue(x-a)/AbsValue(x1-x));## wave2
#===== Checking to see if there is a pattern functions =====#


#---------------------------------------#
#= ==== Butterfly Pattern Function =====#
#---------------------------------------#
script isButterfly {
    input _mode = 0;
    input xab = 0;
    input xad = 0;
    input abc = 0;
    input bcd = 0;
    input d = 0;
    input c = 0;
    def _xab = xab <= 0.786;
    def _abc = abc >= 0.382 and abc <= 0.886;
    def _bcd = bcd >= 1.618 and bcd <= 2.618;
    def _xad = xad >= 1.27 and xad <= 1.618;
    plot ret = _xab and _abc and _bcd and _xad and (if _mode == 1 then d < c else d > c);
}
def u_bfly1 = showPatterns and isButterfly(-1, xab, xad, abc, bcd, d, c) and isButterfly(-1, xab, xad, abc, bcd, d, c)[1] == 0;
AddChartBubble(u_bfly1[-2] , high, "Bear Butterfly", Color.RED, yes);
#============ End Syracusepro Harmonics and Fractals ============#
 
Hi Robert, are the patterns shown for historical prices too? I would like to perform manual back test to see the performance.
 
Someone by the name of syracusepro initiated the Harmonics and Fractals study several years ago and another contributor mcdon030 added more patterns to it. Perhaps you might want to reach out to them and see if they can accommodate your request. Through a quick Google search you can find syracusepro's email. I occasionally see mcdon030 in the ThinkScript Lounge so you may try to catch him there. That might be the closest to get you where you need to be and it would not cost you $$$
 
Last edited:
Someone by the name of syracusepro initiated the Harmonics and Fractals study several years ago and another contributor mcdon030 added more patterns to it. Perhaps you might want to reach out to them and see if they can accommodate your request. Through a quick Google search you can find syracusepro's email. I occasionally see mcdon030 in the ThinkScript Lounge so you may try to catch him there. That might be the closest to get you where you need to be and it would not cost you $$$
thanks, but I can do most of these price point stuff by hand, just thought it be nice to have it automatized, but paying such a high price, seems wasteful, since I know the code are worth some money, but definitely not as high as they are asking.
 
Looking for a thinkscript coder to build a scanner for Harmonics. I'm a TA sceptic and I would be willing to pay to find out. Please drop me a message. TY.
 
Hi Robert, are the patterns shown for historical prices too? I would like to perform manual back test to see the performance.

Yes. The historical patterns are on the charts. The indicator also works with the OnDemand feature.
 
I tried looking for Wave 1, 2, and 3 but don't see it. I only see Wave 4 and 5. Am i missing something?

not that I am an Elliot expert, but according to most stuff I read your waiting until the 4th and 5th wave. so called smart traders wait until the 5th. without all the cycles built in, the concept of trading Elliott waves is extremely difficult. Even the TOS scripts which promote themselves as "Elliott" only have one cycle. Seems counter productive not to include mono cycles. I've added a few more "Elliott" type stuff and other patterns I mess with as I wanted to share with all the scripters which helped me, but I would have a health skepticism with it as it requires a better script. https://tos.mx/056xjyp

side note: if you really want wave 3, ill add it.
 
Hi HourseRider thank you for the script. How did you make yours look so clean, do you mind showing your settings for the script? My chart looks very different. And also can you share the volume wave script too? Sorry for asking so much this late, but thank you for the script!!
 
Last edited:

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
273 Online
Create Post

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