Financial Volume with VWAP cloud for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
j1CcOeB.png

Author Message:
Financial Volume is the quantity of a certain asset traded multiplied by its price. In other others, it's the amount of money traded for that particular asset.
TradingView & TOS uses the "quantity" volume as standard (for a good reason) and actually there is no "right" volume but the quantity volume alone might give the wrong idea.
Samer800 - I added VWAP cloud to identify the increase on Volume. pls note that Volume bar color vary from the original volume indicator. More over, I added price bar color on the increased volume.

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0
#https://www.tradingview.com/script/wkuZN4TJ/
#indicator("Financial Volume with VWAP cloud")
# Created and mod by Sam4Cok@Samer800 based on @f1l1per. code - 11/2022
declare lower;
input BarColor = yes;      # 'Barcolor'
input Source = hlc3;
input showVwapCloud = yes;
input VwapTimeFrame = {default DAY,WEEK, MONTH};
input ShowMA_Line = yes;
input MA_Period = 30;  # "MA Period"

def na = Double.NaN;
def v = volume;
def c = close;
# volVWAP
script VVWAP {
    input src = close;
    input timeFrame = {DAY, WEEK,default MONTH};
    def v = Volume;
    def cap = GetAggregationPeriod();
    def errorInAggregation =
    timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
    timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH;
    Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
    def yyyyMmDd = GetYYYYMMDD();
    def periodIndx;
    switch (timeFrame) {
    case DAY:
        periodIndx = yyyyMmDd;
    case WEEK:
        periodIndx = Floor((DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd))) / 7);
    case MONTH:
        periodIndx = RoundDown(yyyyMmDd / 100, 0);
}
    def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);
    def volumeSum;
    def volumeVwapSum;
    if (isPeriodRolled) {
        volumeSum = v;
        volumeVwapSum = v * src;
    } else {
        volumeSum = CompoundValue(1, volumeSum[1] + v, v);
        volumeVwapSum = CompoundValue(1, volumeVwapSum[1] + v * src, v * src);
    }
    def price = volumeVwapSum / volumeSum;
    plot return = price;
}

def FV = Source * v;
def Volvwap = if showVwapCloud then VVWAP(FV, VwapTimeFrame) else 0;

#--- MA Line
def MA = SimpleMovingAvg(FV, MA_Period);
plot maLine = ma;
maLine.SetDefaultColor(Color.BLUE);
maLine.SetHiding(!ShowMA_Line);

#--------------------------------------------
plot FinancialVolume = FV;
FinancialVolume.AssignValueColor(if FV > Volvwap then if c>c[1] then CreateColor(50,201,86) else color.RED else Color.GRAY);
FinancialVolume.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
def VWAP = Volvwap;

#--- Cloud
AddCloud(VWAP, 0, Color.DARK_GRAY);

#--- Bar Color
AssignPriceColor(if !BarColor then Color.CURRENT else
                 if FV > Volvwap then if c>c[1] then Color.CYAN else color.MAGENTA else Color.CURRENT);
#--- END Clode
 
Last edited by a moderator:
View attachment 16376
Author Message:
Financial Volume is the quantity of a certain asset traded multiplied by its price. In other others, it's the amount of money traded for that particular asset.
TradingView & TOS uses the "quantity" volume as standard (for a good reason) and actually there is no "right" volume but the quantity volume alone might give the wrong idea.
Samer800 - I added VWAP cloud to identify the increase on Volume. pls note that Volume bar color vary from the original volume indicator. More over, I added price bar color on the increased volume.

CODE:
CSS:
#// This source code is subject to the terms of the Mozilla Public License 2.0
#https://www.tradingview.com/script/wkuZN4TJ/
#indicator("Financial Volume with VWAP cloud")
# Created and mod by Sam4Cok@Samer800 based on @f1l1per. code - 11/2022
declare lower;
input BarColor = yes;      # 'Barcolor'
input Source = hlc3;
input showVwapCloud = yes;
input VwapTimeFrame = {default DAY,WEEK, MONTH};
input ShowMA_Line = yes;
input MA_Period = 30;  # "MA Period"

def na = Double.NaN;
def v = volume;
def c = close;
# volVWAP
script VVWAP {
    input src = close;
    input timeFrame = {DAY, WEEK,default MONTH};
    def v = Volume;
    def cap = GetAggregationPeriod();
    def errorInAggregation =
    timeFrame == timeFrame.DAY and cap >= AggregationPeriod.WEEK or
    timeFrame == timeFrame.WEEK and cap >= AggregationPeriod.MONTH;
    Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
    def yyyyMmDd = GetYYYYMMDD();
    def periodIndx;
    switch (timeFrame) {
    case DAY:
        periodIndx = yyyyMmDd;
    case WEEK:
        periodIndx = Floor((DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd))) / 7);
    case MONTH:
        periodIndx = RoundDown(yyyyMmDd / 100, 0);
}
    def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);
    def volumeSum;
    def volumeVwapSum;
    if (isPeriodRolled) {
        volumeSum = v;
        volumeVwapSum = v * src;
    } else {
        volumeSum = CompoundValue(1, volumeSum[1] + v, v);
        volumeVwapSum = CompoundValue(1, volumeVwapSum[1] + v * src, v * src);
    }
    def price = volumeVwapSum / volumeSum;
    plot return = price;
}

def FV = Source * v;
def Volvwap = if showVwapCloud then VVWAP(FV, VwapTimeFrame) else 0;

#--- MA Line
def MA = SimpleMovingAvg(FV, MA_Period);
plot maLine = ma;
maLine.SetDefaultColor(Color.BLUE);
maLine.SetHiding(!ShowMA_Line);

#--------------------------------------------
plot FinancialVolume = FV;
FinancialVolume.AssignValueColor(if FV > Volvwap then if c>c[1] then CreateColor(50,201,86) else color.RED else Color.GRAY);
FinancialVolume.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
def VWAP = Volvwap;

#--- Cloud
AddCloud(VWAP, 0, Color.DARK_GRAY);

#--- Bar Color
AssignPriceColor(if !BarColor then Color.CURRENT else
                 if FV > Volvwap then if c>c[1] then Color.CYAN else color.MAGENTA else Color.CURRENT);
#--- END Clode
@samer800 how can i change the timeframe to ATR as opposed to daily, weekly, monthly?
 

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
495 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