Expert Trend Locator (XTL) For ThinkOrSwim

ignapaillet

New member
Expert Trend Locator (XTL) For ThinkOrSwim
helps you to easily define in what kind of trend you are.
Its calculation is based on CCI and a fixed value of that indicator:
  • if CCI value<-fixed value you're in a short trend (red bars);
  • if -fixedvalue<=CCI<=+fixedvalue you are in a non trend/flat period (white bars);
  • if CCI>fixed value you're in a long trend period (cyan bars);
Code:
input period = 35;
input paintBars = yes;

def fixedValue = 37;
def sma = SimpleMovingAvg(10);

def GreenPrice = CCI(period) > fixedValue;
def RedPrice = CCI(period) < -fixedValue;
def NeutralPrice = -fixedValue <= CCI(period) and CCI(period) <= fixedValue;

plot Bullish = GreenPrice;
plot Neutral = NeutralPrice;
plot Bearish = RedPrice;

Bullish.SetDefaultColor(Color.CYAN);
Bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Bullish.SetLineWeight(3);
Bullish.hide();
Neutral.SetDefaultColor(Color.WHITE);
Neutral.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Neutral.SetLineWeight(3);
Neutral.hide();
Bearish.SetDefaultColor(Color.RED);
Bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Bearish.SetLineWeight(3);
Bearish.hide();

DefineGlobalColor("Bullish", Color.CYAN);
DefineGlobalColor("Neutral", Color.WHITE);
DefineGlobalColor("Bearish", Color.RED);
AssignPriceColor(if !paintBars then Color.CURRENT else if GreenPrice then globalColor("Bullish") else if RedPrice then globalColor("Bearish") else globalColor("Neutral"));
a1.png



I'm looking for help.
I want to create a Watchlist Column that displays "Bullish", "Neutral" or "Bearish" based on the Expert Trend Locator (XTL).
Thank you very much for your help!
 
Last edited by a moderator:
Good afternoon, everybody! I'm not very good for coding, and that's why I'm looking for help.

I want to create a Watchlist Column that displays "Bullish", "Neutral" or "Bearish" based on the Expert Trend Locator (XTL).
I have the code of XTL that paints bars on the chart, but I'm not capable of modifying it for the watchlist column.

This is the XTL code:
Code:
input period = 35;
input paintBars = yes;

def fixedValue = 37;
def sma = SimpleMovingAvg(10);

def GreenPrice = CCI(period) > fixedValue;
def RedPrice = CCI(period) < -fixedValue;
def NeutralPrice = -fixedValue <= CCI(period) and CCI(period) <= fixedValue;

plot Bullish = GreenPrice;
plot Neutral = NeutralPrice;
plot Bearish = RedPrice;

Bullish.SetDefaultColor(Color.CYAN);
Bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Bullish.SetLineWeight(3);
Bullish.hide();
Neutral.SetDefaultColor(Color.WHITE);
Neutral.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Neutral.SetLineWeight(3);
Neutral.hide();
Bearish.SetDefaultColor(Color.RED);
Bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Bearish.SetLineWeight(3);
Bearish.hide();

DefineGlobalColor("Bullish", Color.CYAN);
DefineGlobalColor("Neutral", Color.WHITE);
DefineGlobalColor("Bearish", Color.RED);
AssignPriceColor(if !paintBars then Color.CURRENT else if GreenPrice then globalColor("Bullish") else if RedPrice then globalColor("Bearish") else globalColor("Neutral"));

Thank you very much for your help!

try this

Code:
input period = 35;
 input paintBars = yes; 
def fixedValue = 37; 
def sma = SimpleMovingAvg(10); 
def GreenPrice = CCI(period) > fixedValue; 
def RedPrice = CCI(period) < -fixedValue; def NeutralPrice = -fixedValue <= CCI(period) and CCI(period) <= fixedValue; 

def Bullish = GreenPrice;
def Neutral = NeutralPrice; 
def Bearish = RedPrice;

addlabel(1, (if bullish then "bullish" else if bearish then "bearish" else "neutral", color.black);

assignbackgroundcolor(if bullish then color.green else if bearish then color.red else color.gray);
 
try this

Code:
input period = 35;
 input paintBars = yes;
def fixedValue = 37;
def sma = SimpleMovingAvg(10);
def GreenPrice = CCI(period) > fixedValue;
def RedPrice = CCI(period) < -fixedValue; def NeutralPrice = -fixedValue <= CCI(period) and CCI(period) <= fixedValue;

def Bullish = GreenPrice;
def Neutral = NeutralPrice;
def Bearish = RedPrice;

addlabel(1, (if bullish then "bullish" else if bearish then "bearish" else "neutral", color.black);

assignbackgroundcolor(if bullish then color.green else if bearish then color.red else color.gray);
hello to add three lines in the xtl trend it would be the first bullish or bearish bar the -50 is the first line would be the stop and 100% is the second line is the entry and the third 200% the target but the third is active if the trend breaks the second line .. so also for the downward the same .. all lines are deactivated at the end of the upward or downward trend
 
Last edited:

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