How to remove redundant signals

RegularRob

New member
Hi, I get multiple signals that clutter up my chart with arrows. What is the best way to only plot one arrow if conditions are met?

Code:
plot signal = if positive5 and oktobuy and positive and arrows
then 2
else 0;

plot signal2 = if negative5 and oktoshort and negative and arrows
then 1
else 0;

Alert(alert and signal == 2, "Ok_to_Buy", Alert.bar, Sound.Ding);
signal.SetDefaultColor(Color.violet);
signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signal.setLineWeight (1);

Alert( alert and signal2 ==1, "Ok_to_Short", Alert.bar, Sound.Ding);
signal2.SetDefaultColor(Color.violet);
signal2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
signal2.setLineWeight (1);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Code:
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input macdAverageType = AverageType.EXPONENTIAL;
input Period = aggregationPeriod.five_MIN;
input arrows = yes;
input alert= yes;

plot ema5 = MovingAverage(averageType.EXPONENTIAL, close(period = period), 200);
ema5.setdefaultcolor(color.white);
def value5 = MovingAverage(macdAverageType, close(period = period), fastLength) - MovingAverage(macdAverageType, close(period = period), slowLength);
def average5 = MovingAverage(macdAverageType, value5, macdLength);

Def positive5 = average5 is less than or equal to MACD()."ZeroLine" and close(period = period) is greater than ema5;
Def negative5 = average5 is greater than or equal to MACD()."ZeroLine" and close(period = period) is less than ema5;

def positive =  MACD()."Avg"  is less than MACD()."ZeroLine";
Def negative =MACD()."avg" is Greater than MACD()."ZeroLine";

def oktobuy = TTM_Wave()."Wave2High" is greater than or equal to TTM_Wave()."Wave2High" from 1 bars ago and TTM_Squeeze()."Histogram" is greater than or equal to TTM_Squeeze()."Histogram" from 1 bars ago;
def oktoshort = TTM_Wave()."Wave2High"  is less than or equal to TTM_Wave()."Wave2High" from 1 bars ago and TTM_Squeeze()."Histogram" is less than or equal to TTM_Squeeze()."Histogram" from 1 bars ago;

plot signal = if positive5 and oktobuy and positive and arrows
then 2
else 0;

plot signal2 = if negative5 and oktoshort and negative and arrows
then 1
else 0;

Alert(alert and signal == 2, "Ok_to_Buy", Alert.bar, Sound.Ding);
signal.SetDefaultColor(Color.violet);
signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
signal.setLineWeight (1);

Alert( alert and signal2 ==1, "Ok_to_Short", Alert.bar, Sound.Ding);
signal2.SetDefaultColor(Color.violet);
signal2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
signal2.setLineWeight (1);
 
@RegularRob Here you go, try this:

Code:
input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input macdAverageType = AverageType.EXPONENTIAL;
input Period = aggregationPeriod.five_MIN;
input arrows = yes;
input alert= yes;

plot ema5 = MovingAverage(averageType.EXPONENTIAL, close(period = period), 200);
ema5.setdefaultcolor(color.white);
def value5 = MovingAverage(macdAverageType, close(period = period), fastLength) - MovingAverage(macdAverageType, close(period = period), slowLength);
def average5 = MovingAverage(macdAverageType, value5, macdLength);

Def positive5 = average5 is less than or equal to MACD()."ZeroLine" and close(period = period) is greater than ema5;
Def negative5 = average5 is greater than or equal to MACD()."ZeroLine" and close(period = period) is less than ema5;

def positive =  MACD()."Avg"  is less than MACD()."ZeroLine";
Def negative =MACD()."avg" is Greater than MACD()."ZeroLine";

def oktobuy = TTM_Wave()."Wave2High" is greater than or equal to TTM_Wave()."Wave2High" from 1 bars ago and TTM_Squeeze()."Histogram" is greater than or equal to TTM_Squeeze()."Histogram" from 1 bars ago;
def oktoshort = TTM_Wave()."Wave2High"  is less than or equal to TTM_Wave()."Wave2High" from 1 bars ago and TTM_Squeeze()."Histogram" is less than or equal to TTM_Squeeze()."Histogram" from 1 bars ago;

def signal = if positive5 and oktobuy and positive and arrows
then 2
else 0;

def signal2 = if negative5 and oktoshort and negative and arrows
then 1
else 0;

plot arrow = signal and signal[1] is false;
plot arrow2 = signal2 and signal2[1] is false;


Alert(alert and signal == 2, "Ok_to_Buy", Alert.bar, Sound.Ding);
arrow.SetDefaultColor(Color.violet);
arrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
arrow.setLineWeight(1);

Alert( alert and signal2 ==1, "Ok_to_Short", Alert.bar, Sound.Ding);
arrow2.SetDefaultColor(Color.violet);
arrow2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_Down);
arrow2.setLineWeight(1);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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