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.
 

BenTen

Administrative
Staff
VIP
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.
 

horserider

Well-known member
VIP
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]
 

codydog

Active member
@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();
 

OBW

Member
@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);
 

zeek

Active member
2019 Donor
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);
 

Similar threads

Top