ATR Trailstop crossover watchlist

Hello,

I'm new and trying to create a watchlist column that changes color from red to green whenever the ATRTrailstop study crosses above or below the price of a stock....the idea being that it's a potential entry/exit point.

I've been using the below watchlist code to trigger for EMA crossovers and it works perfectly... but I'm having difficulty working out the code to get it to take by changing the values from an EMA cross to ATRTrailstop cross. I know there are lots of squared away people on here and I hate bothering anyone... but is there anyone out there who can help fix this?

I can get the study to work just fine in a watchlist by using
Code:
close crosses ATRTrailingStop("atr factor" = 2.5, "average type" = "EXPONENTIAL")

I just get it to take and I feel kind of useless... This is what I'm trying to modify:

Code:
declare lower;

input lookback = 1;
input ema1_len = 10;
input ema2_len = 20;
input averageType = AverageType.EXPONENTIAL;

def ema1 = MovAvgExponential(length=ema1_len);
def ema2 = MovAvgExponential(length=ema2_len);

def bull_cross = ema1 crosses above ema2;
def bear_cross = ema1 crosses below ema2;

def bull_lookback = highest(bull_cross, lookback);
def bear_lookback = highest(bear_cross, lookback);

plot signal = if bull_lookback then 2 else if bear_lookback then 1 else 0;
signal.AssignValueColor(if signal == 2 then Color.Green else if signal == 1 then Color.Red else Color.BLACK);
AssignBackgroundCOlor(if signal == 2 then Color.Green else if signal == 1 then Color.Red else Color.BLACK);

Thankyou to EVERYONE who has helped with code in the past...this is such a great group!

Malcolm
 
Last edited:
Solution
I'm new and trying to create a watchlist column that changes color from red to green whenever the ATRTrailstop study crosses above or below the price of a stock....the idea being that it's a potential entry/exit point.

Ruby:
# Trailing Stop Watchlist
# @MerryDay 4/2022

plot ATS = reference ATRTrailingStop("atr factor" = 2.5, "average type" = "EXPONENTIAL");
AssignBackgroundCOlor(
if close crosses above ATS then color.green else
if close crosses below ATS then color.red else color.light_gray) ;
I'm new and trying to create a watchlist column that changes color from red to green whenever the ATRTrailstop study crosses above or below the price of a stock....the idea being that it's a potential entry/exit point.

Ruby:
# Trailing Stop Watchlist
# @MerryDay 4/2022

plot ATS = reference ATRTrailingStop("atr factor" = 2.5, "average type" = "EXPONENTIAL");
AssignBackgroundCOlor(
if close crosses above ATS then color.green else
if close crosses below ATS then color.red else color.light_gray) ;
 
Last edited:
Solution

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