Resource icon

thinkScript boolean arrows in ThinkOrSwim

The term Boolean means a result that can only have one of two possible values: true or false.
In ThinkOrSwim, boolean arrows are used on the upper chart.

.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
plots an up arrow on the low of the candle
https://tlc.thinkorswim.com/center/...ingStrategy/PaintingStrategy-BOOLEAN-ARROW-UP

.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
plots a down arrow on the high of the candle
https://tlc.thinkorswim.com/center/...gStrategy/PaintingStrategy-BOOLEAN-ARROW-DOWN

Usage

Code:
def condition = close > open ;
plot example1 = !condition[1] and condition ;
 example1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

plot example2 = condition[1] and !condition ;
example2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
The above script plots an arrow on the first occurrence of a condition being true or not true
plots an up arrow where
close is not > open on the previous bar[1] and close is > open on the current bar.
plots a down arrow where
close > open on the previous bar[1] and close is not > open on the current bar.

Helpful Hint:

if you find yourself adding arrows to your scripts on a regular basis, keep a copy of this script in your study tab:
Code:
 #Add Arrows to Any Script
def UPcondition = close ;
def DNcondition = close ;
plot upArrow = !UPcondition[1] and UPcondition;
upArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
upArrow.SetDefaultColor(color.cyan) ;
upArrow.SetLineWeight(1);

plot dnArrow = !DNcondition[1] and DNcondition;
dnArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
dnArrow.SetDefaultColor(color.magenta) ;
dnArrow.SetLineWeight(1);
Simply change the def condition to equal whatever condition you want to plot the arrow on; to make this snippet work on all your scripts.

Other Examples

thinkScript can also plot wedges or dots (points) in place of arrows
Code:
#
# TD Ameritrade IP Company, Inc. (c) 2018-2023
#

input adxLength = 10;
input macdFastLength = 12;
input macdSlowLength = 26;
input paintBars = yes;

def adx = reference ADX(length = adxLength);
def macd = reference MACD("fast length" = macdFastLength, "slow length" = macdSlowLength);

plot CAM_UP = adx >= adx[1] and macd > macd[1];
plot CAM_PB = adx <= adx[1] and macd < macd[1];
plot CAM_DN = adx >= adx[1] and macd < macd[1];
plot CAM_CT = adx <= adx[1] and macd > macd[1];

CAM_UP.SetDefaultColor(Color.GREEN);
CAM_UP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
CAM_UP.SetLineWeight(3);
CAM_UP.hide();
CAM_PB.SetDefaultColor(Color.YELLOW);
CAM_PB.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
CAM_PB.SetLineWeight(3);
CAM_PB.hide();
CAM_DN.SetDefaultColor(Color.RED);
CAM_DN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
CAM_DN.SetLineWeight(3);
CAM_DN.hide();
CAM_CT.SetDefaultColor(Color.BLUE);
CAM_CT.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
CAM_CT.SetLineWeight(3);
CAM_CT.hide();

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_PB", Color.YELLOW);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_CT", Color.BLUE);

AssignPriceColor(if !paintBars then Color.CURRENT
else if CAM_UP then GlobalColor("CAM_UP")
else if CAM_PB then GlobalColor("CAM_PB")
else if CAM_DN then GlobalColor("CAM_DN")
else if CAM_CT then GlobalColor("CAM_CT")
else Color.Current);

And more examples:
https://usethinkscript.com/threads/safe-hull-moving-average-indicator-for-thinkorswim.5/#post-131601
https://usethinkscript.com/threads/...-when-signal-occurs-and-ends.3438/#post-31886
https://usethinkscript.com/threads/...ndle-based-on-breadth-open.15264/#post-124137
https://usethinkscript.com/threads/an-arrow-after-close-above-the-previous-high.14871/#post-122945
  • Like
Reactions: pjcar and SethW446
Author
MerryDay
Views
4,231
First release
Last update
Rating
0.00 star(s) 0 ratings

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