I am trying to create a script that counts stock chart candles that are above or below a certain value.
specifically, I want my script to sequentially count candles once they are above the 9 simple moving average. When the candle eventually closes below the 9 sma, I want those to be counted also
my current script isnt perfect and occasionally give repeating numbers
plot(close)
indicator("Candle Count", overlay=true)
// Source for SMA calculation
source = close
// Calculate the 9-period SMA
sma9 = [login to view URL](source, 9)
// Variables for counters and tracking state
var int aboveCount = 0
var int belowCount = 0
var bool isAboveSMA = false
var bool isBelowSMA = false
// Check if the body of the candle (open and close) is above or below SMA and handle counting
if close > sma9 and open > sma9 // Both open and close above SMA
if not isAboveSMA
isAboveSMA := true
isBelowSMA := false
aboveCount := 1 // Reset to 1 when we start a new count above SMA
else
aboveCount := aboveCount + 1 // Increment if we're already counting above SMA
belowCount := 0 // Reset below count
else if close < sma9 and open < sma9 // Both open and close below SMA
if not isBelowSMA
isBelowSMA := true
isAboveSMA := false
belowCount := 1 // Reset to 1 when we start a new count below SMA
else
belowCount := belowCount + 1 // Increment if we're already counting below SMA
aboveCount := 0 // Reset above count
// Plot the 9 SMA for reference
plot(sma9, color=[login to view URL], linewidth=2, title="9 SMA")
// Label each candle above the high with slight offset, using brilliant white text
if isAboveSMA
[login to view URL](bar_index, high + (high * 0.001), text=[login to view URL](aboveCount), color=[login to view URL]([login to view URL], 80), textcolor=[login to view URL], style=label.style_none)
else if isBelowSMA
[login to view URL](bar_index, high + (high * 0.001), text=[login to view URL](belowCount), color=[login to view URL]([login to view URL], 80), textcolor=[login to view URL], style=label.style_none)
Please check my past work, coding ability and reviews on my portfolio.
I offer a range of Pine Script services:
Creating Custom Indicators
Debugging Pine Script Code
Combining Existing Indicators
Updating Existing Indicators
Generating Trading Signals
Creating Custom Alerts
Building Custom Screeners
Plotting Custom Visualization
Developing Backtesting Systems
Implementing Risk Management
Creating Trading Systems
I have tested the indicator and seen the problem, and I can fix it.
I am a professional coder in the development of Bots and Indicators and Scripts for TradingView and MT4/MT5, and I already did similar projects to this job successfully.
Please let us talk about the details of the job, so that we can do this job as you expect.
***The bid is negotiable
Hi!
I’m a SWING Trader specializing in trading platforms and Trading and Pine Script, with extensive experience in creating custom indicators and strategies using machine learning. I work closely with my clients to understand their specific needs and translate them into effective and innovative solutions.
Additionally, I offer free post-sale support to ensure my clients can maximize the value of the implemented solutions. I’d be happy to ask you a few questions to better understand your needs and how I can assist you.
Feel free to reach out!
I will do the project by refining the existing script to accurately count candles above or below the 9-period Simple Moving Average (SMA). I will ensure the count resets when transitioning between the two states and eliminate any repetition, allowing for a correct sequential count of candles based on their position relative to the SMA.
Hi,
I will program tradingview pinescript as per requirements
I can create/modify/automate any tradingview script or strategy in pinescript.
Provided in this :
Automate strategy/bot with any platform or broker.
Tradingview script to Strategy.
Combining multiple Tradingview script/strategies.
Creating accurate Alerts
Backtesting/Improving any strategy result
Target ,Stop loss, trailing stop-loss, multiple tar in points, percentage or pips.
Update pinescript //@version
Remove errors from existing pinescript.
Hey,
As a professional trader and a Pinescript developer with more than 5 years of experience, this task seems straightforward for me and I can complete it within a few minutes. Please reach out to discuss further.
Sincerely,
BAGGAR Nassim
Greetings,
I hope this proposal finds you in excellent health. Welcome to my profile, Home to Professional and Quality services with 100% customer satisfaction guarantee.
I'm a Certified & Experienced Expert.
Dear Client, Good evening. I take this opportunity to inform you that i have KEENLY gone through your project, clearly understood all your project requirements as given in your project description and I confirm to you that i can perfectly deliver as instructed. Being in possession of all CLEARLY STATED required project skills as this is my area of professional specialization having completed similar softwares and developed adequate experience in the same area, I hereby humbly request you to consider my bid for Professional, Quality and Affordable services always.
I guarantee and assure you that with me you will receive;
*AFFORDABLE & QUALITY SERVICES
*STRICT TIMELY DELIVERY & UNLIMITED REVISIONS.
Kindly Message Me We Discuss More About The Project and seal the contract.
Welcome and Thank-you.
Hi there,Good morning I am Mudassar. I have read you project details i saw you need help with Pine Script and Trading
I am pleased to present my proposal, highlighting our extensive experience and proven track record in delivering exceptional results. Our portfolio of success will showcase past projects that demonstrate our ability to meet and exceed client expectations. Glowing testimonials from satisfied clients will attest to our professionalism, dedication, and the quality of our work
Please note that the initial bid is an estimate, and the final quote will be provided after a thorough discussion of the project requirements or upon reviewing any detailed documentation you can share.
Could you please share any available detailed documentation? I'm also open to further discussions to explore specific aspects of the project. Thanks
Regards.
TechFusion
I propose refining the existing script to correctly track and count stock chart candles above or below the 9-period Simple Moving Average (SMA). By ensuring that the counts reset when transitioning between the two states and eliminating repetition, the script will reliably count and display the number of candles in each state (above or below the SMA).
I can help you develop a Pine Script v6 script that meets your requirements. The script will plot SMA(20), EMA(5), and EMA(25) with the specified colors. It will generate upward arrows based on your defined conditions and send pop-up alerts accordingly. I have experience in developing Pine Script indicators and ensuring accurate implementation of trading logic. I will deliver a well-documented and efficient script that meets your needs.