Sharing the study with you since you were able to help me. Plots the value area of the designated time period.
Created by SleepZ here:
https://usethinkscript.com/threads/how-to-view-a-quarter-3-month-period-for-volume-profile.6111/
Created by SleepZ here:
https://usethinkscript.com/threads/how-to-view-a-quarter-3-month-period-for-volume-profile.6111/
Code:
# =================================
# Volume Profile Definition Section
# =================================
def profiles = 50;
def customRowHeight = 1.0;
def multiplier = 1;
def onExpansion = ShowTodayOnly;
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 qtr = if getmonth()==1 then 1 else if getmonth()==4 then 2 else if getmonth()==7 then 3 else if getmonth()==10 then 4 else qtr[1];
def period = qtr ;
#floor(qtr - first(qtr));
def height = PricePerRow.TICKSIZE;
rec count = CompoundValue(1, if period != period[1] then (count[1] + period - period[1]) % multiplier else count[1], 0);
def cond = if period==qtr then period!=period[1] else count < count[1] + period - period[1];
#============================
# Plot POC VAH VAL Section
#============================
profile tpo = if ProfileType == ProfileType.Volume then VolumeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent)
else TimeProfile("startNewProfile" = cond, "onExpansion" = onExpansion, "numberOfProfiles" = profiles, "pricePerRow" = height, "value area percent" = valueAreaPercent);
rec PC = if cond == 1 then tpo.GetPointOfControl()[1] else PC[1];
plot POC = Round(If(ValueAreaMode == ValueAreaMode."Auto", PC, if NewDay then PointOfControl else PC) / TickSize(), 0) * TickSize();
POC.SetDefaultColor(Color.WHITE);
POC.SetStyle(Curve.FIRM);
POC.SetLineWeight(2);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, POC, "POC", Color.WHITE, no);
rec hVA = if cond == 1 then tpo.GetHighestValueArea()[1] else hVA[1];
plot VAH = Round(If(ValueAreaMode == ValueAreaMode."Auto", hVA, if NewDay then ValueAreaHigh else hVA) / TickSize(), 0) * TickSize();
VAH.SetDefaultColor(Color.PINK);
VAH.SetStyle(Curve.FIRM);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, VAH, "VAH", Color.PINK, no);
rec lVA = if cond == 1 then tpo.GetLowestValueArea()[1] else lVA[1];
plot VAL = Round(If(ValueAreaMode == ValueAreaMode."Auto", lVA, if NewDay then ValueAreaLow else lVA) / TickSize(), 0) * TickSize();
VAL.SetDefaultColor(Color.Light_GREEN);
VAL.SetStyle(Curve.FIRM);
AddChartBubble(bar == HighestAll(bar) and ShowBubbles, VAL, "VAL", Color.Light_GREEN, no);
#============================
# VWAP Plot
#============================
def VWAP1 = Round(vwap(period = AggregationPeriod.QUARTER) / TickSize(), 0) * TickSize();
plot VWAP = if ShowVWAP > 0 then VWAP1 else Double.NaN;
VWAP.SetPaintingStrategy(PaintingStrategy.DASHES);
VWAP.SetDefaultColor(Color.YELLOW);
#============================
#Value Area Cloud & Labels
#============================
def VArea = Between(close, VAL, VAH);
def VAreaAbove = close > VAH;
def VAreaBelow = close < VAL;
def Cloudhigh = if ShowCloud then VAH else Double.NaN;
def Cloudlow = if ShowCloud then VAL else Double.NaN;
AddCloud(Cloudhigh, Cloudlow, GlobalColor("cloud"), GlobalColor("cloud"));
DefineGlobalColor("cloud", Color.GRAY);
Last edited by a moderator: