# SimpleTrendChannelFilter study used in scan

#### geebeeaye

##### Member
I'm using this code as a study:

Can someone help me use this in a scan when Uptrend is true?

Code:
``````#
# TD Ameritrade IP Company, Inc. (c) 2015-2020
#

#wizard plots
#wizard text: Inputs: trend check:
#wizard input: trendCheck

input trendCheck = {Min, Normal, default Max};
input showLabel = yes;

def avg20 = Average(close, 20);
def avg50 = Average(close, 50);
def avg200 = Average(close, 200);

plot Downtrend = close < avg50 and
(if trendCheck != trendCheck.Min then avg20 < avg50 else yes) and
(if trendCheck == trendCheck.Max then avg50 < avg200 else yes);
plot Uptrend = close > avg50 and
(if trendCheck != trendCheck.Min then avg20 > avg50 else yes) and
(if trendCheck == trendCheck.Max then  avg50 > avg200 else yes);

Downtrend.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Downtrend.SetLineWeight(3);
Downtrend.SetDefaultColor(Color.DOWNTICK);
Uptrend.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Uptrend.SetLineWeight(3);
Uptrend.SetDefaultColor(Color.UPTICK);

DefineGlobalColor("Downtrend", Color.DOWNTICK);
DefineGlobalColor("Sideways", Color.GRAY);
DefineGlobalColor("Uptrend", Color.UPTICK);
AddLabel(showLabel, if Downtrend then "Downtrend" else if Uptrend then "Uptrend" else "Sideways", if Downtrend then GlobalColor("Downtrend") else if Uptrend then GlobalColor("Uptrend") else GlobalColor("Sideways"));``````

Can someone help me use this in a scan when Uptrend is true?

As easy as this:

87k+ Posts
129 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?