Trouble identifying lowest bar number after variable

greco26

Active member
For some reason I continue to have trouble itenditying the lowest bar number after the variable YZ. I tried 7 different ways. I am trying to isolate only the first pink bubble after the yellow bubble which is what ZZ is supposed to do. Anyone know what Im doing wrong? Thank you as always!


Code:
input LBPeriod = 5;
def BN = barnumber();

def HH = Highest(high, LBPeriod);
def marketHigh1 = if HH > HH[-LBPeriod] then HH else HH[-LBPeriod];
def markedHigh1 = high == marketHigh1;

def lastMarkedHigh1 = CompoundValue(1, if IsNaN( markedHigh1) then lastMarkedHigh1[1] else if markedHigh1 then high else lastMarkedHigh1[1], high);

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

def Resistance1 = lastMarkedHigh1;
def ResistanceBN = if Resistance1 then bn else ResistanceBN[1];
#--------------------------------------------------------------

def LL = Lowest(low, LBPeriod);
#--------------------------------------------------------------
def marketLow1 = if LL < LL[-LBPeriod] then LL else LL[-LBPeriod];
def markedLow1 = low == marketLow1;
def lastMarkedLow1 = CompoundValue(1, if IsNaN(markedLow1) then lastMarkedLow1[1] else if markedLow1 then low else lastMarkedLow1[1], low);

def Support1 = lastMarkedLow1 ;

def stronglow = if Support1 < Support1[1] then low else stronglow[1];
def Prevstronglow = if stronglow != stronglow[1] then stronglow[1] else Prevstronglow[1];

def weaklow = if low > stronglow and Support1 != stronglow then Support1 else weaklow[1];
def prevweaklow = if weaklow != weaklow[1] then weaklow[1] else prevweaklow[1];

def strongHigh = if Resistance1 > Resistance1[1] then high else strongHigh[1];
def prevstronghigh = if strongHigh != strongHigh[1] then strongHigh[1] else prevstronghigh[1];

def weakHigh = if high < strongHigh and Resistance1 != strongHigh then Resistance1 else weakHigh[1];
def prevweakhigh = if weakHigh != weakHigh[1] then weakHigh[1] else prevweakhigh[1];


def peak = high > high[1] and high[-1] < high;
def valley = low < low[1] and low[-1] > low;

def y = if high crosses above stronghigh and peak then bn else y[1];
def yz = highestall(y);
def yy = if bn > yz and valley then bn else yy[1];
def zz = if bn == lowestall(yy) then bn else zz[1];

addchartbubble(bn==y, high,y,color.yellow);
addchartbubble(bn==yy, low,yy,color.pink);
addchartbubble(bn == zz, low,zz,color.magenta);
 

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