• LIMITED TIME OFFER: use coupon code PRIMEDAY at checkout to save $50 off VIP membership (down to $149 / year). Valid through Tuesday 6/22.

Volume Profile Indicator for ThinkorSwim

Shinthus

Member
2019 Donor
Hey all. Someone mentioned that ThinkorSwim's volume profile study was basically Center of Gravity (COG). I forget who and where this was said - can someone please confirm or refute?

Also, I noticed the way Volume Profile is calculated on TOS is different than how it's calculated on Tradingview but I don't use Tradingview because I would rather not pay for indicators.... I also took a liking to Tradingview's version and find it more accurate and easier to interpret. Does anybody know the calculation are different and whether or not we can convert that from pinescript to TOS?

This Volume Profile script is for 24 hours BEGINNING with the RTH OPEN.

Code:
# Volume Profile for RTH and GlobeX
# Mobius
# Chat Room Discussion 03.26.2018

input pricePerRowHeightMode = {AUTOMATIC, TICKSIZE, default CUSTOM};
input customRowHeight = 1.0;
input onExpansion = no;
input profiles = 5; #Hint profiles: for just RTH 1 for GlobeX and RTH 2
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 68;
input opacity = 5;
input RthBegin = 0930;
input RthEnd = 1600;

def TS = TickSize();
def Active = getTime() >= RegularTradingStart(getYYYYMMDD());
def cond = getTime() crosses above RegularTradingStart(getYYYYMMDD());
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
case CUSTOM:
height = customRowHeight;
}
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, onExpansion, no);
def pc = if IsNaN(vol.GetPointOfControl()) and con
then pc[1]
else vol.GetPointOfControl();
def hVA = if IsNaN(vol.GetHighestValueArea()) and con
then hVA[1]
else Round(vol.GetHighestValueArea(), 0);
def lVA = if IsNaN(vol.GetLowestValueArea()) and con
then lVA[1]
else vol.GetLowestValueArea();
def hProfile = if IsNaN(vol.GetHighest()) and con
then hProfile[1]
else vol.GetHighest();
def lProfile = if IsNaN(vol.GetLowest()) and con
then lProfile[1]
else vol.GetLowest();
def plotsDomain = IsNaN(close) == onExpansion;

plot POC = if plotsDomain
then Round(pc / TS, 0) * TS
else Double.NaN;
plot ProfileHigh = if plotsDomain
then Round(hProfile / TS, 0) * TS
else Double.NaN;
plot ProfileLow = if plotsDomain
then Round(lProfile / TS, 0) * TS
else Double.NaN;
plot VAHigh = if plotsDomain
then Round(hVA / TS, 0) * TS
else Double.NaN;
plot VALow = if plotsDomain
then Round(lVA / TS, 0) * TS
else Double.NaN;

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

vol.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);
VAHigh.HideBubble();
VAHigh.HideTitle();
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.HideBubble();
VALow.HideTitle();
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();
def bubble = isNaN(close[2]) and !isNaN(close[3]);
AddChartBubble(bubble, VAHigh[3], "VAH", color = Color.YELLOW, yes);
AddChartBubble(bubble, VALow[3], "VAL", Color.YELLOW, no);
AddChartBubble(bubble, POC[3], "POC", Color.RED, no);
# End Code Volume Profile RTH and GlobeX
 

markos

Well-known member
VIP
ToS's built in Volume Profile is correct according to Professor Jeff Bierman, CTA. He worked as the chief market technician for ThinkorSwim for 5 years before the buyout by TDA. Keep in mind, just like the Fractal Energy Indicator is similar to the Chop Indicator even though the math constructs are different.

Code:
#VolumeProfile_RTHvOvernight
#JoeBone87 in TSL May 2019 (No Guarantee it will plot but math should be good)

input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input onExpansion = no;
input profiles = 1000;
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 70;
input opacity = 50;

input rthbegin  = 0930;
input rthend    = 1600;
def count = secondsfromTime(rthbegin)>0 and secondstillTime(rthend)>0;
def cond = count != count[1];
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
height = PricePerRow.AUTOMATIC;
case TICKSIZE:
height = PricePerRow.TICKSIZE;
case CUSTOM:
height = customRowHeight;
}

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

def hProfile = if IsNaN(vol.GetHighest()) and con then hProfile[1] else vol.GetHighest();
def lProfile = if IsNaN(vol.GetLowest()) and con then lProfile[1] else vol.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(1));
DefineGlobalColor("Point Of Control", GetColor(5));
DefineGlobalColor("Value Area", GetColor(8));

vol.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();

input bubbles = yes;
input n  = 2;
def   n1 = n + 1;
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), VAHigh[n1], "V-VAH", color = Color.YELLOW, yes);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), VALow[n1], "V-VAL", Color.YELLOW, no);
AddChartBubble(bubbles and !IsNaN(close[n1]) and IsNaN(close[n]), POC[n1], "V-POC", Color.RED, no);

The Volume Profile script below lets you set the starting time.

Code:
# Volume Profile for User Set Time
# Mobius
# Chat Room Discussion 03.26.2018

input pricePerRowHeightMode = {AUTOMATIC, TICKSIZE, default CUSTOM};
input customRowHeight = 1.0;
input onExpansion = no;
input profiles = 5; #Hint profiles: for just RTH 1 for GlobeX and RTH 2
input showPointOfControl = yes;
input showValueArea = yes;
input valueAreaPercent = 68;
input opacity = 5;
input Begin = 0930;

def TS = TickSize();
def Active = SecondsTillTime(Begin) == 0;
def cond = Active;
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
case CUSTOM:
    height = customRowHeight;
}
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
def con = CompoundValue(1, onExpansion, no);
def pc = if IsNaN(vol.GetPointOfControl()) and con
         then pc[1]
         else vol.GetPointOfControl();
def hVA = if IsNaN(vol.GetHighestValueArea()) and con
          then hVA[1]
          else Round(vol.GetHighestValueArea(), 0);
def lVA = if IsNaN(vol.GetLowestValueArea()) and con
          then lVA[1]
          else vol.GetLowestValueArea();
def hProfile = if IsNaN(vol.GetHighest()) and con
               then hProfile[1]
               else vol.GetHighest();
def lProfile = if IsNaN(vol.GetLowest()) and con
               then lProfile[1]
               else vol.GetLowest();
def plotsDomain = IsNaN(close) == onExpansion;

plot POC = if plotsDomain
           then Round(pc / TS, 0) * TS
           else Double.NaN;
plot ProfileHigh = if plotsDomain
                   then Round(hProfile / TS, 0) * TS
                   else Double.NaN;
plot ProfileLow = if plotsDomain
                  then Round(lProfile / TS, 0) * TS
                  else Double.NaN;
plot VAHigh = if plotsDomain
              then Round(hVA / TS, 0) * TS
              else Double.NaN;
plot VALow = if plotsDomain
             then Round(lVA / TS, 0) * TS
             else Double.NaN;

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

vol.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);
VAHigh.HideBubble();
VAHigh.HideTitle();
VALow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VALow.HideBubble();
VALow.HideTitle();
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();
def bubble = isNaN(close[2]) and !isNaN(close[3]);
AddChartBubble(bubble, VAHigh[3], "VAH", color = Color.YELLOW, yes);
AddChartBubble(bubble, VALow[3], "VAL", Color.YELLOW, no);
AddChartBubble(bubble, POC[3], "POC", Color.RED, no);
# End Code Volume Profile User Set Time

Volume Profile Scanner

Code:
# Mr. Script
def yyyymmdd = GetYYYYMMDD();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def period = Floor(day_number / 7);
def cond = 0 < period - period[1];
profile vol = VolumeProfile("startNewProfile" = cond, "onExpansion" = no);
vol.Show("va color" = Color.YELLOW);
def b = vol.GetLowestValueArea();
plot c = close <= b and close >= (b*.9);
c.setPaintingStrategy(paintingStrategy.BOOLEAN_ARROW_UP);
 

John808

New member
2019 Donor
Hi @Shinthus, here is another cog indicator https://usethinkscript.com/threads/center-of-gravity-cog-indicator-for-thinkorswim.138/ I think this might be the cog indicator you're looking for if you were in bluesgirl's chatroom. (I'm in the same room :) That's similar to what she uses. From what I understand with the cog indicator is you want to play the edges and also look at the curves of the waves. So if the waves are starting to curl up price may have found a bottom and start to move up. Maybe similar to boillinger bands.

As for volume profile here is a picture of the study I use on TOS. It looks at the volume profile for every individual day, so the levels are pretty much the same across all time frames. I can post the settings I have if you're interested :)

52B6GLo.png


I like to mark off the Value area Highs/Lows (the yellow lines) and the point of control (red line). I use these lines as support/resistance and targets for the next day.

dBsFGTi.png


Oh, all of those lines are hand-drawn lol. With Volume profile, there's a concept called VPOC or virgin point of control, which means if a point of control(the red line) hasn't been tested the next day after it's been made, the price will naturally trend towards it. The "put" target level was the value area high from 8/9/19, the same day the VPOC level is from. I'm still practicing with volume profile, but I like it so far.

Hopefully this helps.
 
Last edited by a moderator:
New here to the forum, but had a few questions regarding thinkscript for VolumeProfile in TOS. I know there is a study there already, but I need to change it a bit to fit my needs.

1)How can I be showing ALL the Weekly VOLUMEPROFILES On the chart (For all the Weeks on the chart)? When I click "No" in the Expansion input, it shows me all the VolumeProfiles, but it plots them on their respective Weeks' charts, when I need them to show next week's one (for each one of them - One period forward, so it can serve as support or resistance for next week). - You can take a look at Market Webs and/or Christian Fromhertz from Tribeca Trade Group (active on twitter)
2)How can I be having the Monthly Volume Profile shown when I have the Weekly Chart Up, the Weekly Volume profile shown when I have the Daily Chart up and the Daily Volume profile shown when I have the 60min. Chart up? and
3)On each of the respective charts above, I would need to see the POC plotted, UNTIL the price hits it again in the future (Virgin Point of Control).
So, for the Weekly chart the Monthly POC, for the Daily Chart the Weekly POC and for the 60min. chart the Daily POC to be carrying forward, until price hits them in the future. How can I do that?
 

XeoNoX

Well-known member
VIP
i hand typed the COG Center of Gravity code for TOS ( thinkorswim ) thinkscript indicator study that was posted above, since i cant copy and paste the picture. Here it is in easier copy and paste format. Please keep entire code intact.

Code:
# Ehlers_COG (Center Of Gravity)
# by growex
# Posted by: Mobius
# 12.18.2017
# Mobius: Someone was asking for a COG study with bands. Cog is an
# unbounded oscillartor as designed by Ehlers. It would need to be
# normalized to the price chart to have bands. Otherwise a 1 bar
# lag on the oscillator gives very good signals. COG is 1 weighted
# average shifted backwards to their center of lag or balance thus
# the name. I was picturing the lagged second line or signal line
# as the second of two but that's actually the same WAVG just
# lagged one bar
#
# Mobius: This study is an accurate translation of Ehlers Center
# Of Gravity.

declare lower;

input price = hl2;
input length = 10;

def Num = fold i = 0 to length -1
with n
do n + (1 + i) * getvalue(price, i , length - 1);
def denom = fold j = 0 to length -1
with k
do k + getvalue(price, j, length -1);
def CG = if denom <> 0 then -Num/Denom else double.NaN;

plot cgline = cg;
cgline.SetDefaultColor(color.green);
plot trigger = cgline[1];
trigger.setdefaultcolor(color.red);
addcloud(cgline, trigger, color.green, color.red);

#End Code Ehlers Center Of Gravity
 

tomsk

Well-known member
VIP
Here is what I thought was a cool COG (Center of Gravity) study that someone posted in the lounge several years ago. I happened to find it in my files, thought I'd share it with the community

Code:
# Adaptive COG
# califj
# 8.5.2017

input price = close;
input CenterLine = 30;
def bar = CenterLine;

input CenterLine2 = 60;
input CenterLine3 = 100;
def length = -bar;

def displacement = (length / 2) + 1;
def dPrice = price[displacement];

def CMA = if !IsNaN(dPrice) then Average(dPrice, AbsValue(length)) else CMA[1] + (CMA[1] - CMA[2]);
def CenteredMA = if !IsNaN(price) then ExpAverage(CMA, bar) else Double.NaN;

plot Center =  CenteredMA;
Center.SetDefaultColor(Color.CYAN);
Center.SetStyle(Curve.SHORT_DASH);
plot Center2 =  if !IsNaN(price) then ExpAverage(CMA, CenterLine2) else Double.NaN;
Center2.SetDefaultColor(Color.LIME);
Center2.SetStyle(Curve.SHORT_DASH);
plot Center3 =  if !IsNaN(price) then ExpAverage(CMA, CenterLine3) else Double.NaN;
Center3.SetDefaultColor(Color.MAGENTA);
Center3.SetStyle(Curve.SHORT_DASH);

def pct = 100;
input width = 75;
def d = width / pct;
def d1 = 0.809 * d;
def d2 = 1.0 * d;
def d3 = 1.618 * d;
def stdDeviation = HighestAll("data" = AbsValue(CenteredMA - price));

plot UpperLine = CenteredMA + stdDeviation * d1;
plot LowerLine = CenteredMA - stdDeviation * d1;
plot UpperLine1 = CenteredMA + stdDeviation * d2;
plot LowerLine1 = CenteredMA - stdDeviation * d2;
plot UpperLine2 = CenteredMA + stdDeviation * d3;
plot LowerLine2 = CenteredMA - stdDeviation * d3;

UpperLine.SetDefaultColor(Color.GRAY);
UpperLine1.SetDefaultColor(Color.LIGHT_RED);
UpperLine2.SetDefaultColor(Color.RED);
LowerLine.SetDefaultColor(Color.GRAY);
LowerLine1.SetDefaultColor(Color.LIGHT_GREEN);
LowerLine2.SetDefaultColor(Color.GREEN);

def crossup = close > center and center2;
def crossdn = close < center and center2;
AddLabel(crossup, " crosses above", Color.GREEN);
AddLabel(crossdn, " crosses below", Color.RED);

Alert(Crosses(high, UpperLine2, CrossingDirection.ABOVE), " price crosses over upper line2!");
Alert(Crosses(low, LowerLine2, CrossingDirection.BELOW), " price crosses over lower line2!");

AddCloud(close, Center, Color.GREEN, Color.RED);
AddCloud(UpperLine, UpperLine1, Color.PINK, Color.PINK);
AddCloud(LowerLine, LowerLine1, Color.LIGHT_GREEN, Color.LIGHT_GREEN);

AddCloud(UpperLine2, UpperLine1, Color.RED, Color.RED);
AddCloud(LowerLine2, LowerLine1, Color.GREEN, Color.GREEN);
def bound1 = HighestAll(high) * 2;
def bound2 = LowestAll(low) / 2;
def cond1 = (close crosses below UpperLine1);
def cond2 = (close crosses above LowerLine1);

AssignPriceColor(if close > center and center2 and center3 then Color.BLUE else if close < center and center2 and center3 then Color.DARK_ORANGE else Color.GRAY);

We have Monkey Bars (several iterations) Volume Profile TPO Profile and a User Defined Profile all of which can be set to defined ranges. So yeah there's alternatives.

Code:
#
# TD Ameritrade IP Company, Inc. (c) 2010-2018
#

input pricePerRowHeightMode = {default AUTOMATIC, TICKSIZE, CUSTOM};
input customRowHeight = 1.0;
input aggregationPeriod = {"1 min", "2 min", "3 min", "4 min", "5 min", "10 min", "15 min", "20 min", default "30 min", "1 hour", "2 hours", "4 hours", "Day", "2 Days", "3 Days", "4 Days", "Week", "Month"};
input timePerProfile = {default CHART, MINUTE, HOUR, DAY, WEEK, MONTH, "OPT EXP", BAR, YEAR};
input multiplier = 1;
input onExpansion = yes;
input profiles = 1000;
input showMonkeyBar = yes;
input showThePlayground = yes;
input thePlaygroundPercent = 70;
input opacity = 100;
input emphasizeFirstDigit = no;
input markOpenPrice = yes;
input markClosePrice = yes;
input volumeShowStyle = MonkeyVolumeShowStyle.NONE;
input showVolumeVA = yes;
input showVolumePoc = yes;
input theVolumePercent = 70;
input showInitialBalance = yes;
input initialBalanceRange = 3;

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);
def periodMin = Floor(seconds / 60 + day_number * 24 * 60);
def periodHour = Floor(seconds / 3600 + day_number * 24);
def periodDay = countTradingDays(Min(first(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
def periodWeek = Floor(day_number / 7);
def periodMonth = month - first(month);

switch (timePerProfile) {
case CHART:
    period = 0;
case MINUTE:
    period = periodMin;
case HOUR:
    period = periodHour;
case DAY:
    period = periodDay;
case WEEK:
    period = periodWeek;
case MONTH:
    period = periodMonth;
case "OPT EXP":
    period = exp_opt - first(exp_opt);
case BAR:
    period = barNumber() - 1;
case YEAR:
    period = getYear() - first(getYear());
}

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

def timeInterval;
def aggMultiplier;
switch (aggregationPeriod) {
case "1 min":
    timeInterval = periodMin;
    aggMultiplier = 1;
case "2 min":
    timeInterval = periodMin;
    aggMultiplier = 2;
case "3 min":
    timeInterval = periodMin;
    aggMultiplier = 3;
case "4 min":
    timeInterval = periodMin;
    aggMultiplier = 4;
case "5 min":
    timeInterval = periodMin;
    aggMultiplier = 5;
case "10 min":
    timeInterval = periodMin;
    aggMultiplier = 10;
case "15 min":
    timeInterval = periodMin;
    aggMultiplier = 15;
case "20 min":
    timeInterval = periodMin;
    aggMultiplier = 20;
case "30 min":
    timeInterval = periodMin;
    aggMultiplier = 30;
case "1 hour":
    timeInterval = periodHour;
    aggMultiplier = 1;
case "2 hours":
    timeInterval = periodHour;
    aggMultiplier = 2;
case "4 hours":
    timeInterval = periodHour;
    aggMultiplier = 4;
case "Day":
    timeInterval = periodDay;
    aggMultiplier = 1;
case "2 Days":
    timeInterval = periodDay;
    aggMultiplier = 2;
case "3 Days":
    timeInterval = periodDay;
    aggMultiplier = 3;
case "4 Days":
    timeInterval = periodDay;
    aggMultiplier = 4;
case "Week":
    timeInterval = periodWeek;
    aggMultiplier = 1;
case "Month":
    timeInterval = periodMonth;
    aggMultiplier = 1;
}

def agg_count = compoundvalue(1, if timeInterval != timeInterval[1] then (getValue(agg_count, 1) + timeInterval - timeInterval[1]) % aggMultiplier else getValue(agg_count, 1), 0);
def agg_cond = compoundvalue(1,  agg_count < agg_count[1] + timeInterval - timeInterval[1], yes);

def digit = compoundValue(1, if cond then 1 else agg_cond + getValue(digit, 1), 1);

profile monkey = monkeyBars(digit, "startNewProfile" = cond, "onExpansion" = onExpansion,
"numberOfProfiles" = profiles, "pricePerRow" = height, "the playground percent" = thePlaygroundPercent,
"emphasize first digit" = emphasizeFirstDigit, "volumeProfileShowStyle" = volumeShowStyle, "volumePercentVA" = theVolumePercent,
 "show initial balance" = showInitialBalance, "initial balance range" = initialBalanceRange);
def con = compoundValue(1, onExpansion, no);
def mbar = compoundvalue(1, if IsNaN(monkey.getPointOfControl()) and con then getValue(mbar, 1) else monkey.getPointOfControl(), monkey.getPointOfControl());
def hPG = compoundvalue(1, if IsNaN(monkey.getHighestValueArea()) and con then getValue(hPG, 1) else monkey.getHighestValueArea(), monkey.getHighestValueArea());
def lPG = compoundvalue(1, if IsNaN(monkey.getLowestValueArea()) and con then getValue(lPG, 1) else monkey.getLowestValueArea(), monkey.getLowestValueArea());

def hProfile = compoundvalue(1, if IsNaN(monkey.getHighest()) and con then getValue(hProfile, 1) else monkey.getHighest(), monkey.getHighest());
def lProfile = compoundvalue(1, if IsNaN(monkey.getLowest()) and con then getValue(lProfile, 1) else monkey.getLowest(), monkey.getLowest());
def plotsDomain = IsNaN(close) == onExpansion;

plot MB = if plotsDomain then mbar else Double.NaN;
plot ProfileHigh = if plotsDomain then hProfile else Double.NaN;
plot ProfileLow = if plotsDomain then lProfile else Double.NaN;
plot PGHigh = if plotsDomain then hPG else Double.NaN;
plot PGLow = if plotsDomain then lPG else Double.NaN;

DefineGlobalColor("Monkey Bar", GetColor(4));
DefineGlobalColor("The Playground", GetColor(3));
DefineGlobalColor("Open Price", GetColor(1));
DefineGlobalColor("Close Price", GetColor(1));
DefineGlobalColor("Volume", GetColor(8));
DefineGlobalColor("Volume Value Area", GetColor(2));
DefineGlobalColor("Volume Point of Control", GetColor(3));
DefineGlobalColor("Initial Balance", GetColor(7));

monkey.show(color.red, if showMonkeyBar then globalColor("Monkey Bar") else color.current,
 if showThePlayground then globalColor("The Playground") else color.current,
 opacity, if markOpenPrice then globalColor("Open Price") else color.current,
 if markClosePrice then globalColor("Close Price") else color.current,
 if showInitialBalance then globalColor("Initial Balance") else color.current,
 globalColor("Volume"),
 if showVolumeVA then globalColor("Volume Value Area") else color.current,
 if showVolumePOC then globalColor("Volume Point of Control") else color.current);
MB.SetDefaultColor(globalColor("Monkey Bar"));
MB.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PGHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PGLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PGHigh.SetDefaultColor(globalColor("The Playground"));
PGLow.SetDefaultColor(globalColor("The Playground"));
ProfileHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ProfileHigh.SetDefaultColor(GetColor(3));
ProfileLow.SetDefaultColor(GetColor(3));
ProfileHigh.hide();
ProfileLow.hide();
 

ssara

New member
VIP
Hello Experts.

I am wondering if we have an Indicator which will locate yesterday Value High - Value Low - Point Of Control so we can plot them after new market session opens.

Second if we can do the same for 30 minutes profiles also. Take last 30 minute profile and plot it ahead for next 30 minutes.
 

dileep349

New member
I am interested in your VPOC settings. I have been looking at ways to have the VPOC for previous days marked. Can you please share your Volume Profile settings please?

Does anyone know if prior day's volume profile data can be referenced such as GetPointofControl()[1] or[2]...etc? When I've tried this in the past I could not get it to work but want to revisit this. I'd like to carry forward POC's and yesterdays value area as an example. Thanks
 

paige706

New member
2019 Donor
Hey, would you mind sharing your settings? I'm using tos and I'm just learning about volume profile. Do you find it helpful for intraday trading? thank you!
 

BlueRaven

New member
From everything I've poked around with I don't think this can be done, but I wanted to ask anyway.

It looks like TOS has the volume profile study locked down so you can only pull POC/Value area. I want to be able to pull data for basically each line / price level.

Basically I would like to automatically look for HVN's, LVN's and edges etc. If TOS can't do it does anyone know of another platform that has that data available ?

Found this script: http://tos.mx/s4SLQt

Code:
# Begin Code --------------------------------------------------------------------
# Mobius
# Mobius.rts[at]gmail.com
# Study Name:  Mobius_Volume_Profile_Plus
# Copy and paste the above name to the Study name before saving the new study.
# V02102011.14
# Study Number 112
# Notes: This is not a recommendation or endorsement to trade any equity.
# Trading has extreme risk and you should not trade equities without fully understanding all risks associated with trading.
# Day trading or Intraday trading could and often does cause extreme financial loss.
#Hint: Volume Profile with Fibonacci Levels and Directional Day Filter.\n \n Aggregation for Volume Profile must be set at a higher level than chart aggregation. \n The Directional Day Filter calculates an average of the first 5Min bar and the extreme values above and below that line for the defined period. \n If the periods closing above the line are grater than those below the day will finish above that line approximately 65% of the time. \n Below the opposite holds true. \n On even distribution days it indicates the likelihood of a flat day. \n At a turn from either extreme of the range the trend will likely be to the opposite side of the range after 1 ATR. \n Target should be the closest Fibonacci. \n If the volume is rising move stop to that level, take 1/2 off and let the trade run to the next Fibonacci, take another 1/2 off and continue to the other extreme end of the range. \n If the extreme of either end of the range is breached it is likely to continue past the breech for 1 ATR. \n If the volume spikes above the norm for the day it is likely to trend further and moving stops each
 

Pensar

Well-known member
VIP
@BlueRaven It certainly doesnt seem possible. I do have this code by Mobius, although it is likely not what you're looking for.

Code:
# High Volume Nodes
# Mobius
# V01.02.2018
# Looks for the highest volume candle in "n" periods and plots the candle range.
# As Volatility increases this study has two values. Plotting a current high volume node as a channel which price will be drawn back to and test since a very high volume node will move price quickly, and price will retest that area. And, with the legacy plots a way to quickly see if larger traders, those that can generate a high volume node, are accumulating or distributing inventory.

input n = 60;
input r = .95;
input LegacyPoints = yes;

def h = high;
def l = low;
def c = close;
def v = volume;
def x = barNumber();
def HighVolume = if ((v - Lowest(v, n)) / (Highest(v, n) - Lowest(v, n))) >= r
                 then x
                 else Double.NaN;
def hh = if !IsNaN(HighVolume)
         then h
         else hh[1];
def ll = if !IsNaN(HighVolume)
         then l
         else ll[1];
plot hhLine = if x >= HighestAll(HighVolume)
              then HighestAll(if IsNaN(c)
                              then hh
                              else Double.NaN)
              else Double.NaN;
hhLine.SetDefaultColor(Color.GRAY);
plot llLine = if x >= HighestAll(HighVolume)
              then HighestAll(if IsNaN(c)
                              then ll
                              else Double.NaN)
              else Double.NaN;
llLine.SetDefaultColor(Color.GRAY);
plot legacy = if LegacyPoints and !IsNaN(HighVolume)
              then l - (2*TickSize())
              else Double.NaN;
legacy.SetStyle(Curve.POINTS);
legacy.SetLineWeight(3);
legacy.SetDefaultColor(Color.Gray);
AddCloud(llLine, hhLine, Color.DARK_GRAY, Color.DARK_GRAY, yes);
# End Code High Volume Nodes
 

AMA

New member
From everything I've poked around with I don't think this can be done, but I wanted to ask anyway.

It looks like TOS has the volume profile study locked down so you can only pull POC/Value area. I want to be able to pull data for basically each line / price level.

Basically I would like to automatically look for HVN's, LVN's and edges etc. If TOS can't do it does anyone know of another platform that has that data available ?

1) Copy all of the stock TOS Volume Profile study code into a new study you're creating(maybe call it VolumeProfileME, or whatever you want).

2) Once created, you can edit the new study and manipulate code and/or variables to do rather interesting things.

Some of what I experimented with were:

-- Showing various levels for today vs. other levels for previous days
.
-- Continuing a level from yesterday onto today's chart(ex: yesterday's POC extends to show on today's chart; very handy, as you can then show/hide prices, use algorithms against yesterday's POC value, etc.).

-- Placing price bubbles/comments/labels/markers/whatever for diff variables and/or labels.

-- Show bubbles when approaching a particular level, such as LVA or POC, etc. to give me a heads up.

-- Set some of the defaults more to my liking. Gets old adding the stock/TOS study to charts and having to change -their- defaults each time.

I no longer use Volume Profile, etc. all that much, but I still have it showing; more as a confirmation thing than anything else.
 

dschapira

New member
Hello, I downloaded this support and resistance study based on volume profile, but its only for tradestation. Could anyone make one for TOS?
Here is the tradestation code if it helps. I am willing to pay for the code.

Code:
int TopVolPivots( 5 ), // The total number of lines to be drawn, with the highest occurrence values. TopVolPivots can be a positive integer up to 20
            int Strength( 3 ), // Strength of pivots
           
            // Define colors for lines
            int Color1( Red ),
            int Color2( Magenta ),
            int Color3( Green ),
            int Color4( Cyan ),
            int Color5( Yellow ),
            int Color6( White ),
            int Color7( White ),
            int Color8( LightGray ),
            int Color9( LightGray ),
            int Color10( LightGray ),
           
            // Define line styles for lines
            int LineStyle1( 0 ),
            int LineStyle2( 0 ),
            int LineStyle3( 0 ),
            int LineStyle4( 0 ),
            int LineStyle5( 0 ),
            int LineStyle6( 0 ),
            int LineStyle7( 0 ),
            int LineStyle8( 0 ),
            int LineStyle9( 0 ),
            int LineStyle10( 0 ),
           
            string FontName( "Ariel" ), // Sets the font of the line labels
            double FontSize( 10 ), // Sets the font size for the line labels
           
            int LineThickness( 1 ), // Defines thickness of lines. LineTickness can be a positive integer up to 6
            int UpdareFrequency( 5000 ), // Determines how often the timer checks for changes in the upper and lower price values. In milliseconds
            bool DrawLabels( True ); // If set to TRUE line labels are drawn.

Vars:        Vector TLVector( Null ), // Stores references for trend lines
            Vector LineLabelVector( Null ), // Stores references for text drawing objects
           
            Vector ColorVector( Null ), // Vector to store color information from user inputs
            Vector LineStyleVector( Null ), // Vector to store line styles from the user inputs
           
            TrendLine Trendline1( Null ),
            TrendLine myTrendLine1( Null ),
            TextLabel LineText( Null ),
           
            DTPoint DTPoint1( Null ), // DateTime point used in the creation of trendlines
            DTPoint DTPoint2( Null ), // DateTime point used in the creation of trendlines
           
            Intrabarpersist bool ScreenSizeChanged( False ),
            intrabarpersist double HighestDispValueLast( 0 ), // Stores highest display value visible
            intrabarpersist double LowestDispValueLast( 0 ),  // Stores lowest display value visible
            IntrabarPersist bool LastBarOnCht( False ), // Set to true if last bar on chart
           
            string Txt(""),
            int DecPlaces( 0 ),
           
            DateTime RightOfChart( Null ), // Stores the datetime of the right of the chart in datetime format
           
            Dictionary PriceVolume( Null ), // Dictionary that stores the entire volume profile for the entire history
            Dictionary PriceVolumeInRange( Null ), // A dictionary that just stores the volume profile for the current price range visible
           
            Vector RankedVolVec( Null ), // A vector containing price levels as strings ranked by volume
           
            double VolVal( 0 ), // Stores volume depending on chart type
           
            bool debug( false ); // Prints the dictionary and vector for debugging

// Method to sort dictionary keys into a vector by volume order with the keys with the highest volume higher in the vector
Method vector DictionaryVolSort( Dictionary Dict2bSortedbyVol )
Vars: string TmpIndex, double TmpVol, Vector Keys, Vector Vols;
Begin
    Keys = Dict2bSortedbyVol.Keys; // Create a vector from the dictionary keys
    Vols = Dict2bSortedbyVol.Values; // Create a vector from the dictionary values
    For Value1 = 0 to Dict2bSortedbyVol.Count - 1
    Begin
        For Value2 = ( Value1 + 1 ) to Dict2bSortedbyVol.Count - 1
        Begin
            If Vols[Value1] astype double < Vols[Value2] astype double then
            Begin
                //Print(" VOL SORT ", Dict2bSortedbyVol.Values[Value1] astype double," should be less than ", Dict2bSortedbyVol.Values[Value2] astype double );
                TmpIndex = Keys[Value1] astype string;
                TmpVol = Vols[Value1] astype double;
               
                Keys[Value1] = Keys[Value2] astype string;
                Vols[Value1] = Vols[Value2] astype double;
               
                Keys[Value2] = TmpIndex;
                Vols[Value2] = TmpVol;
            End;
        End;
    End;
    Return Keys;
End;

// Method to find volume pivots in a dictionary already sorted by price
Method Dictionary VolumePivots( Dictionary FindPivots )
Vars: bool PivotTest, int StrengthCtr, Dictionary TmpDict;
Begin
    TmpDict = New Dictionary;
    // Test each price level (except the number strength at the top as there are no bars above to test and 'FindPivots.Count - Strength - 1' at the bottom)
    For Value1 = Strength to FindPivots.Count - Strength - 1
    Begin
        // Print( "PivotFinder ", Value1, " Strength ", Strength );
        PivotTest = TRUE; // Assume it is a pivot, until proved otherwise
        StrengthCtr = 1; // Reset strength counter
        // First test below pivot
        While PivotTest = TRUE and StrengthCtr <= Strength
        Begin
            If FindPivots.Values[Value1] astype double < FindPivots.Values[Value1 + StrengthCtr] astype double then PivotTest = False
            Else StrengthCtr +=1; // Increment StrengthCtr by 1
        End;
        // If first test was passed now check above the pivot
        StrengthCtr = 1;
        While PivotTest = TRUE and StrengthCtr <= Strength
        Begin
            If FindPivots.Values[Value1] astype double < FindPivots.Values[Value1 - StrengthCtr] astype double then PivotTest = False
            Else StrengthCtr +=1; // Increment StrengthCtr by 1
        End;       
        // If a pivot is found, add to a local dictionary
        If PivotTest = True then TmpDict.Add( FindPivots.Keys[Value1] astype string, FindPivots.Values[Value1] astype double ); // Print("****** ",  FindPivots.Keys[Value1] astype string, FindPivots.Values[Value1] astype double );
        PivotTest = False;
    End;
    Return TmpDict;
End;

// Method to draw initial trend lines and text, otherwise, if already drawn move their positions
Method void TLDictDrawOrRedraw( )
Begin
    If TLVector.Count = 0 then
    Begin
        For Value1 = 0 to TopVolPivots - 1
        Begin
            // Add initial TopVolPivots lines to chart
            DTPoint1 = DTPoint.Create( BarDateTime, 0 );
            Trendline1 = Trendline.Create( DTPoint1, DTPoint1 );
            Trendline1.ExtRight = True;
            Trendline1.ExtLeft = True;
            Trendline1.Persist = True;
            DrawingObjects.Add( Trendline1 );
            TLVector.push_back( Trendline1 );
           
            // Add initial labels to chart
            If DrawLabels then
            Begin
                LineText = TextLabel.Create( DTPoint1,"");
                LineText.VStyle = 0;
                LineText.HStyle = 1;
                LineText.Persist = True;
                LineText.Font = Font.create( FontName, FontSize );
                DrawingObjects.Add( LineText );
                LineLabelVector.push_back( LineText );
            End;
        End;
    End
    Else // If text objects have already been drawn
    Begin
        For Value1 = 0 to TLVector.Count - 1
        Begin
            // Move all existing lines out of the visible area
            DTPoint1 = DTPoint.Create( BarDateTime, 0 );
            myTrendLine1 = TLVector[Value1] astype Trendline;
            myTrendLine1.SetStartPoint( DTPoint1 );
            myTrendLine1.SetEndPoint( DTPoint1 );
            myTrendLine1.Weight = LineThickness;
           
            // Move labels out of the way
            If DrawLabels then
            Begin
                LineText = LineLabelVector[Value1] astype TextLabel;
                LineText.PointValue = DTPoint1;
            End;
        End;
       
        // Now re-position lines based on the sorted dictionary containing the sorted volume pivot levels
        For Value1 = 0 to MinList( TLVector.Count - 1, RankedVolVec.Count - 1 ) // Uses minlist because there may be less than TLVector.Count - 1 in sorted pivot array
        Begin
            RightOfChart = DateTime.FromELDateAndTime( JulianToDate( IntPortion( GetAppInfo( aiRightDispDateTime ) ) ), MinutesToTime( FracPortion( GetAppInfo( aiRightDispDateTime ) ) * 60 * 24));
            DTPoint1 = DTPoint.Create( RightOfChart, StrToNum( RankedVolVec[Value1] astype string ) );
            DTPoint2 = DTPoint.Create( RightOfChart, StrToNum( RankedVolVec[Value1] astype string ) );
           
            // Move trendlines
            myTrendLine1 = TLVector[Value1] astype Trendline;
            myTrendLine1.SetStartPoint( DTPoint1 );
            myTrendLine1.SetEndPoint( DTPoint2 );
           
            // Move the text labels
            If DrawLabels then
            Begin
                LineText = LineLabelVector[Value1] astype TextLabel;
                //LineText.TextString = NumToStr( StrToNum( RankedVolVec[Value1] astype string ), DecPlaces );
                LineText.TextString = RankedVolVec[Value1] astype string;
                LineText.PointValue = DTPoint2;
            End;
           
            // Set color of lines
            If Value1 <= 9 then myTrendline1.Color = Color.FromArgb( 255, getRvalue( ColorVector[Value1] astype int ), getGvalue( ColorVector[Value1] astype int ), getBvalue( ColorVector[Value1] astype int ) )
            // Draw at a darker sahe by altering the alpha value
            Else If Value1 <= 19 then myTrendline1.Color = Color.FromArgb( 150, getRvalue( ColorVector[Value1-10] astype integer ), getGvalue( ColorVector[Value1-10] astype integer ), getBvalue( ColorVector[Value1 - 10] astype integer ) ) ;
            // Set line style
            If Value1 <= 9 then myTrendline1.Style = LineStyleVector[Value1] astype int
            Else If Value1 <= 19 then myTrendline1.Style = LineStyleVector[Value1-10] astype int;
           
            // Set color of text
            If DrawLabels then
            Begin
                If Value1 <= 9 then LineText.Color = Color.FromArgb( 255, getRvalue( ColorVector[Value1] astype int ), getGvalue( ColorVector[Value1] astype int ), getBvalue( ColorVector[Value1] astype int ) )
                Else If Value1 <= 19 then LineText.Color = Color.FromArgb( 150, getRvalue( ColorVector[Value1-10] astype integer ), getGvalue( ColorVector[Value1-10] astype integer ), getBvalue( ColorVector[Value1 - 10] astype integer ) ) ;
            End;           
        End;
    End;
    // Condition1 = VectorPrint( "*", PivotVector );
End;

// Makes sure a screen size change is found even if no price ticks occurring (i.e. if the market is closed)
Method void Timer1_Elapsed_1( elsystem.Object sender, elsystem.TimerElapsedEventArgs args )
begin
   
    ScreenSizeChanged = HighestDispValueLast <> GetAppInfo( aiHighestDispValue ) or LowestDispValueLast <> GetAppInfo( aiLowestDispValue );
    HighestDispValueLast = GetAppInfo( aiHighestDispValue );
    LowestDispValueLast = GetAppInfo( aiLowestDispValue );
   
    // Print(" Highest and Lowest ", D, T," ", GetAppInfo( aiHighestDispValue ):5:5, " HighestDispValueLast ",HighestDispValueLast:5:5," ", GetAppInfo( aiLowestDispValue ):5:5 ," LowestDispValueLast ",LowestDispValueLast:5:5," ScreenSizeChanged ", ScreenSizeChanged );
   
    If ScreenSizeChanged then Redraw();
End;

// Move the labels to the right of the chart
Method void MoveLabels( )
Begin
    // Reposition labels based on the sorted vector containing the sorted pivot levels
    For Value1 = 0 to LineLabelVector.Count - 1
    Begin
        RightOfChart = DateTime.FromELDateAndTime( JulianToDate( IntPortion( GetAppInfo( aiRightDispDateTime ) ) ), MinutesToTime( FracPortion( GetAppInfo( aiRightDispDateTime ) ) * 60 * 24));
        LineText = LineLabelVector[Value1] astype TextLabel;
        DTPoint2 = DTPoint.Create( RightOfChart, Linetext.PointValue.Price astype double );
       
        // Move the text labels to right of chart
        LineText.PointValue = DTPoint2;
    End;
End;

// Method to resample the main volume profile dictionary for prices visible on the screen
Method void Redraw( )
Begin
    ScreenSizeChanged = FALSE;
   
    // Recreate a smaller dictionary as a subset of the PriceVolume dictionary to just contain pivots that are within the screen range
    // PivotVectorInRange.clear( );
    PriceVolumeInRange.Clear( );
   
    For Value1 = 0 to PriceVolume.Count - 1
    Begin
        // If Getsymbolname = "@YM" then Print( File("c:\progr55-1-2data.txt"), D, T, " PivotVectorInRange.Count ", PivotVectorInRange.Count );
        If StrToNum( PriceVolume.Keys[Value1] astype string ) < GetAppInfo( aiHighestDispValue )
        and StrToNum( PriceVolume.Keys[Value1] astype string ) > GetAppInfo( aiLowestDispValue )
        then PriceVolumeInRange.Add( PriceVolume.Keys[Value1] astype string, PriceVolume.Values[Value1] );
    End;
   
    If Debug then
    Begin
        For Value1 = 0 to PriceVolumeInRange.Count - 1
        Begin
            If getSymbolName = "@YM" then Print( Value1," ", D, T, " Key ",PriceVolumeInRange.Keys[Value1] astype string," Vol ", PriceVolumeInRange.Values[Value1] astype double );
        End;
    End;
   
    // Return a dictionary that just contains the key/volume pairs of volume pivots
    PriceVolumeInRange = VolumePivots( PriceVolumeInRange );
   
    If Debug then
    Begin
        For Value1 = 0 to PriceVolumeInRange.Count - 1
        Begin
            If getSymbolName = "@YM" then Print( "PIVOTS BEFORE VOL SORT",Value1," ", D, T, " Key ",PriceVolumeInRange.Keys[Value1] astype string," Vol ", PriceVolumeInRange.Values[Value1] astype double );
        End;
    End;
   
    // Return a vector of the keys (i.e. prices) ranked by volume
    RankedVolVec = DictionaryVolSort( PriceVolumeInRange );
   
    If Debug then
    Begin
        For Value1 = 0 to RankedVolVec.Count - 1
        Begin
            If getSymbolName = "@YM" then Print( "PIVOTS AFTER VOL SORT",Value1," ", D, T, " Key ",RankedVolVec[Value1] astype string," ", Maxbarsback );
        End;
    End;
   
    // Call the TLDictDrawOrRedraw method
    TLDictDrawOrRedraw( );
    //Condition1 = VectorPrint( "IR", PivotVectorInRange );
End;

// Store volume depending on chart type and interval
if BarType >= 2 and BarType < 5 then { not tick/minute data nor an advanced chart type (Kagi, Renko, Kase etc.) } VolVal = Volume
else { if tick/minute data or an advanced chart type;  in the case of minute data, also set the "For volume, use:" field in the Format Symbol dialog to Trade Vol or
Tick Count, as desired;  when using advanced chart types, Ticks returns volume if the chart is built from 1-tick interval data } VolVal = Ticks ;

Once
Begin
    // Raise run time errors for wrongly set inputs
    If TopVolPivots > 20 then RaiseRuntimeError( "The TopVolPivots input must be " +
         "an integer less than or equal to 20." ) ;
    If LineThickness < 0 or LineThickness > 6 then RaiseRuntimeError( "The LineThickness input must be " +
         "an integer between 0 and 6." ) ;

    TLVector = New Vector;
    LineLabelVector = New Vector;
   
    ColorVector = New Vector;
   
    PriceVolume = New Dictionary;
    PriceVolumeInRange = New Dictionary;
    RankedVolVec = New Vector;
   
    // Store colors in the ColorVector
    ColorVector.push_back( Color1 );
    ColorVector.push_back( Color2 );
    ColorVector.push_back( Color3 );
    ColorVector.push_back( Color4 );
    ColorVector.push_back( Color5 );
    ColorVector.push_back( Color6 );
    ColorVector.push_back( Color7 );
    ColorVector.push_back( Color8 );
    ColorVector.push_back( Color9 );
    ColorVector.push_back( Color10 );
   
    LineStyleVector = New Vector;
   
    // Store line styles in the LineStyleVector
    LineStyleVector.push_back( LineStyle1 );
    LineStyleVector.push_back( LineStyle2 );
    LineStyleVector.push_back( LineStyle3 );
    LineStyleVector.push_back( LineStyle4 );
    LineStyleVector.push_back( LineStyle5 );
    LineStyleVector.push_back( LineStyle6 );
    LineStyleVector.push_back( LineStyle7 );
    LineStyleVector.push_back( LineStyle8 );
    LineStyleVector.push_back( LineStyle9 );
    LineStyleVector.push_back( LineStyle10 );
   
    // Determine the number of decimal places required for text drawing
    Txt = NumToStr( FracPortion( MinMove / PriceScale ), 5 );
    If RightStr( Txt, 1 ) <> "0" then DecPlaces = 5;
    If RightStr( Txt, 2 ) = "00" then DecPlaces = 3;
    If RightStr( Txt, 3 ) = "000" or RightStr( Txt, 4 ) = "0000" then DecPlaces = 2;
    //If RightStr( Txt, 4 ) = "0000" then DecPlaces = 1;
    If RightStr( Txt, 5 ) = "00000" then DecPlaces = 0;
   
    ClearPrintLog;
End;

// On last tick of each bar see if new pivot has occurred, if so add to PivotVector
If BarStatus( 1 ) = 2 then
Begin
    // Run redraw on the close of each bar
    If DrawLabels then MoveLabels( );
   
    // At the close of each bar store the volume for the specific price
    // If a volume is already stored for that price, add it to the existing volume, otherwise store it
    If PriceVolume.Contains( NumToStr( C, DecPlaces ) ) then
    PriceVolume.Items[ NumToStr( C, DecPlaces ) ] = PriceVolume.Items[ NumToStr( C, DecPlaces ) ] astype double + VolVal
    Else PriceVolume.Add( NumToStr( C, DecPlaces ), VolVal );
    //If GetSymbolName = "@YM" and C = 15740 then Print(D," ", T, " VolVal ", VolVal );
   
    //If GetSymbolName = "@YM" then Print(D," ", T, " Add vol data ", VolVal, " PriceVolume.Items[ NumToStr( C, DecPlaces ) ] astype double ", PriceVolume.Items[ NumToStr( C, DecPlaces ) ] astype double );
End;

// Run the Redraw() method when first applied to the chart
Once ( GetAppInfo( aiRealTimeCalc ) = 1 or ( D = JulianToDate( LastCalcJDate ) and LastCalcMMTime = 60 * IntPortion( T * 0.01 ) + 100 * FracPortion( T * 0.01 ) ) ) LastBarOnCht = True;

// Do the initial calculation to calculate the levels an draw the horizontal lines
If LastBarOnCht then
Once
Begin
    Redraw( );
    //Print( "LastBarOnCht ", D, T );
End;

// Print(" Highest and Lowest ", D, T," ", GetAppInfo( aiHighestDispValue ):5:5, " ", GetAppInfo( aiLowestDispValue ):5:5 );
 
Last edited by a moderator:

jngy2k

Member
VIP
Question: The AAPL chart is how I have my TOS volume profile setup.
I have 'price per height' as "Ticksize" + "time per profile" as "Day" + "on expansion" "no" + "show value area" "no".
This is as close as I can get it to the volume profile of a twitter post I saw on the bottum chart of GNPX.
And I am envious of how they did their volume profile!
Somehow, they are able to have expansion volume profile of the chart added to the "no" "on expansion" chart.
How in the heck did they do that??



7fRIh6N.png
hg07EXp.png
 

Similar threads

Top