# Code to plot CURRENT signal only

#### David45

##### Active member
2019 Donor
Is there a universal code that can be applied to any indicator so that it only plots the current signal/arrow and no historical signals/arrows? Or would the code need to be specific to the indicator? Below is the potion of code I am trying to alter so that it only plots the current signal/arrow but nothing I've tried has worked. I'm just wondering if I am overthinking this and there is a simple way to do this that I am unaware of. Thank you for any insights and assistance!

# calculates and plots the arrows
def EIL = if !IsNaN(EI) and !isUp then pricel else GetValue(EIL, 1);
def EIH = if !IsNaN(EI) and isUp then priceh else GetValue(EIH, 1);
def dir = CompoundValue(1, if EIL != EIL or pricel == EIL and pricel == EISave then 1 else if EIH != EIH or priceh == EIH and priceh == EISave then -1 else dir, 0);
def signal = CompoundValue(1, if dir > 0 and pricel > EIL then if signal <= 0 then 1 else signal else if dir < 0 and priceh < EIH then if signal >= 0 then -1 else signal else signal, 0);
def showarrows = yes;
plot U1 = showarrows and signal > 0 and signal <= 0;
U1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
U1.SetDefaultColor(Color.GREEN);
U1.SetLineWeight(4);
plot D1 = showarrows and signal < 0 and signal >= 0;
D1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
D1.SetDefaultColor(Color.RED);
D1.SetLineWeight(4);

Last edited:
Solution
Is there a universal code that can be applied to any indicator so that it only plots the current signal/arrow and no historical signals/arrows? Or would the code need to be specific to the indicator? Below is the potion of code I am trying to alter so that it only plots the current signal/arrow but nothing I've tried has worked. I'm just wondering if I am overthinking this and there is a simple way to do this that I am unaware of. Thank you for any insights and assistance!

# calculates and plots the arrows
def EIL = if !IsNaN(EI) and !isUp then pricel else GetValue(EIL, 1);
def EIH = if !IsNaN(EI) and isUp then priceh else GetValue(EIH, 1);
def dir = CompoundValue(1, if EIL != EIL or pricel == EIL and pricel == EISave...
Is there a universal code that can be applied to any indicator so that it only plots the current signal/arrow and no historical signals/arrows? Or would the code need to be specific to the indicator? Below is the potion of code I am trying to alter so that it only plots the current signal/arrow but nothing I've tried has worked. I'm just wondering if I am overthinking this and there is a simple way to do this that I am unaware of. Thank you for any insights and assistance!

# calculates and plots the arrows
def EIL = if !IsNaN(EI) and !isUp then pricel else GetValue(EIL, 1);
def EIH = if !IsNaN(EI) and isUp then priceh else GetValue(EIH, 1);
def dir = CompoundValue(1, if EIL != EIL or pricel == EIL and pricel == EISave then 1 else if EIH != EIH or priceh == EIH and priceh == EISave then -1 else dir, 0);
def signal = CompoundValue(1, if dir > 0 and pricel > EIL then if signal <= 0 then 1 else signal else if dir < 0 and priceh < EIH then if signal >= 0 then -1 else signal else signal, 0);
def showarrows = yes;
plot U1 = showarrows and signal > 0 and signal <= 0;
U1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
U1.SetDefaultColor(Color.GREEN);
U1.SetLineWeight(4);
plot D1 = showarrows and signal < 0 and signal >= 0;
D1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
D1.SetDefaultColor(Color.RED);
D1.SetLineWeight(4);
Figured it out! I used some code that SleepyZ helped me with for another indicator and it worked on this one too! So Kudos to SleepyZ!

input Count = 1;
def cond = if signal > 0 and signal <= 0 or
signal < 0 and signal >= 0
then 1
else 0 ;
def dataCount = CompoundValue(1, if cond then dataCount + 1 else dataCount, 0);
def limitplot = HighestAll(dataCount) - dataCount <= Count - 1;
#-------------------------------------------------------------------------------

input showarrows = yes;
plot U1 = showarrows and signal > 0 and signal <= 0 and limitplot;
U1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
U1.SetDefaultColor(Color.GREEN);
U1.SetLineWeight(4);
plot D1 = showarrows and signal < 0 and signal >= 0 and limitplot;
D1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
D1.SetDefaultColor(Color.RED);
D1.SetLineWeight(4);

• wtf_dude

### Not the exact question you're looking for?

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