Need some pointers on programming a pivot indicator

tsnewb

New member
Beginner here. I've got an attempt at the bottom here, but I'm starting at part 2, just to get an arrow to print at the bottom of a pivot and already having issues. They do print correctly on some candles, but not on all candles that they should be on, and they also print on candles they shouldn't.


## 1. establish downtrend or uptrend
## if current pivot low is lower than prior pivot low
## then do the following for a downtrend pullback

## 2. for the first pivot high marked with a red 0
# if low of bar is lower than prior bar's low
# and high of bar is higher than prior bar's high
# then mark with a bubble with numeral 0


## 3. for the low pivot currently marked with a green 0
# if low of bar is lower than prior bars low
# and high of bar is lower than high of prior bars
# and it becomes a pivot low
# then mark with a bubble with numeral 0

## 4. for the pivot high currently marked with a red 1
# if high of bar is higher than prior bars high
# and low of bar is higher than low of prior bars
# and it becomes a pivot high
# then mark with a bubble with numeral 1

## 5. for the pivot low higher currently marked with a green 1
# if low of bar is lower than prior bars low
# and high of bar is lower than high of prior bars
# and it becomes a pivot low
# then mark with a bubble with the numeral 1

## 6. for the last pivot high currently marked with a red 0
# if high of bar is higher than prior bars high
# and low of bar is higher than low of prior bars
# and it becomes a pivot high
# then mark with a bubble with numeral 0


Here's where I'm at:
#pullback 1.2
## for the low pivot currently marked with a green 0
# if low of bar is lower than prior bars low
# and high of bar is lower than high of prior bars
# and it becomes a pivot low
# then mark with an up arrow
def downleg_first_entry = low < low[1] and high[0] < low[2] and high[1];
plot digit_0 = if downleg_first_entry then high else double.nan;
digit_0.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
digit_0.SetLineWeight(3);
digit_0.SetDefaultColor(color.RED);
digit_0.HideBubble();
digit_0.HideTitle();


Here's what I'm trying to replicate:
WdvhqbT.jpg


Here's where I'm at now:
OrkDUPy.jpg
 
@tsnewb Pivot and Trend Reversal indicators can be tricky... My suggestion would be to decipher (reverse engineer) several of the many pivot and reversal studies here in these forums... For a true trend reversal indicator, like ZigZagHighLow, recursion is required - along with ample conditional logic... You need to store and recall the higher high and lower low status... And yet another method is to use Fractal Patterns like the TOS ZigZagStepPattern Pattern...
 

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