Hello,
I see the below code which @SleepyZ developed, that shows buy and sell volume. Could anyone please modify the script to show the buy volume for each month and the total buy volume for the corresponding year? Then, calculate the relative volume by dividing the monthly buy volume by the total buy volume of the year. This relative volume should be plotted on a lower chart against time. For instance, the relative volume for January will always be 1, since the total yearly volume is equal to the monthly volume. However, the relative volume will change as we move from February to December.
This value should be plotted as a histogram similar to the "Relative Volume" chart in TOS.
Additionally, the script should allow for comparison with a specified value (e.g., 2). If the relative volume is greater than or equal to 2.0, the histogram bar should be colored light pink; otherwise, it should be dark pink.
Thank you so much
I see the below code which @SleepyZ developed, that shows buy and sell volume. Could anyone please modify the script to show the buy volume for each month and the total buy volume for the corresponding year? Then, calculate the relative volume by dividing the monthly buy volume by the total buy volume of the year. This relative volume should be plotted on a lower chart against time. For instance, the relative volume for January will always be 1, since the total yearly volume is equal to the monthly volume. However, the relative volume will change as we move from February to December.
This value should be plotted as a histogram similar to the "Relative Volume" chart in TOS.
Additionally, the script should allow for comparison with a specified value (e.g., 2). If the relative volume is greater than or equal to 2.0, the histogram bar should be colored light pink; otherwise, it should be dark pink.
Thank you so much
Code:
input agg = AggregationPeriod.DAY;
def v = volume(period = agg);
def h = high(period = agg);
def o = open(period = agg);
def c = close(period = agg);
def l = low(period = agg);
def buyvol = Round(((h - o + (c - l)) / 2 / (h - l)) * v, 0);
def sellvol = Round(((l - o) + (c - h)) / 2 / (h - l) * v, 0);
def buyvolper = buyvol / v * 100;
def sellvolper = AbsValue(sellvol) / v * 100;
AddLabel(yes, "Total Volume: " + v, Color.LIGHT_GRAY);
AddLabel(yes, "Buy Volume: " + buyvol, Color.GREEN);
AddLabel(yes, "Sell Volume: " + AbsValue(sellvol), Color.RED);
AddLabel(yes, "BVP%: " + Round(buyvolper), Color.GREEN);
AddLabel(yes, "SVP%: " + Round(sellvolper), Color.RED);