Visualizing Displacement [TFO] For ThinkOrSwim

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

Hey guys. TFO has created a displacement indicator for Trading View. Is there anyone who can convert it to TOS? I would be greatly appreciated.

Here is the link: https://www.tradingview.com/script/n6djFgQH-Visualizing-Displacement-TFO/
check out the below.

CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © tradeforopp
#indicator("Visualizing Displacement [TFO]", "Displacement [TFO]", true)
#Converted and mod by Sam4Cok@Samer800 - 12/2022
input BarColor = yes;
input ShowLines = no;
input require_fvg = yes;    # "Require FVG"
input disp_type = {Default "Open to Close", "High to Low"}; # "Displacement Type"
input DisplacementLength = 100;    # "Displacement Length"
input DisplacementStrength = 4.0;      # "Displacement Strength"

def na =Double.NaN;

def range = if disp_type == disp_type."Open to Close" then 1 else 0;

def candle_range = if range then AbsValue(open - close) else high - low;
def std = stdev(candle_range, DisplacementLength) * DisplacementStrength;
def fvg = if close[1] > open[1] then high[2] < low[0] else low[2] > high[0];
def disp = if require_fvg then candle_range[1] > std[1] and fvg else candle_range > std;
def displacement = if require_fvg then disp[-1] else disp;


def raising = if displacement then if close>open then 1 else 0 else raising[1];
def disHi = if displacement then high else disHi[1];
def disLo = if displacement then low else disLo[1];
def mid   = (disHi + disLo) / 2;

plot disUpper = if !ShowLines or disHi==0 then na else disHi;
disUpper.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
disUpper.AssignValueColor(if raising then Color.GREEN else Color.RED);

plot disLower = if !ShowLines or disLo==0 then na else disLo;
disLower.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
disLower.AssignValueColor(if raising then Color.GREEN else Color.RED);

plot midLine = if !ShowLines or mid==0 then na else mid;
midLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
midLine.SetDefaultColor(Color.GRAY);
midLine.SetStyle(Curve.SHORT_DASH);

AssignPriceColor(if (displacement and BarColor) then if raising then Color.CYAN else Color.MAGENTA else Color.CURRENT);

#--- END CODE
 
Thread starter Similar threads Forum Replies Date
samer800 Opening Range Gaps [TFO] for ThinkOrSwim Custom 3
hboogie Repaints Volume Spikes [TFO] For ThinkOrSwim Custom 2

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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