Fractal Chaos Bands Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
The Fractal Chaos Bands Indicator was originally coded for TradingView. It helps to identify whether the stock is trending or not. Requested for conversion to ThinkorSwim by @cherif.

Here is a quick snippet of what it does and how the Chaos Bands works:

When a market is trending, the bands will have a slope and if market is not trending the bands will flatten out. As the slope of the bands decreases, it signifies that the market is choppy, insecure and variable. As the graph becomes more and more abrupt, be it going up or down, the significance is that the market becomes trendy, or stable. Fractal Chaos Bands Indicator is used similarly to other bands-indicator (Bollinger bands for instance), offering trading opportunities when price moves above or under the fractal lines.

We also added buy and sell signals into the indicator so that you can test out its potential.

LgiAEGk.png


thinkScript Code

Rich (BB code):
# Chaos Bands Conversion by WalkingBallista and BenTen for cherif
# https://www.tradingview.com/script/YE3wLwsR-Fractal-Chaos-Bands-Backtest/
# https://usethinkscript.com/d/134-fractal-chaos-bands-indicator-for-thinkorswim

input sequenceCount = 1;

def maxSideLength = sequenceCount + 10;
def upRightSide = fold i1 = 1 to maxSideLength + 1 with count1 while count1 != sequenceCount and count1 != -1 do
    if GetValue(high, -i1) > high or (GetValue(high, -i1) == high and count1 == 0) then -1
    else if GetValue(high, -i1) < high then count1 + 1 else count1;
def upLeftSide = fold i2 = 1 to maxSideLength + 1 with count2 while count2 != sequenceCount and count2 != -1 do
    if GetValue(high, i2) > high or (GetValue(high, i2) == high and count2 >= 1) then -1
    else if GetValue(high, i2) < high then count2 + 1 else count2;

def downRightSide = fold i3 = 1 to maxSideLength + 1 with count3 while count3 != sequenceCount and count3 != -1 do
    if GetValue(low, -i3) < low or (GetValue(low, -i3) == low and count3 == 0) then -1
    else if GetValue(high, -i3) > low then count3 + 1 else count3;
def downLeftSide = fold i4 = 1 to maxSideLength + 1 with count4 while count4 != sequenceCount and count4 != -1 do
    if GetValue(low, i4) < low or (GetValue(low, i4) == low and count4 >= 1) then -1
    else if GetValue(low, i4) > low then count4 + 1 else count4;

def fractalUp = if upRightSide == sequenceCount and upLeftSide == sequenceCount then high else fractalUp[1];
def fractalDown = if downRightSide == sequenceCount and downLeftSide == sequenceCount then low else fractalDown[1];

plot UpFractal = fractalUp;
plot DownFractal = fractalDown;

AddOrder(OrderType.BUY_AUTO, close > UpFractal, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "FCB_L");

AddOrder(OrderType.SELL_AUTO, close < DownFractal, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "FCB_S");

Shareable Link

https://tos.mx/S1Z9HZ

Credits:
 
Last edited:

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Quick note: I tried to merge the other discussions posted by @WalkingBallista comments but ended up deleting all the content in that post. I do apologize.

 
Last edited:

laketrader

Member
2019 Donor
VIP
I loaded the indicator into TOS but noticed one difference from original indicator from Tradeview. In Tradeview indicator picture, the system seemed to sell short when the price is out of upper band and to buy long when the price is out of lower band.

 
Last edited:

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
@laketrader Isn't that how it's supposed so be? I didn't look too much into the TradingView version.

 
Last edited:

cherif

Member
The rule is go long when price breaks out of upper fractal and and go short when price breaks out of the downfractal. Exits will depend on peoples risk tolerance, but the farthest u should go before exiting is when price hit the opposite fractal.

One observation as far as the upfractal and downfractal are concerned, when i move the n sequence to 3 or 4, the fractals stops to respond to price movements unless i refresh and hit apply. Any idea why?

 
Last edited:

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
@aceboogie_11 The code above is a backtesting script. You need to add it as a strategy instead of a regular indicator.
 
Just discovering this indicator. Very nice. Is there a way to hide the pivot candle values and display arrows/wedges instead?
 

sellitmarin

New member
VIP
How would you add alerts as the lines are crossed? I'd like to setup a johnny quotron addition with this to trigger buy / sell alarms when it crosses in either direction, then use the quotron to get the supply and demand zone ranges.

I've got a zscore strategy installed and shooting off alarms, and I have a feeling with this, it will be a two prong approach and when it hits, its gonna be amazing every single time. I've been using zscore to find bottoms. So far the zscore is always before the lift off, but I'd like to learn how to get things setup as alarms. Does anyone have any tutorials?
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
How would you add alerts as the lines are crossed? I'd like to setup a johnny quotron addition with this to trigger buy / sell alarms when it crosses in either direction, then use the quotron to get the supply and demand zone ranges.

I've got a zscore strategy installed and shooting off alarms, and I have a feeling with this, it will be a two prong approach and when it hits, its gonna be amazing every single time. I've been using zscore to find bottoms. So far the zscore is always before the lift off, but I'd like to learn how to get things setup as alarms. Does anyone have any tutorials?
Fractal Alert:
Alert(UpFractal , "UpFractal ", Alert.Bar, Sound.Chimes);
Alert(DownFractal , "DownFractal ", Alert.Bar, Sound.Chimes);

https://usethinkscript.com/resources/how-to-add-alert-script-to-thinkorswim-indicators.9/
 

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.
Top