DEEPWATER_THE ONE For ThinkOrSwim

My Third Lower section Indicator i sometimes use is a Bollenger Bandwidth indicator. It lets me know when a breakout occurs, either up or down.
Code:
declare lower;

input averageType = AverageType.Simple;
input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_Up = 2.0;
input BulgeLength = 150;
input SqueezeLength = 150;

def upperBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, averageType).UpperBand;
def lowerBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, averageType).LowerBand;
def midLine = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, averageType).MidLine;

plot Bandwidth = (upperBand - lowerBand) / midLine * 100;
Bandwidth.SetDefaultColor(GetColor(1));
Bandwidth.SetLineWeight(3);
AddLabel(yes, if  Bandwidth > 1 then "BREAKOUT" else "", Color.CYAN);
Alert( Bandwidth > 2 ,  "BREAKOUT ", Alert.BAR, Sound.Ring);

plot Bulge = Highest(Bandwidth, BulgeLength);
Bulge.SetDefaultColor(GetColor(8));
Bulge.setStyle(Curve.SHORT_DASH);

plot Squeeze = Lowest(Bandwidth, SqueezeLength);
Squeeze.SetDefaultColor(GetColor(8));
Squeeze.setStyle(Curve.SHORT_DASH);

#End Code
Hi; I use this one give it a try @Deepwater

Code:
#// Indicator for TOS
#// © peacefulLizard50262
#indicator("Chebyshev type I and II", "CHBV", true)
# Converted by Sam4Cok@Samer800    - 12/2024
# Modified to plot I&II lenghts on chart by CANDO13579
# Description:
#   Implements two Chebyshev smoothing filters (Type I and Type II)
#   using custom fractional complement logic and fundamental data source.
#------------------------------------------------------------
input timeframe = AggregationPeriod.MIN;
input Source = FundamentalType.CLOSE;
input length = 50;
input ripple = 7.5;

def na = Double.NaN;
def last = IsNaN(close);
def cap = GetAggregationPeriod();
def tf = Max(cap, timeframe);

# Custom Functions
script fractional_complement {
    input x = 7.5;
    plot out = (10 - ((9 / 10 * x) % 9)) * Power(10, -1 - Floor(x / 10));
}

script cosh {
    input x = 1;
    plot out = (Exp(x) + Exp(-x)) / 2;
}

script sinh {
    input x = 1;
    plot out = (Exp(x) - Exp(-x)) / 2;
}

script acosh {
    input x = 1;
    plot out = if x < 1 then 0 else Log(x + Sqrt(x * x - 1));
}

script asinh {
    input x = 1;
    plot out = Log(x + Sqrt(x * x + 1));
}

# Shared Value
def fc = fractional_complement(ripple);

# Chebyshev Type I
def a1 = cosh(1 / length * acosh(1 / (1 - fc)));
def b1 = sinh(1 / length * asinh(1 / fc));
def g1 = (a1 - b1) / (a1 + b1);

def chbv1 = if IsNaN(chbv1[1]) then Fundamental(Source, period = tf)
            else (1 - g1) * Fundamental(Source, period = tf) + g1 * chbv1[1];

# Chebyshev Type II
def a2 = cosh(1 / length * acosh(1 / fc));
def b2 = sinh(1 / length * asinh(fc));
def g2 = (a2 - b2) / (a2 + b2);

def chbv2 = if IsNaN(chbv2[1]) then Fundamental(Source, period = tf)
            else (1 - g2) * Fundamental(Source, period = tf) + g2 * chbv2[1];

# Define Price for Comparison
def price = Fundamental(Source, period = tf);

# Plot CHBV_I with Dynamic Color
plot CHBV_I = if !last then chbv1 else na;
CHBV_I.SetLineWeight(2);
CHBV_I.AssignValueColor(
    if price > chbv1 then Color.GREEN  # Price above → Green
    else if price < chbv1 then Color.RED  # Price below → Red
    else Color.CYAN  # Neutral (if price = CHBV_I)
);
CHBV_I.SetStyle(Curve.FIRM);

# Plot CHBV_II with Dynamic Color
plot CHBV_II = if !last then chbv2 else na;
CHBV_II.SetLineWeight(2);
CHBV_II.AssignValueColor(
    if price > chbv2 then Color.LIGHT_ORANGE  # Price above → Green
    else if price < chbv2 then Color.RED  # Price below → Red
    else Color.YELLOW  # Neutral (if price = CHBV_II)
);
CHBV_II.SetStyle(Curve.FIRM);
 
Last edited by a moderator:

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

I created a Buy scan and placed the code on Page 1 the 4th entry is now the scan for the strong buy signal. You need to add other discriminator filters like volume, price etc. Youtube will help you set up custom scans if you can't figure it out.

https://usethinkscript.com/threads/deepwater_the-one.6518/
I can't get the scanner to work on futures. Is there something that can be added/modified in the code to strictly look at futures?
 
Been trading BBAI using The One. Up over 30% in 2026, over 60% over last three months. BBAI pretty much trading sideways.
 
Then up in my charts I use 2 EMA of specific lengths plus some other nice info like Volume I combined from other sources. Enjoy the code.

Code:
input timeFrame = {default day};
input showOnlyToday = no;

def day = GetDay();
def lastday = GetLastDay();
def isToday = If(day >= lastday, 1, 0);


def shouldPlot = If(showOnlyToday and isToday, 1, If(!showOnlyToday, 1, 0));
 #-----------------------------
 #input paintBars = yes;
 #-------------
plot UpperVolatility = isToday;
plot LowerVolatility = !isToday;
 #-----------------------

UpperVolatility.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
UpperVolatility.SetLineWeight(3);
UpperVolatility.SetDefaultColor(Color.GREEN);
UpperVolatility.Hide();
 #----------------------------
LowerVolatility.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
LowerVolatility.SetLineWeight(3);
LowerVolatility.SetDefaultColor(Color.RED);
LowerVolatility.Hide();
 #------------------------------------------
 #( today bars )
DefineGlobalColor("up", Color.GREEN);
DefineGlobalColor("dwn", Color.RED);

 # ( not today bars )
DefineGlobalColor("invisi", Color.BLACK);

 # if not paint bars then paint normal ... if condition1 then bullish scheme ... if condition2 then bearish scheme ... else normal
AssignPriceColor(
 if !showOnlyToday
 #!paintBars
then Color.CURRENT

else
 # ( is today then normal paint )
if UpperVolatility
then
if close > open then GlobalColor("up") else GlobalColor("dwn")
 #globalColor( "up"winking smiley

else
 # ( is not today then black)
if LowerVolatility
then GlobalColor( "invisi")
 else Color.CURRENT);



def today = GetDay() == GetLastDay();
plot dailyHigh = if !today then Double.NaN else high(period = "day" );
plot dailyLow = if !today then Double.NaN else low(period = "day" );
#-----------------------------
# ___________________________________________________________
# ________________  DAY/ HI-LOW / VOLUME ____________________
# ___________________________________________________________
#


input show_label = yes;
input show_bubble = no;


def period_Type = AggregationPeriod.DAY;

def begin = close(period = period_Type)[1];
def end = close(period = period_Type);
def NetChg = end - begin;
def PctChg = (end / begin) - 1;
def DayVolume = volume(period = "DAY");


AddLabel(show_label, " V: " + DayVolume + "  " , if  DayVolume > 0 then CreateColor( 224, 224, 224)
else if  DayVolume == 0 then CreateColor(224, 224, 224) else Color.LIGHT_GRAY);


def bar = if IsNaN(close)
             then if yes
                     then bar[1]
                     else Double.NaN
             else BarNumber();
def ThisBar = HighestAll(bar);
def barCount   = if bar == ThisBar
                 then close
                 else Double.NaN;
#####------EMA2
input price = close;
#input length9 = 9;
input length34 = 34;
input length144 = 144;
input displace = 0;
input showBreakoutSignals = no;

#def AvgExp9 = ExpAverage(price[-displace], length9);
def AvgExp34 = ExpAverage(price[-displace], length34);
def AvgExp144 = ExpAverage(price[-displace], length144);

input averageType = AverageType.EXPONENTIAL;

plot fastAvg = MovingAverage(averageType, price[-displace], Length34);
plot slowAvg = MovingAverage(averageType, price[-displace], Length144);

fastAvg.SetDefaultColor(GetColor(1));
slowAvg.SetDefaultColor(GetColor(0));
AddLabel(yes, if  fastAvg < slowAvg then "Trending Down" else "");
#Alert( fastAvg < slowAvg ,  "Trending Down ", Alert.BAR, Sound.Ring);
AddLabel(fastAvg > slowAvg, "Trending Up ", Color.LIGHT_GREEN);
#Alert( fastAvg > slowAvg ,  "Trending Up ", Alert.BAR, Sound.Ring);

#End Code
Thanks a lot .. !
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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