Put beginning & ending arrow when signal occurs and ends

ChiliPepper

New member
I've been trying to figure out how to put 1 single arrow when the signal occur and 1 arrow when the signal ends and no arrows in between, but I've having a hard time doing it. Can some one help? I tried using the BOOLEAN_ARROW_UP but it puts in a continuous row of arrows when the signal occurs for more than 1 candle. I've included a screen shot of what I want to do.

This code uses John Carter's Squeeze technique.

Rgs6vVO.jpg


Code:
def EMA8 = ExpAverage(close, 8);
def EMA21 = ExpAverage(close, 21);

def bullish = if EMA8 > EMA21 then 1 else 0;
def squeeze = if TTM_Squeeze().SqueezeAlert >= 0 then 1 else 0;
def histSignal = if TTM_Squeeze().Histogram[0] > TTM_Squeeze().Histogram[1] then 1 else 0;
def greaterVol = VolumeAvg().Vol > VolumeAvg().VolAvg and close > close[1];
def wave = if TTM_Wave().Wave2High[0] > TTM_Wave().Wave2High[1] and TTM_Wave().Wave2Low[0] > TTM_Wave().Wave2Low[1] then 1 else 0;

def conditions = bullish and squeeze and histSignal and wave;
plot signal = conditions[1];
signal.SetDefaultColor(Color.WHITE);
signal.SetLineWeight(2);
 
Last edited by a moderator:
@ChiliPepper Replace the plot in your code with this and add the desired color code lines. I included a couple notes.

Code:
# Using the exclamation point in front of a variable means "is not true". Saying "!conditions[1]" means that I want the conditions to be not true on the previous bar (finds the beginning or end of the conditions).
# the "low" and "high" assigns where you want the regular arrows to plot.
plot signal1 = if !conditions[1] and conditions then low else double.nan; # first arrow
     signal1.setpaintingstrategy(paintingstrategy.arrow_up);
plot signal2 = if conditions[1] and !conditions then high else double.nan; #second arrow
     signal2.setpaintingstrategy(paintingstrategy.arrow_down);

Here is similar way that returns the same as the above snippet, but this time using boolean arrows.

Code:
plot signal1 = !conditions[1] and conditions; # first arrow
     signal1.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
plot signal2 = conditions[1] and !conditions; # second arrow
     signal2.setpaintingstrategy(paintingstrategy.boolean_arrow_down);
 

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