Repaints AGAIG High Low - Peak Valleys For ThinkOrSwim

Repaints

csricksdds

Trader Educator
VIP
This indicator combines my HighLow Indicator with Robert Paynes Modified Peaks Valleys Indicator. What we are looking for is an arrow within an arrow that is dual colored White/Red or White/Green. I only place trades when both arrows show within each other...as a rule I don't trade the individual Red/Green arrows by themselves unless my AsGoodAsItGets_ArrowsOnly is also indicating direction change as well. This indicator does repaint so use it in conjunction with others as well. I have included a picture.

q7rxhDU.png

Here is the code:

Ruby:
##AsGood-HiLo-PeaksValleys-Arrows indicator 3/26/24
# find peaks and valleys
# https://usethinkscript.com/threads/...y-demand-zones-for-thinkorswim.172/#post-7048
# robert payne code
#Modified by C. Ricks 2/21/24

def na = double.nan;
def bn = BarNumber();
def lastbn = highestall(if isnan(close) then 0 else bn);
def lastcls = if lastbn then close else lastcls[1];
#def lastbar = (!isnan(close) and isnan(close[-1]));

input show_peak_valley_arrows = yes;
def spva = show_peak_valley_arrows;

input len = 10;
def offset = Min(len - 1, lastbn - bn);
#def swingLow = low < Lowest(low[1], len - 1) and low == GetValue(Lowest(low, len), -offset);

#--------------------------
#valley section
#def Valley = low < Lowest(low[1], len) and low < Lowest(low[-len], len);
def valley = low < Lowest(low[1], len - 1) and low == GetValue(Lowest(low, len), -offset);
def valley_pr = if valley then low else na;

plot ArrowUP = if spva then Valley else na;
ArrowUP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
ArrowUP.SetDefaultColor(Color.Green);
ArrowUP.SetLineWeight(3);

#---------------------------
#peak section
#def Peak = high > highest(high[1], len) and high > highest(high[-len], len);
def peak = high > highest(high[1], len - 1) and high == GetValue(highest(high, len), -offset);
def peak_pr = if peak then high else na;

plot ArrowDN = if spva then Peak else na;
ArrowDN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
ArrowDN.SetDefaultColor(Color.RED);
ArrowDN.SetLineWeight(3);

# -------------------------

##AsGood-HighLowPivot-Arrows

input length = 13;
def lastBar = HighestAll(if IsNaN(close) then 0 else bn);

input ignore_last_bar = yes;
def ignorelast = if (ignore_last_bar and bn == lastbar) then 0 else 1;

def HighPoint = ignorelast and high > highest(high[1], length - 1) and high == GetValue(highest(high, length), -offset);
def Lowpoint = ignorelast and low < Lowest(low[1], length - 1) and low == GetValue(Lowest(low, length), -offset);

input show_Arrows_on_Highpoints_Lowpoints = yes;
def vert = 0.001;

def prange = highPoint – lowPoint;
def plotHighest = highpoint + prange * .3;
def plotLowest = lowpoint - prange * 3.0;

plot BuyCriteria = if LowPoint then Low else double.NaN ;
plot SellCriteria = if HighPoint then High else double.NaN ;

BuyCriteria.SetPaintingStrategy(PaintingStrategy.ARROW_UP) ;
BuyCriteria.SetDefaultColor(color.WHITE);
BuyCriteria.SetLineWeight(5);
SellCriteria.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN) ;
SellCriteria.SetDefaultColor(color.WHITE);
SellCriteria.SetLineWeight(5);

input usealerts = yes;
alert(usealerts and SellCriteria[1] == 1, "Short", alert.bar, sound.ring);
alert(usealerts and BuyCriteria[1] == 1, "Long", alert.bar, sound.ring);

#End Code
 
Last edited by a moderator:

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