• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

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
 

XeoNoX

Well-known member
VIP
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.
 

adii800

Member
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:

adii800

Member
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);
 
Top