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.
Here is the code:
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: