# Need help to create upper signals

#### zotz

##### New member
Hello all,

Anyone can help me to create upper signals (up/down arrows, etc) whenever the Avg line (Avg = Average(diff, smoothingLength) crosses the Zero line?
I'm not good with coding.

The code/indicator is below.
Btw, it's just the HeikinAshiDiff indicator in ToS.
Thank you!

Code:
``````##########
declare lower;

input smoothingLength = 3;

def haclose = (open + high + low + close) / 4;
def haopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close[1]) / 2);
def diff = haclose - haopen;

plot Avg = Average(diff, smoothingLength);
plot ZeroLine = 0;

Avg.SetDefaultColor(GetColor(8));
ZeroLine.SetDefaultColor(GetColor(5));``````

Code:
``````plot ArrowUp = if Avg crosses above ZeroLine then (Avg - 1) else Double.NaN;
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowUp.SetDefaultColor(Color.CYAN);
ArrowUp.SetLineWeight(2);
ArrowUp.HideBubble();

plot ArrowDn = if Avg crosses below ZeroLine then (Avg + 1) else Double.NaN;
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowDn.SetDefaultColor(Color.YELLOW);
ArrowDn.SetLineWeight(2);
ArrowDn.HideBubble();``````

I used (Avg +1) and (Avg - 1) to move the arrows little ways from the lines.

@mfsteve How do you show this as an upper indicator. I also like to see the arrows at the candle/bars.

@zotz Here you go. I used the up and down arrows provided by @mfsteve

Code:
``````input smoothingLength = 3;

def haclose = (open + high + low + close) / 4;
def haopen = CompoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close[1]) / 2);
def diff = haclose - haopen;

def Avg = Average(diff, smoothingLength);
def ZeroLine = 0;

plot ArrowUp = if Avg crosses above ZeroLine then low else Double.NaN;
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowUp.SetDefaultColor(Color.CYAN);
ArrowUp.SetLineWeight(2);
ArrowUp.HideBubble();

plot ArrowDn = if Avg crosses below ZeroLine then high else Double.NaN;
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowDn.SetDefaultColor(Color.YELLOW);
ArrowDn.SetLineWeight(2);
ArrowDn.HideBubble();``````

87k+ Posts
271 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?