Color candle when RelativeVolatilityIndex greater than 55


Category:
0
0

Hello Hahn,

I wanted to know if you could create a chart indicator that colored price candles under these conditions.

  1. When the close>open (green)
  2. When the current candle volume is equal or greater than 100k with an RVI (RelativeVolatilityIndex) > 55

 

This chart study will be primarily used and tested on the 1 minute chart.

 

Thank you

Marked as spam
Posted by (Questions: 22, Answers: 63)
Asked on November 15, 2018 4:03 am
96 views
0

This is what I have so far

def paintBar = close > OPEN and volume > 100000;
#———- Paint Candles
AssignPriceColor(if paintBar then Color.YELLOW else Color.Current);

( at November 15, 2018 6:57 am)
0
Private answer

Since you have resolved two of the specifications with your code I have updated the title. Instead of “How to change color of breakout candle” I have updated the title of the question to: “Color candle when RelativeVolatilityIndex greater than 55”. Makes sense to do this, since you are really only needing to get the RVI portion completed.

For this we will once again reach back to a previous post. Only two lines of code will need to be modified. I am getting that code from this post: https://www.hahn-tech.com/ans/relative-volatility-index-rvi-custom-watch-list/

input stDevLength = 10;
input averageLength = 14;
input averageType = AverageType.EXPONENTIAL;
def stDevHi = stDev(high, stDevLength);
def stDevLo = stDev(low, stDevLength);
def avgStDevHiUp = MovingAverage(averageType, if high > high[1] then stDevHi else 0, averageLength);
def avgStDevHiDown = MovingAverage(averageType, if high < high[1] then stDevHi else 0, averageLength);
def avgStDevLoUp = MovingAverage(averageType, if low > low[1] then stDevLo else 0, averageLength);
def avgStDevLoDown = MovingAverage(averageType, if low < low[1] then stDevLo else 0, averageLength);
def rviHi = if avgStDevHiUp + avgStDevHiDown == 0 then 50 else 100 * avgStDevHiUp / (avgStDevHiUp + avgStDevHiDown);
def rviLo = if avgStDevLoUp + avgStDevLoDown == 0 then 50 else 100 * avgStDevLoUp / (avgStDevLoUp + avgStDevLoDown);
def RVI = (rviHi + rviLo) / 2;
AssignPriceColor(if RVI > 55 then Color.YELLOW else Color.CURRENT);

That code only handles the RVI portion of the request. All you need to do is take the lines of code from your comment and add them anywhere above the last line:

AssignPriceColor(if RVI > 55 then Color.YELLOW else Color.CURRENT);

And once you have done so you will modify that last line to this:

AssignPriceColor(if RVI > 55 and paintBar then Color.YELLOW else Color.CURRENT);

 

 

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on November 15, 2018 9:37 am
0

This is what I have, and it is not working

def paintBar = close > OPEN and volume > 100000;
#———- Paint Candles
AssignPriceColor(if paintBar then Color.YELLOW else Color.Current);
AssignPriceColor(if RVI > 55 and paintBar then Color.YELLOW else Color.CURRENT);

( at November 15, 2018 9:53 am)
0

and just to clarify, I am not referring to volume on the day. I am referring to 100k volume on the current 1 minute candle .

Thank you

( at November 15, 2018 9:54 am)
0

Why on earth would you think that you could exclude the rest of the code? If that’s indeed what you did. I said to add your code above the last line. I did not say the last line was all you needed.

( at November 15, 2018 11:55 am)
0

And why are you keeping the original last line when I clearly stated that you would MODIFY the last line.

( at November 15, 2018 11:56 am)
0

Sorry, I completely botched this thread, please close out and I will create a new thread

( at November 15, 2018 12:40 pm)