Need some code help

rengagopal

Member
VIP
I try to get a bubble with candle count when Hull(close,15) > hull(close,15)[1] at end of the Up run. not for every minute. I have used the following logic and getting the bubble in every candle. Please help.

plot Hull15 = HullMovingAvg(Close, 15);
def cntL = if Hull15 <= Hull15[1] then cntL[1] + 1 else cntL[1]; ########## to find the Begining of the Hull15 downtrend.
def cnt = if cntL == 1 and Hull15[1] > Hull15[2] then cnt[1] + 1 else cnt[1]; ######## If Downtrend has started check the previous candles till the Up trend is false.
addchartbubble(cnt > 0 , max(open,close) * 1.0005,cnt + " " + cntl,color.Yellow);
 
Solution
I try to get a bubble with candle count when Hull(close,15) > hull(close,15)[1] at end of the Up run. not for every minute. I have used the following logic and getting the bubble in every candle. Please help.

plot Hull15 = HullMovingAvg(Close, 15);
def cntL = if Hull15 <= Hull15[1] then cntL[1] + 1 else cntL[1]; ########## to find the Begining of the Hull15 downtrend.
def cnt = if cntL == 1 and Hull15[1] > Hull15[2] then cnt[1] + 1 else cnt[1]; ######## If Downtrend has started check the previous candles till the Up trend is false.
addchartbubble(cnt > 0 , max(open,close) * 1.0005,cnt + " " + cntl,color.Yellow);

See if this helps. It resets the count to zero when the Hull15 < Hull15[1] is no longer true. Then the...
I try to get a bubble with candle count when Hull(close,15) > hull(close,15)[1] at end of the Up run. not for every minute. I have used the following logic and getting the bubble in every candle. Please help.

plot Hull15 = HullMovingAvg(Close, 15);
def cntL = if Hull15 <= Hull15[1] then cntL[1] + 1 else cntL[1]; ########## to find the Begining of the Hull15 downtrend.
def cnt = if cntL == 1 and Hull15[1] > Hull15[2] then cnt[1] + 1 else cnt[1]; ######## If Downtrend has started check the previous candles till the Up trend is false.
addchartbubble(cnt > 0 , max(open,close) * 1.0005,cnt + " " + cntl,color.Yellow);

See if this helps. It resets the count to zero when the Hull15 < Hull15[1] is no longer true. Then the bubble for the last count can be isolated as in the first part of the code's addchartbubble(cntl[-1]==0 and cntl>0

Thank you for providing your code. You did nice work and were very close to what you wanted.

Capture.jpg
Ruby:
plot Hull15 = HullMovingAvg(Close, 15);
def cntL = if Hull15 <= Hull15[1] then cntL[1] + 1 else if hull15>hull15[1] then 0 else cntL[1]; ########## to find the Begining of the Hull15 downtrend.
def cnt = if cntL == 1 and Hull15[1] > Hull15[2] then cnt[1] + 1 else cnt[1]; ######## If Downtrend has started check the previous candles till the Up trend is false.
addchartbubble(cntl[-1]==0 and cntl>0, max(open,close) * 1.0005,cnt + " " + cntl,color.Yellow);
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

See if this helps. It resets the count to zero when the Hull15 < Hull15[1] is no longer true. Then the bubble for the last count can be isolated as in the first part of the code's addchartbubble(cntl[-1]==0 and cntl>0

Thank you for providing your code. You did nice work and were very close to what you wanted.
Thank you!!

My output is little different from yours. Don't know why. I will insert the image tomorrow. I have to find out how to insert the picture from my desktop.
 
See if this helps. It resets the count to zero when the Hull15 < Hull15[1] is no longer true. Then the bubble for the last count can be isolated as in the first part of the code's addchartbubble(cntl[-1]==0 and cntl>0

Thank you for providing your code. You did nice work and were very close to what you wanted.
Here is the image.


 
Last edited by a moderator:
Thank you!!

My output is little different from yours. Don't know why. I will insert the image tomorrow. I have to find out how to insert the picture from my desktop.
I cannot tell from the images what chart settings you are using and would need your code to make a comparison.

Here is some color of the HMA and the basis of the count from def cntl showing in the bubbles that may help.

Capture.jpg
Ruby:
plot Hull15 = HullMovingAvg(Close, 15);
Hull15.assignvalueColor(if Hull15 <= Hull15[1] then color.red else color.yellow);
def cntL = if Hull15 <= Hull15[1] then cntL[1] + 1 else if hull15>hull15[1] then 0 else cntL[1]; ########## to find the Begining of the Hull15 downtrend.
def cnt = if cntL == 1 and Hull15[1] > Hull15[2] then cnt[1] + 1 else cnt[1]; ######## If Downtrend has started check the previous candles till the Up trend is false.
addchartbubble(cntl>0, max(open,close) * 1.0005, cntl,color.Yellow);
addchartbubble(cntl[-1]==0 and cntl>0, max(open,close) * 1.0005,cnt + " " + cntl,color.Yellow);
 
I cannot tell from the images what chart settings you are using and would need your code to make a comparison.

Here is some color of the HMA and the basis of the count from def cntl showing in the bubbles that may help.
Thank you!! My bad. I missed to notice the same results in your previous image. I got it. Thank you again!!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
301 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