Speed Indicator For ThinkOrSwim

I was wondering if there was a tool to convert pine script to think script. This looks like a useful indicator to determine size of market moves.

https://www.tradingview.com/script/LSb23VWz-Speed-Indicator/
find below.

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0
#// © sumitmak
#indicator("Speed Indicator", shorttitle="SI")
# converted by Sam4COK@Samer800 - 10/2023 - request from UseThinkScript.com memeber
declare lower;

#//Time and Speed Range
input SpeedLength = 20;                # "Speed Period"
input MovAvgLength = 20;               # "Moving Average Period"
input ChannelLength = 20;              # "Channel Period"
input PriceCalculation = {Default "Close", "High/Low"};#, "To use either close values or high/low")
input usePricePercentage = no;    # "Speed Price Percentage", "Display Speed in Percentage to Closing Price"
input showSpeedMovAvg = no;       # "Speed EMA", "Applies an EMA line to the Indicator")
input showMaxMinBand = yes;       # "Shows a min-max channel like the Donchian Channels on the Indicator"
input showTripleBollingerBands = no;# "Triple Bollinger Bands", "Shows three different Bollinger Band channels"

def na = Double.NaN;
def hl = PriceCalculation==PriceCalculation."High/Low";
def bb = showTripleBollingerBands;
#//Distance
def gu = if low > high[1] then (low - high[1]) else na;
def gd = if high < low[1] then (low[1] - high) else na;
def hlg = if low > high[1] then (high - low + gu) else
          if high < low[1] then (high - low + gd) else (high - low);
def clc = AbsValue(close - close[1]);
def dis = if hl then hlg else clc;
def d = Sum(dis, SpeedLength);

#//Speed
def s = d / SpeedLength;
def sp = s / close * 100;
def sv = if usePricePercentage then sp else s;

#//Speedometer Min-Max Bands
def max = Highest(sv, ChannelLength);
def min = Lowest(sv, ChannelLength);
def sr = (max - min) / 3;
def hs = max - sr;
def ls = min + sr;

#//Speed Standard Deviation Bands
def ema = ExpAverage(sv, MovAvgLength);
def std = stdev(sv, ChannelLength);
def bbu1 = ema + 1 * std;
def bbl1 = ema - 1 * std;
def bbu2 = ema + 2 * std;
def bbl2 = ema - 2 * std;
def bbu3 = ema + 3 * std;
def bbl3 = ema - 3 * std;

#//Plots and Fills
plot speed = sv;#, "Speed", #FF0000, 2)
speed.SetLineWeight(2);
speed.SetDefaultColor(Color.MAGENTA);

plot p1 = if showMaxMinBand then max else na;#, "Max", color.red)
plot p2 = if showMaxMinBand then hs else na;#, "High", color.yellow)
p1.SetDefaultColor(Color.RED);
p2.SetDefaultColor(Color.YELLOW);

plot LowLine = if showMaxMinBand then ls else na;#, "Low", color.green)
plot minLine = if showMaxMinBand then min else na;#, "Min", color.blue)
LowLine.SetDefaultColor(Color.GREEN);
minLine.SetDefaultColor(Color.CYAN);

plot AvgSpeed = if showSpeedMovAvg then ema else na;#, "Average Speed", color.orange)
plot UpBB1 = if bb then bbu1 else na;#, "Upper 1 SD", color.green)
plot LoBB1 = if bb then bbl1 else na;#, "Lower 1 SD", color.green)

plot bb1 = if bb then bbu2 else na;#, "Upper 2 SD", color.yellow)
plot bb2 = if bb then bbl2 else na;#, "Lower 2 SD", color.yellow)
plot bb3 = if bb then bbu3 else na;#, "Upper 3 SD", color.red)
plot bb4 = if bb then bbl3 else na;#, "Lower 3 SD", color.red)

AvgSpeed.SetDefaultColor(Color.ORANGE);
UpBB1.SetDefaultColor(Color.DARK_GREEN);
LoBB1.SetDefaultColor(Color.DARK_GREEN);

BB1.SetDefaultColor(Color.DARK_ORANGE);
BB2.SetDefaultColor(Color.DARK_ORANGE);
BB3.SetDefaultColor(Color.DARK_RED);
BB4.SetDefaultColor(Color.DARK_RED);

AddCloud(p1, p2,  Color.DARK_RED);#,"Top Range")
AddCloud(bb3, bb1, Color.DARK_RED);#, "Upper 3 SD Range")
AddCloud(bb2, bb4, Color.DARK_RED);#, "Lower 3 SD Range")


#-- END of CODE
 
@samer800 You are a hero for this community!
find below.

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0
#// © sumitmak
#indicator("Speed Indicator", shorttitle="SI")
# converted by Sam4COK@Samer800 - 10/2023 - request from UseThinkScript.com memeber
declare lower;

#//Time and Speed Range
input SpeedLength = 20;                # "Speed Period"
input MovAvgLength = 20;               # "Moving Average Period"
input ChannelLength = 20;              # "Channel Period"
input PriceCalculation = {Default "Close", "High/Low"};#, "To use either close values or high/low")
input usePricePercentage = no;    # "Speed Price Percentage", "Display Speed in Percentage to Closing Price"
input showSpeedMovAvg = no;       # "Speed EMA", "Applies an EMA line to the Indicator")
input showMaxMinBand = yes;       # "Shows a min-max channel like the Donchian Channels on the Indicator"
input showTripleBollingerBands = no;# "Triple Bollinger Bands", "Shows three different Bollinger Band channels"

def na = Double.NaN;
def hl = PriceCalculation==PriceCalculation."High/Low";
def bb = showTripleBollingerBands;
#//Distance
def gu = if low > high[1] then (low - high[1]) else na;
def gd = if high < low[1] then (low[1] - high) else na;
def hlg = if low > high[1] then (high - low + gu) else
          if high < low[1] then (high - low + gd) else (high - low);
def clc = AbsValue(close - close[1]);
def dis = if hl then hlg else clc;
def d = Sum(dis, SpeedLength);

#//Speed
def s = d / SpeedLength;
def sp = s / close * 100;
def sv = if usePricePercentage then sp else s;

#//Speedometer Min-Max Bands
def max = Highest(sv, ChannelLength);
def min = Lowest(sv, ChannelLength);
def sr = (max - min) / 3;
def hs = max - sr;
def ls = min + sr;

#//Speed Standard Deviation Bands
def ema = ExpAverage(sv, MovAvgLength);
def std = stdev(sv, ChannelLength);
def bbu1 = ema + 1 * std;
def bbl1 = ema - 1 * std;
def bbu2 = ema + 2 * std;
def bbl2 = ema - 2 * std;
def bbu3 = ema + 3 * std;
def bbl3 = ema - 3 * std;

#//Plots and Fills
plot speed = sv;#, "Speed", #FF0000, 2)
speed.SetLineWeight(2);
speed.SetDefaultColor(Color.MAGENTA);

plot p1 = if showMaxMinBand then max else na;#, "Max", color.red)
plot p2 = if showMaxMinBand then hs else na;#, "High", color.yellow)
p1.SetDefaultColor(Color.RED);
p2.SetDefaultColor(Color.YELLOW);

plot LowLine = if showMaxMinBand then ls else na;#, "Low", color.green)
plot minLine = if showMaxMinBand then min else na;#, "Min", color.blue)
LowLine.SetDefaultColor(Color.GREEN);
minLine.SetDefaultColor(Color.CYAN);

plot AvgSpeed = if showSpeedMovAvg then ema else na;#, "Average Speed", color.orange)
plot UpBB1 = if bb then bbu1 else na;#, "Upper 1 SD", color.green)
plot LoBB1 = if bb then bbl1 else na;#, "Lower 1 SD", color.green)

plot bb1 = if bb then bbu2 else na;#, "Upper 2 SD", color.yellow)
plot bb2 = if bb then bbl2 else na;#, "Lower 2 SD", color.yellow)
plot bb3 = if bb then bbu3 else na;#, "Upper 3 SD", color.red)
plot bb4 = if bb then bbl3 else na;#, "Lower 3 SD", color.red)

AvgSpeed.SetDefaultColor(Color.ORANGE);
UpBB1.SetDefaultColor(Color.DARK_GREEN);
LoBB1.SetDefaultColor(Color.DARK_GREEN);

BB1.SetDefaultColor(Color.DARK_ORANGE);
BB2.SetDefaultColor(Color.DARK_ORANGE);
BB3.SetDefaultColor(Color.DARK_RED);
BB4.SetDefaultColor(Color.DARK_RED);

AddCloud(p1, p2,  Color.DARK_RED);#,"Top Range")
AddCloud(bb3, bb1, Color.DARK_RED);#, "Upper 3 SD Range")
AddCloud(bb2, bb4, Color.DARK_RED);#, "Lower 3 SD Range")


#-- END of CODE
@samer800 You are a hero to this community!
 

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