Trend Direction Indicator for ThinkorSwim

Pensar

Expert
VIP
Lifetime
This is a simple indicator that displays trend by using new 1, 3, and 6 month highs. When all three are in confluence, a bar at the bottom of the chart is colored based on the direction taken. I've found it quite helpful to create directional awareness for the trend of a stock.

Screenshot-2021-02-26-101239.png


. . . and for all the GME traders . . . .

Screenshot-2021-02-26-100738.png


Code:
# Trend Direction Indicator
# Displays trend based on new 1, 3, and 6 month highs or lows
# Pensar - V.1.0 - 02.26.2021 - Initial Release

def H = high(period = AggregationPeriod.Month);
def L = low(period = AggregationPeriod.Month);

plot "6 Month High" = Highest(H, 6);
plot "6 Month Low" = Lowest(L, 6);
plot "3 Month High" = Highest(H, 3);
plot "3 Month Low" = Lowest(L, 3);
plot "1 Month High" = Highest(H, 1);
plot "1 Month Low" = Lowest(L, 1);

def T6 = if close < "6 Month Low"[20] then -1 else if high > "6 Month High"[20] then 1 else T6[1];
def T3 = if close < "3 Month Low"[20] then -1 else if high > "3 Month High"[20] then 1 else T3[1];
def T1 = if close < "1 Month Low"[20] then -1 else if high > "1 Month High"[20] then 1 else T1[1];

"6 Month High".AssignValueColor(if T6 == 1 then Color.cyan else Color.magenta);
"6 Month High".setstyle(curve.short_dash);
"6 Month Low".AssignValueColor(if T6 == 1 then Color.cyan else Color.magenta);
"6 Month Low".setstyle(curve.short_dash);
"3 Month High".AssignValueColor(if T3 == 1 then Color.cyan else Color.magenta);
"3 Month High".setstyle(curve.short_dash);
"3 Month Low".AssignValueColor(if T3 == 1 then Color.cyan else Color.magenta);
"3 Month Low".setstyle(curve.short_dash);
"1 Month High".AssignValueColor(if T1 == 1 then Color.cyan else Color.magenta);
"1 Month High".setstyle(curve.short_dash);
"1 Month Low".AssignValueColor(if T1 == 1 then Color.cyan else Color.magenta);
"1 Month Low".setstyle(curve.short_dash);

plot Trend_Bar = if T1 then LowestAll(low) else double.nan;
Trend_Bar.SetPaintingStrategy(PaintingStrategy.LINE);
Trend_Bar.AssignValueColor(if (T1 == 1 and T3 == 1 and T6 == 1) then Color.cyan
                           else if (T1 == -1 and T3 == -1 and T6 == -1) then Color.magenta
                           else color.gray);
Trend_Bar.SetLineWeight(5);

# end code
 

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