Candles sticks that change color with heavy volume


Category:
1
0

Hello Hahn,

Is it possible to create a script that changes the colors of candlesticks based on volume and RSI?

For example, when the current candle has more than 1.5 relative volume and an RSI>65 , it will be colored yellow on the chart.

Marked as spam
Posted by (Questions: 22, Answers: 63)
Asked on July 9, 2018 4:35 pm
1239 views
0

What is “relative volume”?

( at July 9, 2018 5:15 pm)
0
Private answer

Sorry, my original answer contained a typo in the code and was missing the screenshot. Full text of my original answer follows:

Ok, great. In the future please be sure to use the full name of any studies that are included with Thinkorswim. The term “relative volume” can have many interpretations. Instead of this you should provide the full name of the study as it appears in Thinkorswim:  “RelativeVolumeStDev”.

Having made that clarification we have the following code. Screenshot below shows the result:

input rviLength = 60;
input numDev = 2.0;
#---------- RSI Inputs
input rsiLength = 14;
input rsiPrice = close;
input rsiAverageType = AverageType.WILDERS;
#---------- RelativeVolumeStDev
input allowNegativeValues = no;
def rawRelVol = (volume - Average(volume, rviLength)) / StDev(volume, rviLength);
def relVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
#---------- RSI
def netChgAvg = MovingAverage(rsiAverageType, rsiPrice - rsiPrice[1], rsiLength);
def totChgAvg = MovingAverage(rsiAverageType, AbsValue(rsiPrice - rsiPrice[1]), rsiLength);
def chgRatio = if totChgAvg != 0 then netChgAvg / totChgAvg else 0;
def rsi = 50 * (chgRatio + 1);
#---------- Condition
def paintBar = relVol > 1.5 and rsi > 65;
#---------- Paint Candles
AssignPriceColor(if paintBar then Color.YELLOW else Color.Current);

 

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4079)
Answered on July 10, 2018 10:52 am
0
Hello Pete, This is very amazing. The only issue with the code I would like to work with you with is what condition can we further add to the code for Red candles to never be shown as yellow or yellow candles that go red are displayed as red on the chart. So, in a nutshell, if the current candle is red (down)…. never display the color as yellow. or, The candle must be a ”up candle” for the color to be displayed
( at July 15, 2018 6:40 am)
0

Update the following line of code:
def paintBar = relVol > 1.5 and rsi > 65;

To:
def paintBar = close > open and relVol > 1.5 and rsi > 65;

( at July 15, 2018 7:41 am)
0

!!!! Amazing work

( at July 15, 2018 8:54 am)
0
Hello Hahn, I want to add a new condition to this code base on our previous conversations here in this thread https://www.hahn-tech.com/thinkorswim-chart-studies/ . The final condition I would to add to this code a new condition that the candles will only turn yellow IF the amount of volume in dollars ON THE DAY is greater than 1 million based on the code we spoke about earlier below. This will esentially be a code merger. Thank you
( at November 5, 2018 6:53 pm)
0

def volumeDollars = Round(volume * hlc3, 0);
def newDay = GetDay() GetDay()[1];
rec todaysVolumeDollars = if newDay then volumeDollars else todaysVolumeDollars[1] + volumeDollars;
AddLabel(yes, Concat(“Total Vol Dollars: “, todaysVolumeDollars), Color.WHITE);

( at November 5, 2018 6:57 pm)
0

Sorry but the two sections of code are not compatible. One is meant to run on a daily chart and the other is only meant to run on an intraday chart.

( at November 6, 2018 7:52 am)
0
Hi Pete, I wonder if you can help me write a script for Intraday 1minute chart for a Falling Knife red candle that drop more than 10% in one candle. Example: XYZ 10:30 open candle is $0.99, high 1.00, low is 0.85, closed 0.89 So, between the high $1, closed $0.89 which drop more than 10% in that 1 candle. Are you able to help me write a code that this candle can change into a different color? Thank you so much Jin
( at October 18, 2020 12:29 pm)
0
What you have described is certainly possible. However you will need to post that as a new question. Your request has nothing in common with the question and solution provided on this page. Except that it changes the color of the candle based on a condition.
( at October 18, 2020 1:30 pm)
0
Sorry, I have been looking for a long time I can't find the new question link, that's why i posted here. I will try to figure it out. Thanks for your reply.
( at October 18, 2020 1:46 pm)
0
That's why there is a Help menu at the top of this website. From the Help menu you will find an option named "Introduction Video". The video explains everything you need to know about using the Q&A forum and navigating this site.
( at October 18, 2020 2:23 pm)