Stack two arrows instead of overlaying them?

RickK

Active member
Anyone, is there a way to keep the signal arrows from laying over the top of one another? I seem to remember a script from a long time ago that had one down arrow just above the candle (lets say red) and another down arrow (white) just above the red candle.
 
Solution
@RickKennedy

Thinkscript has two types of arrow painting strategies—Boolean arrows and regular arrows. The Boolean arrows can only be set at the high / low of the candle. The regular arrows can be plotted wherever one wants them. You can learn more about the different types of painting strategies here: https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/PaintingStrategy

With that in mind, here is an example code that will offset the cyan arrow only when both cond1 and cond2 are true at the same time.

ZG1Fat5.png


Code:
# +------------------------------------------------------------+
# |       Example code to dynamically offset arrow plots       |
# |                        Robert Payne                        |...
Don't know if that is possible, but there are alternatives. You can change the background of the candle color or display the arrows as a lower study.
 
Just winging it as I cannot locate study where I had this.
So try playing with it and see if can get it to work.

Def offset = x;
plot x = xyz - offset;
plot y = xyz2 - 2 * offset;

or maybe

def offset = x;
plot x = xyz [offset]
 
@RickKennedy - try this, you can fuss with it to do what you want exactly

input z = 2.51;
input offset = 5;
plot hiz = if zscore > z then high + offset * ticksize() else double.nan;
plot lowz = if zscore < -z then low - offset * ticksize() else double.nan;
hiz.assignvaluecolor(color.red);
lowz.assignvaluecolor(color.blue);
hiz.SetPaintingStrategy(PaintingStrategy.POINTS);
lowz.SetPaintingStrategy(PaintingStrategy.POINTS);
hiz.setlineweight(4);
lowz.setlineweight(4);
hiz.hidebubble();
lowz.hidebubble();
 
@RickKennedy

Thinkscript has two types of arrow painting strategies—Boolean arrows and regular arrows. The Boolean arrows can only be set at the high / low of the candle. The regular arrows can be plotted wherever one wants them. You can learn more about the different types of painting strategies here: https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/PaintingStrategy

With that in mind, here is an example code that will offset the cyan arrow only when both cond1 and cond2 are true at the same time.

ZG1Fat5.png


Code:
# +------------------------------------------------------------+
# |       Example code to dynamically offset arrow plots       |
# |                        Robert Payne                        |
# |               https://funwiththinkscript.com               |
# +------------------------------------------------------------+
def cond1 = high == Highest(high, 13) and high == GetValue(Highest(high, 13), -12);
def cond2 = high == Highest(high, 5) and high == GetValue(Highest(high, 5), -4);

def avgRng = Average(high - low, 21) / 3;
def offset = if cond1 and cond2 then avgRng * 2 else 0;

plot arrow1 = if cond1 then high else Double.NaN;
arrow1.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
arrow1.SetDefaultColor(Color.LIME);
arrow1.SetLineWeight(5);
plot arrow2 = if cond2 then high + offset else Double.NaN;
arrow2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
arrow2.SetDefaultColor(Color.CYAN);
arrow2.SetLineWeight(5);
 
Solution
I currently have two studies that both plots down/up arrows and was wondering if it`s possible to use an offset on one of the studies so that the arrows doesn't overlay each other. The arrow plots for each study can be seen below,

study1
Code:
plot pUP = major == 1;
pUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
pUP.SetDefaultColor(Color.GREEN);
pUP.SetLineWeight(2);

plot pDown = major == -1;
pDown.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
pDown.SetDefaultColor(Color.RED);
pDown.SetLineWeight(2);

study 2
Code:
# Arrows below based on the following
#AddChartBubble(ConditionUp4 && ConditionUp5, Volume, concat("Buy @ $", Close), Color.Green, Yes);
#AddChartBubble(ConditionUp1 && ConditionUp2 && ConditionUp3, Volume, concat("Buy @ $", Close), Color.Green, Yes);
#AddChartBubble(ConditionDown1 && ConditionDown4 && ConditionDown5, Volume, concat("Sell @ $", Close), Color.Red, Yes);
#AddChartBubble(ConditionDown1 && ConditionDown2 && ConditionDown3,  Volume, concat("Sell @ $", Close), Color.Red, Yes);

# buy and sell signals

def Buy45 = ConditionUp4 && ConditionUp5;
plot bullish45 = Buy45;
bullish45.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullish45.SetDefaultColor(Color.CYAN);
bullish45.SetLineWeight(3);

def Buy123 = ConditionUp1 && ConditionUp2 && ConditionUp3;
plot bullish123 = Buy123;
bullish123.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullish123.SetDefaultColor(Color.CYAN);
bullish123.SetLineWeight(3);

def Bearish145i = ConditionDown1 && ConditionDown4 && ConditionDown5;
plot bearish145 = Bearish145i;
bearish145.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearish145.SetDefaultColor(Color.CYAN);
bearish145.SetLineWeight(3);

def Bearish123i = ConditionDown1 && ConditionDown2 && ConditionDown3;
plot bearish123 = Bearish123i;
bearish123.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearish123.SetDefaultColor(Color.CYAN);
bearish123.SetLineWeight(3);
 
@zeek the arrow offset code in post#8 should work for you.

Yes @zeek , the thing that helped me the most was knowing that I couldn't do anything with boolean arrow up/down. It had to be the numeric one. Also, when I finally used it, I had to set the arrow offset as an input that could be modified for every chart because the distance from the candle on a /CL chart was different than a /GC or a /RTY chart. Below is an example how I've used it:

Code:
#...this script seems to provide better fractal signals than the other script
# added alarms for buy/sell fractal signals - RickK 2021/09/08

### define inputs
input price = close;
input audioalarm = yes;
input arrow_offset = .06;  #might need to be modified for every instrument's charts

### define a Buy Fractal setup
def buy_fractal_setup_is_true = high[2] < high[1];
def buy_fractal_peak_is_true = high > high[1] && high > high[-1];
def buy_fractal_confirm_is_true = high[-1] > high[-2];

### define a Sell Fractal setup
def sell_fractal_setup_is_true = low[2] > low[1];
def sell_fractal_peak_is_true = low < low[1] && low < low[-1];
def sell_fractal_confirm_is_true = low[-1] < low[-2];

### plot details (for some reason the original coder set "buy" with a down arrow
#   above the candle and the "sell" is a Up arrow below the candle.  I just left
# that way)
plot buy_fractal = if buy_fractal_setup_is_true and buy_fractal_peak_is_true and buy_fractal_confirm_is_true then price + arrow_offset else double.NaN;
buy_fractal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
buy_fractal.SetDefaultColor(Color.magenta);

plot sell_fractal = if sell_fractal_setup_is_true and sell_fractal_peak_is_true and sell_fractal_confirm_is_true then close - arrow_offset  else double.NaN;
sell_fractal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
sell_fractal.SetDefaultColor(Color.cyan);

### alarms

alert (audioalarm and buy_fractal, "!..BUY..!", alert.bar, sound.DING);

alert (audioalarm and sell_fractal, "!..SELL..!", alert.bar, sound.ding);
#end
 

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