Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#

# Quant Trading App Volume Profile


# Created: September 15, 2021
#
# Credit: Bryant Littrean, Thinkorswim
# Contact: tradinglitt@gmail.com
# Trading Litt Youtube: https://bit.ly/trading-litt-yt
# Quant Trading App Discord: https://quanttradingdiscord.com
#

def multiplier = 1; def onExpansion = no; def profiles = 1000; input


showPointOfControl = yes; input showValueArea = yes; input valueAreaPercent = 68;
input opacity = 60; 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); period = countTradingDays(min(first(yyyymmdd), yyyymmdd), yyyymmdd)
- 1; def count = CompoundValue(1, if period != period[1] then (count[1] + period -
period[1]) % multiplier else count[1], 0); def cond = count < count[1] + period -
period[1]; def height = PricePerRow.TICKSIZE; 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", CreateColor(70, 70, 70));
DefineGlobalColor("Point Of Control", CreateColor(255, 215, 0));
DefineGlobalColor("Value Area", CreateColor(95, 140, 230));
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); POC.SetLineWeight(2);
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();

You might also like