Custom Time VolumeProfile

OptionsTrader

New member
Does anyone have a VolumeProfile that has these 2 things:

1. Custom start and end time (found a thread that had a custom start time but no end time)

2. Shows buyers vs sellers (exactly like what VolumePressure does)

Thanks in advance!
 
Solution
Does anyone have a VolumeProfile that has these 2 things:

1. Custom start and end time (found a thread that had a custom start time but no end time)

2. Shows buyers vs sellers (exactly like what VolumePressure does)

Thanks in advance!

I have modified the script in the following link that I did previously to allow a begininng and ending timeframe display. It uses psuedo buying/selling volume options that were developed, as was stated in the previous post, TOS does not provide that data.

https://usethinkscript.com/threads/volume-profile-indicator-pocs-for-thinkorswim.8153/post-121688

Screenshot-2023-04-24-112042.png
Code:
#DataProfile_BuyingSelling_CloseOpen
#DataProfile - Using Close based upon the input method. Green is 'buying' and...
this script splits profiles between ETH/RTH and lets you define when RTH starts and ends, not exactly what you're looking for but could possibly be modified by someone more experienced than me https://tos.mx/7AdC2OL
Ruby:
input pricePerRowHeightMode = {AUTOMATIC, TICKSIZE, default CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = {CHART, default MINUTE, HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = no;
input profiles = 1;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 7;


def period;
def yyyymmdd = getYyyyMmDd();
def seconds = secondsFromTime(0);
def month = getYear() * 12 + getMonth();
def day_number = daysFromDate(first(yyyymmdd)) + getDayOfWeek(first(yyyymmdd));
def dom = getDayOfMonth(yyyymmdd);
def dow = getDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);

switch (timePerProfile) {
case CHART:
    period = 0;
case MINUTE:
    period = floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
    period = floor(seconds / 3600 + day_number * 24);
case DAY:
    period = countTradingDays(Min(first(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
    period = floor(day_number / 7);
case MONTH:
    period = floor(month - first(month));
case "OPT EXP":
    period = exp_opt - first(exp_opt);
case BAR:
    period = barNumber() - 1;
}

input RthBegin  = 0930;
input RthEnd    = 1600;
#input showBubbles = no;

def bar = BarNumber();

def RTHBar1 = if SecondsFromTime(RthBegin) == 0 and
SecondsTillTime(RthBegin) == 0
then bar
else RTHBar1[1];

def RTHBarEnd = if SecondsFromTime(RthEnd) == 0 and
SecondsTillTime(RthEnd) == 0
then 1
else Double.NaN;

def RTH = SecondsFromTime(RthBegin) > 0 and
SecondsTillTime(RthEnd) > 0;

def cond = RTH != RTH[1];

def height;

switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}



profile vp = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = compoundValue(1, onExpansion, no);
def pc = if IsNaN(vp.getPointOfControl()) and con then pc[1] else vp.getPointOfControl();
def hVA = if IsNaN(vp.getHighestValueArea()) and con then hVA[1] else vp.getHighestValueArea();
def lVA = if IsNaN(vp.getLowestValueArea()) and con then lVA[1] else vp.getLowestValueArea();


def hProfile = if IsNaN(vp.getHighest()) and con then hProfile[1] else vp.getHighest();
def lProfile = if IsNaN(vp.getLowest()) and con then lProfile[1] else vp.getLowest();
def plotsDomain = IsNaN(close) == onExpansion;


plot POC = if plotsDomain then pc else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot VAHigh = if plotsDomain then hVA else Double.NaN;
plot VALow = if plotsDomain then lVA else Double.NaN;



DefineGlobalColor("Profile", GetColor(0));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));


vp.show(globalColor("Profile"), if showPointOfControl then globalColor("Point Of Control") else color.current, if showValueArea then globalColor("Value Area") else color.current, opacity);
POC.SetDefaultColor(globalColor("Point Of Control"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(globalColor("Value Area"));
VALow.SetDefaultColor(globalColor("Value Area"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.hide();
ProfileLow.hide();

since tos doesn't use true tick data I don't think denoting between buy/sell volume is possible
 
Last edited by a moderator:

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

I have modified the script in the following link that I did previously to allow a begininng and ending timeframe display. It uses psuedo buying/selling volume options that were developed, as was stated in the previous post, TOS does not provide that data.

https://usethinkscript.com/threads/volume-profile-indicator-pocs-for-thinkorswim.8153/post-121688
not quite what im looking for but thank you. I wish it actually showed the buyers vs sellers so every bar would be green & red.
 
Does anyone have a VolumeProfile that has these 2 things:

1. Custom start and end time (found a thread that had a custom start time but no end time)

2. Shows buyers vs sellers (exactly like what VolumePressure does)

Thanks in advance!

I have modified the script in the following link that I did previously to allow a begininng and ending timeframe display. It uses psuedo buying/selling volume options that were developed, as was stated in the previous post, TOS does not provide that data.

https://usethinkscript.com/threads/volume-profile-indicator-pocs-for-thinkorswim.8153/post-121688

Screenshot-2023-04-24-112042.png
Code:
#DataProfile_BuyingSelling_CloseOpen
#DataProfile - Using Close based upon the input method. Green is 'buying' and Red is the 'selling' beyond the 'buying'. (The Red is actually the total of buying and selling with the buying overlaid on the red)
#20211130 Sleepyz; updated 20230312 Sleepyz

input method = {default begin_end_times, standard};
input begin  = 0930;
input end    = 1600;

input selling_method = {default buying_selling_pressure, buying_selling_volume};
def c = close;
def o = open;
def h = high;
def l = low;
def v = volume;

# Buying vs. Selling Power
# Assembled by BenTen at UseThinkScript.com
# Converted from https://www.tradingview.com/script/XZ3UXRvL-buy-vs-sell-power-x/


input s = 5;
input m = 9;
input len = 14;
input paintbar = yes;

def source = close;
def hilow = ((high - low) * 100);
def openclose = ((close - open) * 100);
def vol = (close / hilow);
def spreadv = (openclose * close);
def pt = spreadv + TotalSum(spreadv);

def a = ExpAverage(pt, len) - ExpAverage(pt, m);
def b = ExpAverage(pt, s) - ExpAverage(pt, m);
def p = a + b;

def blue = b;
def red = p;

def bullishRule = b >= p;
def bearishRule = b <= p;

AssignPriceColor(if paintbar and bullishRule then Color.CYAN else if paintbar and bearishRule then Color.MAGENTA else Color.CURRENT);

def test;
def rth   = if secondsfromTime(begin)>=0 and secondstillTime(end)>=0 then 1 else 0;
switch (selling_method) {
case buying_selling_volume:
    test = if ((c - l) / (h - l) * volume) >= ((h - c) / (h - l) * volume) then close else if ((c - l) / (h - l) * volume) < ((h - c) / (h - l) * volume) then Double.NaN else test[1];
case buying_selling_pressure:
    test = if b >= p then close else if b < p then Double.NaN else test[1];
}

def buy   = if !rth then double.nan else test;
def Data  = if !rth then double.nan else close;

input pricePerRowHeightMode = { default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input timePerProfile = { CHART, MINUTE, HOUR, default DAY, WEEK, MONTH, "OPT EXP", BAR};
input multiplier = 1;
input onExpansion = no;
input profiles = 3;
input showPointOfControl = yes;
input showValueArea = no;
input valueAreaPercent = 70;
input opacity = 100;

def period;
def yyyymmdd = GetYYYYMMDD();
def seconds = SecondsFromTime(0);
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def dom = GetDayOfMonth(yyyymmdd);
def dow = GetDayOfWeek(yyyymmdd - dom + 1);
def expthismonth = (if dow > 5 then 27 else 20) - dow;
def exp_opt = month + (dom > expthismonth);
switch (timePerProfile) {
case CHART:
    period = 0;
case MINUTE:
    period = Floor(seconds / 60 + day_number * 24 * 60);
case HOUR:
    period = Floor(seconds / 3600 + day_number * 24);
case DAY:
    period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
    period = Floor(day_number / 7);
case MONTH:
    period = Floor(month - First(month));
case "OPT EXP":
    period = exp_opt - First(exp_opt);
case BAR:
    period = BarNumber() - 1;
}

def count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond  = if method == method.begin_end_times then rth!=rth[1] else count < count[1] + period - period[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}

profile datatype = DataProfile("data" = Data, "startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, onExpansion, no);
def pc = if IsNaN(datatype.GetPointOfControl()) and con then pc[1] else datatype.GetPointOfControl();
def hVA = if IsNaN(datatype.GetHighestValueArea()) and con then hVA[1] else datatype.GetHighestValueArea();
def lVA = if IsNaN(datatype.GetLowestValueArea()) and con then lVA[1] else datatype.GetLowestValueArea();

def hProfile = if IsNaN(datatype.GetHighest()) and con then hProfile[1] else datatype.GetHighest();
def lProfile = if IsNaN(datatype.GetLowest()) and con then lProfile[1] else datatype.GetLowest();
def plotsDomain = IsNaN(close) == onExpansion;

plot POC = if plotsDomain then pc else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot VAHigh = if plotsDomain then hVA else Double.NaN;
plot VALow = if plotsDomain then lVA else Double.NaN;

DefineGlobalColor("Profile", Color.LIGHT_RED);
DefineGlobalColor("Point Of Control", Color.CYAN);
DefineGlobalColor("Value Area", Color.LIGHT_RED);

datatype.Show(GlobalColor("Profile"), if showPointOfControl then GlobalColor("Point Of Control") else Color.CURRENT, if showValueArea then GlobalColor("Value Area") else Color.CURRENT);
POC.SetDefaultColor(GlobalColor("Point Of Control"));
POC.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
POC.SetLineWeight(2);
VAHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh.SetDefaultColor(GlobalColor("Value Area"));
VALow.SetDefaultColor(GlobalColor("Value Area"));
VAHigh.SetLineWeight(2);
VALow.SetLineWeight(2);
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.Hide();
ProfileLow.Hide();


profile datatype2 = DataProfile("data" = buy, "startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);

def con2 = CompoundValue(1, onExpansion, no);
def pc2 = if IsNaN(datatype2.GetPointOfControl()) and con2 then pc2[1] else datatype2.GetPointOfControl();
def hVA2 = if IsNaN(datatype2.GetHighestValueArea()) and con2 then hVA2[1] else datatype2.GetHighestValueArea();
def lVA2 = if IsNaN(datatype2.GetLowestValueArea()) and con2 then lVA2[1] else datatype2.GetLowestValueArea();

def hProfile2 = if IsNaN(datatype2.GetHighest()) and con2 then hProfile2[1] else datatype2.GetHighest();
def lProfile2 = if IsNaN(datatype2.GetLowest()) and con2 then lProfile2[1] else datatype2.GetLowest();
def plotsDomain2 = IsNaN(close) == onExpansion;

plot POC2 = if plotsDomain2 then pc2 else Double.NaN;
plot ProfileHigh2 = if plotsDomain2 then hProfile2 else Double.NaN;
plot ProfileLow2 = if plotsDomain2 then lProfile2 else Double.NaN;
plot VAHigh2 = if plotsDomain2 then hVA2 else Double.NaN;
plot VALow2 = if plotsDomain2 then lVA2 else Double.NaN;

DefineGlobalColor("Profile2", Color.GREEN);
DefineGlobalColor("Point Of Control2", Color.CYAN);
DefineGlobalColor("Value Area2", Color.GREEN);

datatype2.Show(GlobalColor("Profile2"), if showPointOfControl then GlobalColor("Point Of Control") else Color.CURRENT, if showValueArea then GlobalColor("Value Area") else Color.CURRENT, opacity);

POC2.SetDefaultColor(GlobalColor("Point Of Control2"));
POC2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
POC2.SetLineWeight(2);
VAHigh2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VAHigh2.SetDefaultColor(GlobalColor("Value Area2"));
VALow2.SetDefaultColor(GlobalColor("Value Area2"));
VAHigh2.SetLineWeight(2);
VALow2.SetLineWeight(2);
ProfileHigh2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh2.SetDefaultColor(GetColor(3));
ProfileLow2.SetDefaultColor(GetColor(3));
ProfileHigh2.Hide();
ProfileLow2.Hide();

input showbubbles = yes;
input bubblemover = 2;
def bm  = bubblemover;
def bm1 = bm + 1;
def mover = showbubbles and IsNaN(close[bm]) and !IsNaN(close[bm1]);

AddChartBubble(mover, POC[bm1], "APOC", POC.TakeValueColor());#All POC
AddChartBubble(mover, POC2[bm1], "UPOC", POC.TakeValueColor());#Up POC
AddChartBubble(mover, VAHigh[bm1], "AVAH", VAHigh.TakeValueColor());
AddChartBubble(mover, VAHigh2[bm1], "UVAH", VAHigh2.TakeValueColor());
AddChartBubble(mover, VALow[bm1], "AVAL", VALow.TakeValueColor());
AddChartBubble(mover, VALow2[bm1], "UVAL", VALow2.TakeValueColor());
 
Last edited:
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
433 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