All Buy / Sell Volume Pressure Indicators & Labels For ThinkOrSwim

My understanding is that ThinkorSwim does not provide a "true" cumulative volume indicator on its platform similar to Tradingview or other more updated scripting capacity platforms. to be explicit ,TOS does not aggregate the individual spread difference for transactions spread between buyers and sellers during the actual auction process as it unfolds. (In my opinion scalpers especially favor cum delta volume because it shows the internal tension in a moment by moment unfolding process.) All the volume studies I have personally observed on usethinkscipt.com theads seem to have as their goal a "workaround" for this lack of precision and information. Given what I have seen so far, there is no perfect way to perform a true cumulative delta volume indicator in thinkorswim. Please feel free to reply and further enlighten me about this subject. One last comment: even with the cum delta volume study, I have personally observed many, I repeat, many false short term breakouts and reversals even in the most robust index like spx, spy and index options. Whatever signal a TOS trader uses to drill down into the internal auction process I suggest that it is critical pay attention to the tick indicators and the cumulative tick indicators along with all these (Mobius Volume Waves, Buy, Sell vol,

This is useful as a workaround for the reality that unlike Tradingview, there is no actual cumulative delta indicator on TOS (the accumulation spread between buyer and seller in the transactional auction process. Aside from that this is an excellent tool to decipher the internal tension over the selected time period in which you are trading. U could add a cumulative tick indicator across the price section (for the major indexes) in order to get a clearer picture of how the auction, price discovery process is unfolding. I take comfort that I have observed that the cumulative delta indicators on other platforms lead to many false breakouts and short term reversals. Do not despair as the only perfect indicator is already inside you. No single electronic signal will replace you when you are in total synchronization with the market. Thanks to everyone working on this thread. Very creative workarounds.



Great indicator. Thanks as always.

I copied the code into an study but when I go to my watchlist and choose customize, the study does not show up as an option I can have in my watchlist. Any suggestions. I found a video on youtube. I didnt realize you add it under custom quote.
 
Last edited:
I copied the code into an study but when I go to my watchlist and choose customize, the study does not show up as an option I can have in my watchlist. Any suggestions
There is a video by Hahn Tech LLC that is very detailed allowing you to build indicators in any Watchlist.. It illustrates how certain indicators can be adapted to WatchList I found it useful but not not easily done at first. {Personally I use other alerts, instead,using the marketwatch gadget on TOS- and putting it in detached mode.} Here is the link to the instructions for adopting indicators for watchlist and/or marketwatch. It's a work in progress to customize your TOS platform. see this link https://www.hahn-tech.com/category/tos/watchlists-tos//// when I first started I was overwhelmed and intimidated as a self taught humble hacker. Hope that helps, Best to all
 
Are there any ways to have the buy/sell add up just like total volume instead of increasing and decreasing. This gif is from a daily candle chart

fn2DY3i.gif



Code:
def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0);
def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0);
def buyvolper = buyvol / volume() * 100;
def sellvolper = absValue(sellvol) / volume() * 100;

addLabel(yes, "Total Volume: " + volume(), color.LIGHT_GRAY);
addLabel(yes, "Buy Volume: " + buyvol, color.GREEN);
addLabel(yes, "Sell Volume: " + absValue(sellvol), color.RED);
addLabel(yes, "BVP%: " + buyvolper, color.GREEN);
addLabel(yes, "SVP%: " + sellvolper, color.RED);
 
Are there any ways to have the buy/sell add up just like total volume instead of increasing and decreasing. This gif is from a daily candle chart

fn2DY3i.gif



Code:
def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0);
def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0);
def buyvolper = buyvol / volume() * 100;
def sellvolper = absValue(sellvol) / volume() * 100;

addLabel(yes, "Total Volume: " + volume(), color.LIGHT_GRAY);
addLabel(yes, "Buy Volume: " + buyvol, color.GREEN);
addLabel(yes, "Sell Volume: " + absValue(sellvol), color.RED);
addLabel(yes, "BVP%: " + buyvolper, color.GREEN);
addLabel(yes, "SVP%: " + sellvolper, color.RED);

This should help

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);
 
Knowing the percentage of buyers and sellers in the market is a powerful tool for making informed investment decisions. By using this script, traders can assess the market sentiment and determine whether there is a high demand for a particular stock, or if there are more sellers than buyers. This information can help traders to time their trades more effectively, as well as to identify potential trends or market reversals. The buyPercent and sellPercent variables calculate the percentage of buying and selling volume, respectively, in relation to the total trading volume. These percentages are displayed in the labels, along with the current buying and selling volumes. The labels are color-coded to indicate whether there is more buying or selling pressure in the market, with green indicating more buying and red indicating more selling.

(Added Current bar volume and last bar volume.) 5-06-2023

Video:

Install: Go to Studies, Edit Studies, Create, Delete whats in there, copy the code below, paste it, Name it, Move it over to the chart if not already there.

Code:
#hint: Buy_Sell_Percent_Label - Created by @uptwobucks . This Volume Label measures the percentage of buys and sells live. Wait for the buys to outnumber the sells (Turns Green) then make your decision.

declare upper;

input Show_Labels = yes;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);
def OL = open[1];
def HL = high[1];
def CL = close[1];
def LL = low[1];
def VL = volume[1];
def LBuying = VL * (CL - LL) / (HL - LL);
def LSelling = VL * (HL - CL) / (HL - LL);
def totVol = Round(Buying, 0) + Round(Selling, 0) ;
def buyPercent  = ( Round(Buying, 0)  / totVol ) * 100;
def sellPercent = ( Round(Selling, 0) / totVol ) * 100;

AddLabel(Show_Labels, "Total Vol: " + volume(period = AggregationPeriod.DAY), Color.WHITE);

#Volume of Current Bar
AddLabel(yes, "CurrentBar Vol: " + volume, Color.LIGHT_GREEN);

#Volume of the Last Bar
AddLabel(yes, "LastBar Vol: " + volume[1], Color.LIGHT_ORANGE);

AddLabel(Show_Labels, "  BUYERS: " + Round(Buying, 0) + " -- " + Round(buyPercent, 0) + "%"  , if Buying > Selling then Color.LIGHT_GREEN else Color.BLACK);

AddLabel(Show_Labels, "  SELLERS: " + Round(Selling, 0) + " -- " + Round(sellPercent, 0) + "%"  , if Selling > Buying then Color.LIGHT_RED else Color.BLACK);
 
Last edited by a moderator:
just as it is shown total volume; , buy volume; , sell volume on current candle. can we add previous candle? Many thanks!11
mdtn
Are there any ways to have the buy/sell add up just like total volume instead of increasing and decreasing. This gif is from a daily candle chart

fn2DY3i.gif



Code:
def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0);
def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0);
def buyvolper = buyvol / volume() * 100;
def sellvolper = absValue(sellvol) / volume() * 100;

addLabel(yes, "Total Volume: " + volume(), color.LIGHT_GRAY);
addLabel(yes, "Buy Volume: " + buyvol, color.GREEN);
addLabel(yes, "Sell Volume: " + absValue(sellvol), color.RED);
addLabel(yes, "BVP%: " + buyvolper, color.GREEN);
addLabel(yes, "SVP%: " + sellvolper, color.RED);
 
just as it is shown total volume; , buy volume; , sell volume on current candle. can we add previous candle? Many thanks!11
mdtn

Here is the last 2 candles with bubbles above/below these showing the total volume; , buy volume; , and sell volume

Screenshot-2023-04-09-160731.png
Code:
input bubbleoffset = 3;

def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume(), 0);
def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume(), 0);
def buyvolper = buyvol / volume() * 100;
def sellvolper = AbsValue(sellvol) / volume() * 100;

def last = !IsNaN(close) and IsNaN(close[-1]);
def prev = !IsNaN(close[1]) and IsNaN(close[-2]);
AddChartBubble(last or prev, if last then high + TickSize() * bubbleoffset else low - TickSize() * bubbleoffset, "Total Volume: " + volume(), Color.LIGHT_GRAY, if last then yes else no);

AddChartBubble(last or prev, if last then high + TickSize() * bubbleoffset else low - TickSize() * bubbleoffset,  "Sell Volume: " + AbsValue(sellvol), Color.RED, if last then yes else no);

AddChartBubble(last or prev, if last then high + TickSize() * bubbleoffset else low - TickSize() * bubbleoffset, "Buy Volume: " + buyvol, Color.GREEN, if last then yes else no);
 
Hi @SleepyZ Can you help modify the coloring of the labels per the image below? Thank you


This does what you wanted for the sell labels per the image

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), if sellvolper < 50 then Color.GRAY else Color.RED);
AddLabel(yes, "BVP%: " + Round(buyvolper), Color.GREEN);
AddLabel(yes, "SVP%: " + Round(sellvolper), if sellvolper < 50 then Color.GRAY else Color.RED);
 
Volume drives price.
The thinking is to filter your corral of eligible stocks by the standard of Average(volume,50) > 1000000. Thus making sure you are picking the stocks being traded by the Industrial Traders and Algos as they are who move markets. AND THEN look at the buying /selling percentages to see who is in charge.

I keep the Chris Enhanced Labels on my chart, gives me totally daily volume and who is in charge by percentage. I overlay my labels on the Better Volume Indicator as modified by @netarchitech so I can eyeball unusual activity.
Everyone should choose the volume indicator that best suits their style. I use @netarchitech because I am a Price Action Trader which he incorporates into his script.
Read more about Better Volume: https://usethinkscript.com/threads/better-volume-indicator-for-thinkorswim.108/
Read more about Price Action: https://usethinkscript.com/threads/price-action-toolbox-for-thinkorswim.10747/

B2U0olR.png

My Chris Enhanced Labels:
Ruby:
#Chris' Enhanced Volume V.2 /w Uptick/Downtick
#streamlined by @MerryDay 2/2020 only displays Daily Volume and who is in charge
declare lower;
declare real_size ;
##############################
# UPTICK / DOWNTICK CRITERIA #
##############################
input VolAgg = AggregationPeriod.DAY ;
def Buying = volume * (close - low) / (high - low);
def Selling = volume * (high - close) / (high - low);
def DailyVol = volume("period" = VolAgg);
def AvgVol = Average(DailyVol,50) ;
#################
# Formatting
#################
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;

AddLabel(yes, "AvgVol = " +Round(AvgVol,0) +" | " +"DailyVol = " + Round(DailyVol, 0), color.violet);
AddLabel(buying>selling, "Buy %: " + Round((Buying/(Buying+Selling))*100,2) ,  GlobalColor("LabelGreen"));
AddLabel(selling>buying, "Sell %: " + Round((Selling/(Selling+Buying))*100,2) , color.RED);

plot scan = Buying > Selling ;
     scan.hide();
this is awesome! I have custom candles I use is there anyway to put those in place of the HeikinAshi?
 
this is awesome! I have custom candles I use is there anyway to put those in place of the HeikinAshi?
The buying selling volume pressure scripts in this thread are lower studies.
Not related to Heiken Ashi.

Therefore, there should be no issues with using the buying selling volume pressure scripts in this thread with your custom candle scripts.
 
######################################################################### #URL# http://tos.mx/O9l8QYQ
#SELLERSINDICATOR#
##################################################################

input startTime = 0400;
input endTime = 0929;
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];
declare lower;
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);
plot SV = Selling;
SV.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
SV.SetDefaultColor(Color.RED);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(1);
plot BV = volume;
BV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BV.SetDefaultColor(Color.BLUE);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);

##########################################################################################################################################

Hope this was helpful :)
 
Last edited by a moderator:
Hi @SleepyZ Can you help modify the coloring of the labels per the image below? Thank you

These labels are great, but may have found an error in the tally. At "market open" shouldn't all time frames match in volume? I'm getting different counts on 1hour, 2hour and 10 minutes right as the market opens. Forgot to mention that this is at the very beginning of a new week also. I have the weekly, daily, hourly and 10 minute charts on my desktop. So during the first 10 minutes all charts should show the same volume until 10 minutes go by, then the only different volume should be the 10 minute chart as it goes into the 2nd 10 minute time frame, but the hourly, daily and weekly should all reflect the same volume.
 
Last edited:
Hey everyone. I used DTS sellers indicator and decided to make some changes to it and as you all may know, I do not write code so I had chat GPT do what I was asking. Chat GPT made a mistake or I didn't provide enough info but in any case the mistake was really good. I sent it to the original creator so he could take a look at the changes. It may be a game changer for scalpers.
Here is a link to what he said about it.

BTW, He did email me back and I didn't see it as I didn't use my main email account. Anyhow, he did ask if I wanted him to mention me for credit. This was his reply:

"Hello Metal
This looks very interesting. Thank you for sharing. I want to make additional changes to this that other subscribers have suggested I add to the Sellers Indicator and make it available to our subscribers for free. Is that okay with you? I can mention your name as a contributor if you like.
Please let me know and thanks for watching and your support to our community."


I did not respond to him before he put out the video. I wouldn't have asked for the credit in any case.

I hope this can be of some help!

https://tos.mx/QyFjEmS
Ruby:
# BUYERS INDICATOR WITH LABELS
#################################################################

AddLabel(yes, "This: " + volume, Color.yellow);
AddLabel(yes, "Last: " + volume[1], color.yellow);
input startTime = 0400;
input endTime = 0929;
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];
declare lower;
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);
plot BV = Buying;
BV.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
BV.SetDefaultColor(Color.GREEN);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(1);
plot SV = Selling;
SV.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
SV.SetDefaultColor(Color.RED);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(1);
plot VolumeHistogram = volume;
VolumeHistogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VolumeHistogram.SetDefaultColor(Color.BLUE);
VolumeHistogram.HideTitle();
VolumeHistogram.HideBubble();
VolumeHistogram.SetLineWeight(5);

# Average Volume Line
def AverageVolume = Average(VolumeHistogram, 50);
plot AverageVolumeLine = AverageVolume;
AverageVolumeLine.SetDefaultColor(Color.GRAY);
AverageVolumeLine.SetStyle(Curve.FIRM);

# Label indicating Buyers/Sellers Volume
def isBuyersVolumeGreater = BV > SV;
def isSellersVolumeGreater = SV > BV;
AddLabel(yes, if isBuyersVolumeGreater then "Buyers Volume > Sellers Volume" else if isSellersVolumeGreater then "Sellers Volume > Buyers Volume" else "Buyers Volume = Sellers Volume",
    if isBuyersVolumeGreater then Color.GREEN else if isSellersVolumeGreater then Color.RED else Color.YELLOW);

# Buyer and Seller Percentage Labels
def TotalVolume = VolumeHistogram + AverageVolume;
def BuyerPercentage = Buying / TotalVolume * 100;
def SellerPercentage = Selling / TotalVolume * 100;
AddLabel(yes, "Buyer %: " + Round(BuyerPercentage, 2) + "%", Color.GREEN);
AddLabel(yes, "Seller %: " + Round(SellerPercentage, 2) + "%", Color.RED);

# Current Candle Volume Label
#def CurrentCandleVolume = if targetPeriod then VolumeHistogram else Double.NaN;
#AddLabel(yes, "Current Candle Volume: " + AsText(CurrentCandleVolume), Color.WHITE);

# Last Candle Volume Label
#def LastCandleVolume = if targetPeriod[1] then VolumeHistogram[1] else Double.NaN;
#AddLabel(yes, "Last Candle Volume: " + AsText(LastCandleVolume), Color.WHITE);
 
Last edited by a moderator:
Hey everyone. I used DTS sellers indicator and decided to make some changes to it and as you all may know, I do not write code so I had chat GPT do what I was asking. Chat GPT made a mistake or I didn't provide enough info but in any case the mistake was really good. I sent it to the original creator so he could take a look at the changes. It may be a game changer for scalpers.
Here is a link to what he said about it.

BTW, He did email me back and I didn't see it as I didn't use my main email account. Anyhow, he did ask if I wanted him to mention me for credit. This was his reply:

"Hello Metal
This looks very interesting. Thank you for sharing. I want to make additional changes to this that other subscribers have suggested I add to the Sellers Indicator and make it available to our subscribers for free. Is that okay with you? I can mention your name as a contributor if you like.
Please let me know and thanks for watching and your support to our community."


I did not respond to him before he put out the video. I wouldn't have asked for the credit in any case.

I hope this can be of some help!

https://tos.mx/QyFjEmS
Ruby:
# BUYERS INDICATOR WITH LABELS
#################################################################

AddLabel(yes, "This: " + volume, Color.yellow);
AddLabel(yes, "Last: " + volume[1], color.yellow);
input startTime = 0400;
input endTime = 0929;
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];
declare lower;
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);
plot BV = Buying;
BV.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
BV.SetDefaultColor(Color.GREEN);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(1);
plot SV = Selling;
SV.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
SV.SetDefaultColor(Color.RED);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(1);
plot VolumeHistogram = volume;
VolumeHistogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VolumeHistogram.SetDefaultColor(Color.BLUE);
VolumeHistogram.HideTitle();
VolumeHistogram.HideBubble();
VolumeHistogram.SetLineWeight(5);

# Average Volume Line
def AverageVolume = Average(VolumeHistogram, 50);
plot AverageVolumeLine = AverageVolume;
AverageVolumeLine.SetDefaultColor(Color.GRAY);
AverageVolumeLine.SetStyle(Curve.FIRM);

# Label indicating Buyers/Sellers Volume
def isBuyersVolumeGreater = BV > SV;
def isSellersVolumeGreater = SV > BV;
AddLabel(yes, if isBuyersVolumeGreater then "Buyers Volume > Sellers Volume" else if isSellersVolumeGreater then "Sellers Volume > Buyers Volume" else "Buyers Volume = Sellers Volume",
    if isBuyersVolumeGreater then Color.GREEN else if isSellersVolumeGreater then Color.RED else Color.YELLOW);

# Buyer and Seller Percentage Labels
def TotalVolume = VolumeHistogram + AverageVolume;
def BuyerPercentage = Buying / TotalVolume * 100;
def SellerPercentage = Selling / TotalVolume * 100;
AddLabel(yes, "Buyer %: " + Round(BuyerPercentage, 2) + "%", Color.GREEN);
AddLabel(yes, "Seller %: " + Round(SellerPercentage, 2) + "%", Color.RED);

# Current Candle Volume Label
#def CurrentCandleVolume = if targetPeriod then VolumeHistogram else Double.NaN;
#AddLabel(yes, "Current Candle Volume: " + AsText(CurrentCandleVolume), Color.WHITE);

# Last Candle Volume Label
#def LastCandleVolume = if targetPeriod[1] then VolumeHistogram[1] else Double.NaN;
#AddLabel(yes, "Last Candle Volume: " + AsText(LastCandleVolume), Color.WHITE);
Going to Test this live and see how things go. Looks pretty promising running it through futures
 
VPA Candle Colors (04/19/21) By richard_the_red

Code:
## VPA CANDLE COLORS
## By richard_the_red
## This script will make candles with more relative volume brighter
# and with less relative volume less visually important. 
# It also colors candles based on selling vs buying volume percentage rather than open/close. 
# This means you can have orange or yellow candles 
# if the volume is a more even mix of buying and selling.

## Yellow dots in the candle body mean that it is significant volume for that candle, 
# rvsd is greater than Standard_Deviations.

## NOTE: if you change your appearance settings for volume bars
# to color them using candle color then they will also show the VPA colors,
# this saves on performance so you don't have to use the old VPA Volume Colors script as well.

declare upper; # only applies to candles in the main chart
declare once_per_bar; # reduces computation time dramatically at the expense of not calculating current bar color, just uses default

## The length of our MA for volume, here defaults to the last 20 candles
input only_show_below = AggregationPeriod.FIFTEEN_MIN;
input SMA_Length = 20; # how many bars to calculate RVSD
input Standard_Deviations = 1.0; # default number of SD threshold, 1 is 65% 2 is 95%
input max_transparency_percent = 50; # so you can turn off volume-based opacity if you want, make it 100
def opacity = (max_transparency_percent / 100) * 255;
DefineGlobalColor("dot", color.mAGENTA);

def L = low;
def C = close;
def O = open;
def H = high;
def V = volume;

# See if this is the current candle so we can skip coloring it for performance reasons
def isLatestBar = !IsNaN(close) && IsNaN(close[-1]);

## Originally Developed by Melvin E. Dickover, the Relative Volume Standard Deviation is calculated over the SMA_Length kind of like a moving average but more complicated. RCB uses this in his enhanced volume script.
def rvsd = RelativeVolumeStDev(length = SMA_Length);
def isRvsd = rvsd >= Standard_Deviations;
def rvsdhigh = Highest(rvsd, SMA_Length);
def base_opacity = ((rvsd / rvsdhigh) * (255 - opacity)) + opacity; # completely transparent candles are useless
def cvalcur = if isRvsd then 255 else if isNaN(base_opacity) then opacity else base_opacity; # significant bars are always brighter

## Color candles on a gradient from green if buying volume is greater than selling, to red if selling volume is greater than buying.
## Note that the opacity of the candle is based on Relative Volume Standard Deviation (SMA_Length price vs volume)
def Buying = v * ((c - l) / (h - l));
def Selling = v * ((h - c) / (h - l));
def Percent = AbsValue(Buying - Selling) / v;
def Percent_Buying = Buying / v;
def pctgreen = Percent_Buying * cvalcur;
def Percent_Selling = Selling / v;
def pctred = Percent_Selling * cvalcur;

def Red =
    if ( # if candle is flat then check last for color else use pct
        (h == l),
        if (c < c[1], 255, 120),
        if ( pctred > 255, 255, if (pctred < 0, 0, pctred) )
    );
def Green =
    if ( # if candle is flat then check last for color else use pct
        (h == l),
        if (c > c[1], 255, 120),
        if ( pctgreen > 255, 255, if (pctgreen < 0, 0, pctgreen) )
    );
def Blue = if (isRvsd, 40, 30); # Make slight blue tint to soften the color

## Now color the candle. Modifying the green value slightly as it doesn't show up as well as red
AssignPriceColor(if isLatestBar OR only_show_below <= GetAggregationPeriod() then color.current else CreateColor(Red, Green, Blue));

plot rvsd_dot = if (isRVSD, Max(o, c) - (BodyHeight() / 2), double.NaN);
rvsd_dot.setPaintingStrategy(paintingStrategy.POINTS);
rvsd_dot.assignValueColor(GlobalColor("dot"));
2023-08-27-FLEXIBLE_GRID xxx.png
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
229 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top