Ignore current incomplete candle

redart1021

New member
Hi I'm making an indicator that highlights very low volume candlesticks. However I'd prefer to not highlight the current unfinished candle. How do I exclude this candle in my calculation? Right now the main code looks like this:

Code:
def LoVol = volume<volume[1] and volume<volume[2] and volume<volume[3] and volume<volume[4] and volume<volume[5] and volume<volume[6] and volume<volume[7] and volume<volume[8] and volume<volume[9] and volume<volume[10];

Thanks
 

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

i dont know what your trying to do, but your current code in the original post is pretty much saying
the current volume is less than the volume of all of the last 10 volume bars.
considering market is closed, the odds of finding that right now would be slim because the last volume candle is normally one of the biggest volume candies of the day so it wouldnt surprise me if its returning 0 results.
 
Here it is, its pretty simple but you need to account for the Expansion Area to the right, which is found in Chart Settings -> Time Axis.
I would just set it to zero, so you don't have to worry about scrolling as new bars are formed or inputting it but up to you :)
Code:
def BN = BarNumber();
input Expansion_Area = 0;
def Current_Bar_Number = if !isNaN(close) then highestAll(BN)-Expansion_Area else 0;
def LoVol = volume<volume[1] and volume<volume[2] and volume<volume[3] and volume<volume[4] and volume<volume[5] and volume<volume[6] and volume<volume[7] and volume<volume[8] and volume<volume[9] and volume<volume[10] and BN < Current_Bar_Number;
AssignPriceColor(if LoVol then Color.WHITE else Color.Current);
The color is changeable through the code btw

**New code on Post #7
 
Last edited:
For reference, this is the condition for the 'latest bar'
Ruby:
def Latest_bar = IsNan(Close[-1]);
All it does is check that the next bar's close is not a number, i.e. this is the latest bar.

Here is an updated version, that does not require you any inputs:
Ruby:
def Latest_bar = IsNan(Close[-1]);
def LoVol = !Latest_Bar and volume<volume[1] and volume<volume[2] and volume<volume[3] and volume<volume[4] and volume<volume[5] and volume<volume[6] and volume<volume[7] and volume<volume[8] and volume<volume[9] and volume<volume[10];
AssignPriceColor(if LoVol then Color.WHITE else Color.Current);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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