Volume per candle


Tags:
Category:
0
0

I know I can use the VolumeAvg in the lower studies section to show me the candle volume I’m searching for. However, I’m trying to get this on the price part of the chart. I currently can tell 30 day average (can customize the time), Show today’s volume, percentage of 30 day, unusual volume (can customize the %), 30 bar avg, and current bar. Now the current bar shows the last bar on the chart whether it’s an hourly chart or daily chart, etc. What I want to be able to do is hover over any candle and see the volume if that is possible.

Here is my code link: http://tos.mx/Kz8Nc8

Marked as spam
Posted by (Questions: 21, Answers: 47)
Asked on April 24, 2018 8:49 am
1230 views
0

I simplified the code some when finding the average and can now input the length whether I want 30 days or more or less. Here is an updated link of the code. http://tos.mx/Vd47ba

( at April 24, 2018 9:41 am)
0
( at April 24, 2018 10:22 am)
0
Private answer

The only way to display the data for a candle you are hovering over with the mouse, is to use a plot statement. It is not possible to display that value in a chart label. Because thinkscript has no interface to enable the code to “see” what the user is pointing to with the mouse.

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on April 24, 2018 10:14 am
0

Ok that makes sense. I’ve updated and continue to tweak the code and curious if you could help me with one more issue. Updated code: http://tos.mx/nVSb7n
1. I would like to have the Daily Average set to the average over the last 252 days. Currently this only shows when I have the length input to 252 and on a daily time frame. How can I keep this true if I use any other time frame? What code should I put in place of this?

( at April 24, 2018 6:22 pm)
0

Please avoid using share links to provide source code. Those links have an expiration date and folks reading this post 10 years from now (or 12 months from now) will not be able to access those links. Are you the author of this code? I see the header section contains comments detailing authorship. I need to make sure this code is open-sourced and free of copy-right restrictions.

( at April 24, 2018 7:09 pm)
0

My apologies about the link sharing. Yes I am the owner of the code. That is my website that shows this.

( at April 24, 2018 8:02 pm)
0

I do not mind if it is ok with you to upload a document with this code to dropbox so others in the future may use.

( at April 24, 2018 8:05 pm)
0

Ok thanks for confirming. in the morning, I will post the full code with the solution to your question about how to get the daily average to display on lower time frame charts.

( at April 24, 2018 8:42 pm)
0
Private answer

My second answer is in response to an additional question asked by Ryan in the comments section of my last email.

On 4/24/18 Ryan asked:

I would like to have the Daily Average set to the average over the last 252 days. Currently this only shows when I have the length input to 252 and on a daily time frame. How can I keep this true if I use any other time frame? What code should I put in place of this?

Here is the entire text of Ryan’s code:

#FibKing Creations
#FibKing Trading
#www.FibKingTrading.com
#Volume Stats
#Updated 4.24.18
#Inputs
input length = 252;
input avglength = 30;
input ShowDailyAvg = yes;
input ShowTodayVolume = yes;
input ShowPercentOfDayAvg = yes;
input UnusualVolumePercent = 100;
input ShowBarAvg = yes;
input ShowCurrentBar = yes;
#Volume Data Defined
def volYearDayAvg = Average(volume, length);
def today = volume(period = "DAY");
def percentOfDay = Round((today / volYearDayAvg) * 100, 0);
def avglengthBars = Average(volume, avglength);
def percentOfAvg = Round((today / avglengthBars) * 100, 0);
def curVolume = volume;
#Labels
AddLabel(ShowDailyAvg, "Daily Avg: " + Round(volYearDayAvg, 0), Color.LIGHT_GRAY);
AddLabel(ShowPercentOfDayAvg, percentOfDay + "%", (if percentOfDay >= UnusualVolumePercent then Color.GREEN else if percentOfDay >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(ShowTodayVolume, "Today: " + today, (if percentOfDay >= UnusualVolumePercent then Color.GREEN else if percentOfDay >= 100 then Color.ORANGE else Color.LIGHT_GRAY));
AddLabel(ShowBarAvg, "Avg Bars: " + Round(avglengthBars, 0), Color.LIGHT_GRAY);
AddLabel(ShowPercentOfDayAvg, percentOfAvg + "%", (if percentOfAvg >= UnusualVolumePercent then Color.GREEN else if percentOfAvg >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(ShowCurrentBar, "Cur Bar: " + curVolume, (if curVolume >= avglengthBars then Color.GREEN else Color.ORANGE));
#High Volume dot
def aVol = Average(volume, avglength);
def pVol = 100 * ((volume - aVol[1]) / aVol[1]);
def pDot = pVol >= unusualVolumePercent;
plot volumeStrength = if pDot then hl2 else Double.NaN;
volumeStrength.SetPaintingStrategy(PaintingStrategy.boolEAN_POINTS);
volumeStrength.SetLineWeight(5);
volumeStrength.SetDefaultColor(Color.white);
volumeStrength.HideBubble();
#Alerts
input enableAlerts = Yes;
alert(enableAlerts and pDot, "Volume Strength Alert", alert.bar, sound.ring);

His year-long daily average is computed on this line:

def volYearDayAvg = Average(volume, length);

In order to force this to read from the daily time frame when the chart is set to a LOWER time frame you will modify that line of code to this:

def volYearDayAvg = Average(volume(period = AggregationPeriod.DAY), length);

Give it a try and let us know how it goes. (this will cause an error when plotted on a time frame higher than daily)

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on April 25, 2018 7:41 am
0

Thank you. I always have a brain fart on the aggregate period line. Thanks again for this!

( at April 25, 2018 8:38 am)