Moving Average Volume Breakouts

CashMoney

Member
VIP
Does anyone know how to a create volume zone based on the volume when it breaks out of moving average.
I would like to create this from volume candles that break out of the moving average.
Create a zone once the candle is closed.
@samer800 @BenTen @MerryDay @horserider

*please see attachment *
Can anyone help?

Here in the indicator for volume
https://usethinkscript.com/threads/volume-buy-sell-pressure-with-hot-percent-for-thinkorswim.389/
Ruby:
# HORSERIDER VOLUME V3 - @HODL
# Volume Buy Sell Pressure with Hot Percent for ThinkorSwim
# Show total volume in gray. Buying volume in green. Sell Volume in red.
# Volume average is gray line.
# Specified percent over average volume is cyan triangles.
# Horserider 12/30/2019 derived from some already existing studies.
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © sudoMode
#indicator(title = 'Pressure Gauge', shorttitle = 'Equilibrium', overlay = false)
# Converted and mod by Sam4Cok@Samer800 - 05/2023

declare lower;

#Inputs
input ControlPercent = 20; #hint above or below this value colors label
input ControlAvgPercent = 10;
input lengthVolAvgLabel = 30;
input lengthAvgXBarsControl = 30; #hint shows who is in control over X bars
input HotPct = 150.0; #hint total volume of bar greater than hotpct = cyan triangle
input ShowTodayVolume = yes;
input ShowBarVolume = yes;
input ShowBuySellPercent = yes;
input ShowBuySellPercentAvgXBars = yes;
input ShowCurrentBarControl = yes;
input ShowControlAvgXBars = yes;
input type = { default SMP, EXP } ;
#Definitions
def lengthVolAvgPlot = 21;
def tradeDaytimeOnly = yes; #hint tradeDaytimeOnly: (IntraDay Only) Only perform trades during hours stated
def OpenTime = 0930; #hint OpenTime: Opening time of market
def CloseTime = 1600; #hint CloseTime: Closing time of market
def length_HV = 20 ;
def Begin = SecondsFromTime(OpenTime);
def End = SecondsTillTime(CloseTime);
def isIntraDay = if GetAggregationPeriod() > 14400000 or GetAggregationPeriod() == 0 then 0 else 1;
def MarketOpen = if !tradeDaytimeOnly or !isIntraDay then 1 else if tradeDaytimeOnly and isIntraDay and Begin > 0 and End > 0 then 1 else 0;
def na = Double.NaN;
#Horserider Volume
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V*(C-L)/(H-L);
def selling = V*(H-C)/(H-L);
Plot SellVol = selling;
SellVol.setPaintingStrategy(PaintingStrategy.Histogram);
SellVol.SetDefaultColor(Color.Red);
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(1);
plot TV = volume;
TV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TV.SetDefaultColor(Color.GRAY);
TV.SetLineWeight(1);
Plot BuyVol = buying;
BuyVol.setPaintingStrategy(PaintingStrategy.Histogram);
BuyVol.SetDefaultColor(Color.Green);
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);
Script F {
Input Length = 30;
def data = volume(period = "DAY");
def data1 =
fold a = 1
to Length + 1
with K = 0
do K + data[a];
def Vol30day_Average = data1 / length;
plot Vol = Vol30day_Average;
}
Script G {
Input Length = 30;
def data = volume;
def data1 =
fold a = 1
to Length + 1
with k = 0
do k + data[a];
def Vol30Bars_Average = data1 / length;
plot Vol2 = Vol30Bars_Average;
}
def AvgVolume30_Day = F(lengthVolAvgLabel);
def AvgVolume30_Bars = G(lengthVolAvgLabel);
def today = volume(period = "DAY");
def curVolume = volume;
def diffFromAvg = today - AvgVolume30_Day;
def diffFromAvgBars = curVolume - AvgVolume30_Bars;
def percentDiffdays = Round((diffFromAvg / AvgVolume30_Day) * 100, 0);
def percentOf30Bar = Round((curVolume / AvgVolume30_Bars) * 100, 0);
def SellVolPercent = Round((Selling / Volume) * 100, 0);
def buyVolPercent = Round((Buying / Volume) * 100, 0);
def percentDiffBars = Round((diffFromAvgBars / AvgVolume30_Bars) * 100, 0);
def BarsBias = if (percentDiffBars <> ControlPercent) and (curVolume > AvgVolume30_Bars) then 1 else if (percentDiffBars <> ControlPercent) and (curVolume < AvgVolume30_Bars) then -1 else 0;
def DaysBias = if (percentDiffdays <> ControlPercent) and (today > AvgVolume30_Day) then 1 else if (percentDiffdays <> ControlPercent) and (curVolume < AvgVolume30_Day) then -1 else 0;
def percentdiff = (sellvolpercent - buyvolpercent);
def percentdiffAbs = absvalue(sellvolpercent - buyvolpercent);
def SellingAvgBars = average(selling,lengthAvgXBarsControl);
def BuyingAvgBars = average(buying,lengthAvgXBarsControl);
def sellavgpercent = (round(AvgVolume30_Bars,0) - Round(SellingAvgBars,0))/Round(AvgVolume30_Bars,0)*100;
def buyavgpercent = (round(AvgVolume30_Bars,0) - Round(BuyingAvgBars,0))/Round(AvgVolume30_Bars,0)*100;
def perdiffavg = absvalue(sellavgpercent - buyavgpercent);
plot VolAvg = Average(volume, lengthVolAvgPlot);
VolAvg.Setdefaultcolor(Color.Gray);
def MA = if type == type.SMP then SimpleMovingAvg(volume, length_HV) else MovAvgExponential(volume, length_HV);
plot HV = if (100 * ((volume / ma) - 1) >= hotPct) then ma else Double.NaN;
hv.SetDefaultColor( Color.CYAN);
hv.SetLineWeight(2) ;
hv.SetPaintingStrategy( PaintingStrategy.TRIANGLES);
def bn = barnumber();
def HighV = if (100 * ((volume / ma) - 1) >= hotPct) then 1 else 0;
def HighV_Foldcondition = if MarketOpen and (100 * ((volume / ma) - 1) >= hotPct) and (buyvolPercent > sellvolpercent) then 1
else if MarketOpen and (100 * ((volume / ma) - 1) >= hotPct) and (buyvolPercent < sellvolpercent) then -1 else 0;
input HighVLookback = 100;
def HighV_lookback = fold uu = 1 to HighVLookback with pp do pp + HighV_Foldcondition[uu];
#Labels
AddLabel(ShowBuySellPercent, "Current Bar Buy: " + BuyVolPercent + "%",
(if (BuyVolPercent > Sellvolpercent) and highV then Color.cyan
else if (BuyVolPercent > Sellvolpercent) and (BuyVolPercent >= ControlPercent) then Color.Green
else if (BuyVolPercent < Sellvolpercent) then Color.Gray
else Color.current));
AddLabel(ShowBuySellPercent, "Current Bar Sell: " + SellVolPercent + "%",
(if (BuyVolPercent < Sellvolpercent) and highV then Color.cyan
else if (BuyVolPercent < Sellvolpercent) and (SellVolPercent >= ControlPercent) then Color.red
else if (BuyVolPercent > Sellvolpercent) then Color.Gray
else Color.current));
AddLabel(ShowCurrentBarControl, "Current Bar Control: " + percentdiff + "%",
(if (BuyVolPercent > Sellvolpercent) and highV then Color.cyan
else if (BuyVolPercent > Sellvolpercent) and (percentdiff >= ControlPercent) then Color.green
else if (BuyVolPercent < Sellvolpercent) and (percentdiff >= ControlPercent) then Color.red
else if (percentdiff < ControlPercent) then Color.Gray
else Color.current));

AddLabel(ShowTodayVolume,
if (DaysBias == 1) then "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + "% Above " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == -1) then "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + "% Below " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == 0) and (today > AvgVolume30_Bars) then "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + "% above " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == 0) and (today < AvgVolume30_Bars) then "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + "% below " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_day, 0)+ ")",
(if (DaysBias == 1) then Color.green
else if (DaysBias == -1) then Color.RED
else if (DaysBias == 0) and (curVolume > AvgVolume30_Day) then color.orange
else if (DaysBias == 0) and (curVolume < AvgVolume30_Day) then color.orange
else color.light_gray));
AddLabel(ShowBarVolume,
if (BarsBias == 1) then "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + "% Above " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == -1) then "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + "% Below " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == 0) and (curVolume > AvgVolume30_Bars) then "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + "% above " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == 0) and (curVolume < AvgVolume30_Bars) then "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + "% below " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")",
(if (BarsBias == 1) then Color.green
else if (BarsBias == -1) then Color.RED
else if (BarsBias == 0) and (curVolume > AvgVolume30_Bars) then color.orange
else if (BarsBias == 0) and (curVolume < AvgVolume30_Bars) then color.orange
else Color.light_gray));

addlabel(ShowBuySellPercentAvgXBars,lengthAvgXBarsControl + " Bar Average Buy: " + round(buyavgpercent,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.light_green
else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Gray
else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
else Color.current));
addlabel(ShowBuySellPercentAvgXBars,lengthAvgXBarsControl + " Bar Average Sell: " + round(sellavgpercent,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.gray
else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Light_red
else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
else Color.current));
addlabel(ShowControlAvgXBars,lengthAvgXBarsControl + " Bar Average Control: " + round(perdiffavg,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.light_green
else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Light_red
else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
else Color.current));
#


Thank you.
 

Attachments

  • volume zone.jpg
    volume zone.jpg
    112.5 KB · Views: 261
  • volume zone.jpg
    volume zone.jpg
    138.2 KB · Views: 200
Last edited:
Does anyone know how to a create volume zone based on the volume when it breaks out of moving average.
I would like to create this from volume candles that break out of the moving average.
Create a zone once the candle is closed.
@samer800 @BenTen @MerryDay @horserider

*please see attachment *
Can anyone help?

Here in the indicator for volume
https://usethinkscript.com/threads/volume-buy-sell-pressure-with-hot-percent-for-thinkorswim.389/
Ruby:
# HORSERIDER VOLUME V3 - @HODL
# Volume Buy Sell Pressure with Hot Percent for ThinkorSwim
# Show total volume in gray. Buying volume in green. Sell Volume in red.
# Volume average is gray line.
# Specified percent over average volume is cyan triangles.
# Horserider 12/30/2019 derived from some already existing studies.
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © sudoMode
#indicator(title = 'Pressure Gauge', shorttitle = 'Equilibrium', overlay = false)
# Converted and mod by Sam4Cok@Samer800 - 05/2023

declare lower;

#Inputs
input ControlPercent = 20; #hint above or below this value colors label
input ControlAvgPercent = 10;
input lengthVolAvgLabel = 30;
input lengthAvgXBarsControl = 30; #hint shows who is in control over X bars
input HotPct = 150.0; #hint total volume of bar greater than hotpct = cyan triangle
input ShowTodayVolume = yes;
input ShowBarVolume = yes;
input ShowBuySellPercent = yes;
input ShowBuySellPercentAvgXBars = yes;
input ShowCurrentBarControl = yes;
input ShowControlAvgXBars = yes;
input type = { default SMP, EXP } ;
#Definitions
def lengthVolAvgPlot = 21;
def tradeDaytimeOnly = yes; #hint tradeDaytimeOnly: (IntraDay Only) Only perform trades during hours stated
def OpenTime = 0930; #hint OpenTime: Opening time of market
def CloseTime = 1600; #hint CloseTime: Closing time of market
def length_HV = 20 ;
def Begin = SecondsFromTime(OpenTime);
def End = SecondsTillTime(CloseTime);
def isIntraDay = if GetAggregationPeriod() > 14400000 or GetAggregationPeriod() == 0 then 0 else 1;
def MarketOpen = if !tradeDaytimeOnly or !isIntraDay then 1 else if tradeDaytimeOnly and isIntraDay and Begin > 0 and End > 0 then 1 else 0;
def na = Double.NaN;
#Horserider Volume
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V*(C-L)/(H-L);
def selling = V*(H-C)/(H-L);
Plot SellVol = selling;
SellVol.setPaintingStrategy(PaintingStrategy.Histogram);
SellVol.SetDefaultColor(Color.Red);
SellVol.HideTitle();
SellVol.HideBubble();
SellVol.SetLineWeight(1);
plot TV = volume;
TV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TV.SetDefaultColor(Color.GRAY);
TV.SetLineWeight(1);
Plot BuyVol = buying;
BuyVol.setPaintingStrategy(PaintingStrategy.Histogram);
BuyVol.SetDefaultColor(Color.Green);
BuyVol.HideTitle();
BuyVol.HideBubble();
BuyVol.SetLineWeight(5);
Script F {
Input Length = 30;
def data = volume(period = "DAY");
def data1 =
fold a = 1
to Length + 1
with K = 0
do K + data[a];
def Vol30day_Average = data1 / length;
plot Vol = Vol30day_Average;
}
Script G {
Input Length = 30;
def data = volume;
def data1 =
fold a = 1
to Length + 1
with k = 0
do k + data[a];
def Vol30Bars_Average = data1 / length;
plot Vol2 = Vol30Bars_Average;
}
def AvgVolume30_Day = F(lengthVolAvgLabel);
def AvgVolume30_Bars = G(lengthVolAvgLabel);
def today = volume(period = "DAY");
def curVolume = volume;
def diffFromAvg = today - AvgVolume30_Day;
def diffFromAvgBars = curVolume - AvgVolume30_Bars;
def percentDiffdays = Round((diffFromAvg / AvgVolume30_Day) * 100, 0);
def percentOf30Bar = Round((curVolume / AvgVolume30_Bars) * 100, 0);
def SellVolPercent = Round((Selling / Volume) * 100, 0);
def buyVolPercent = Round((Buying / Volume) * 100, 0);
def percentDiffBars = Round((diffFromAvgBars / AvgVolume30_Bars) * 100, 0);
def BarsBias = if (percentDiffBars <> ControlPercent) and (curVolume > AvgVolume30_Bars) then 1 else if (percentDiffBars <> ControlPercent) and (curVolume < AvgVolume30_Bars) then -1 else 0;
def DaysBias = if (percentDiffdays <> ControlPercent) and (today > AvgVolume30_Day) then 1 else if (percentDiffdays <> ControlPercent) and (curVolume < AvgVolume30_Day) then -1 else 0;
def percentdiff = (sellvolpercent - buyvolpercent);
def percentdiffAbs = absvalue(sellvolpercent - buyvolpercent);
def SellingAvgBars = average(selling,lengthAvgXBarsControl);
def BuyingAvgBars = average(buying,lengthAvgXBarsControl);
def sellavgpercent = (round(AvgVolume30_Bars,0) - Round(SellingAvgBars,0))/Round(AvgVolume30_Bars,0)*100;
def buyavgpercent = (round(AvgVolume30_Bars,0) - Round(BuyingAvgBars,0))/Round(AvgVolume30_Bars,0)*100;
def perdiffavg = absvalue(sellavgpercent - buyavgpercent);
plot VolAvg = Average(volume, lengthVolAvgPlot);
VolAvg.Setdefaultcolor(Color.Gray);
def MA = if type == type.SMP then SimpleMovingAvg(volume, length_HV) else MovAvgExponential(volume, length_HV);
plot HV = if (100 * ((volume / ma) - 1) >= hotPct) then ma else Double.NaN;
hv.SetDefaultColor( Color.CYAN);
hv.SetLineWeight(2) ;
hv.SetPaintingStrategy( PaintingStrategy.TRIANGLES);
def bn = barnumber();
def HighV = if (100 * ((volume / ma) - 1) >= hotPct) then 1 else 0;
def HighV_Foldcondition = if MarketOpen and (100 * ((volume / ma) - 1) >= hotPct) and (buyvolPercent > sellvolpercent) then 1
else if MarketOpen and (100 * ((volume / ma) - 1) >= hotPct) and (buyvolPercent < sellvolpercent) then -1 else 0;
input HighVLookback = 100;
def HighV_lookback = fold uu = 1 to HighVLookback with pp do pp + HighV_Foldcondition[uu];
#Labels
AddLabel(ShowBuySellPercent, "Current Bar Buy: " + BuyVolPercent + "%",
(if (BuyVolPercent > Sellvolpercent) and highV then Color.cyan
else if (BuyVolPercent > Sellvolpercent) and (BuyVolPercent >= ControlPercent) then Color.Green
else if (BuyVolPercent < Sellvolpercent) then Color.Gray
else Color.current));
AddLabel(ShowBuySellPercent, "Current Bar Sell: " + SellVolPercent + "%",
(if (BuyVolPercent < Sellvolpercent) and highV then Color.cyan
else if (BuyVolPercent < Sellvolpercent) and (SellVolPercent >= ControlPercent) then Color.red
else if (BuyVolPercent > Sellvolpercent) then Color.Gray
else Color.current));
AddLabel(ShowCurrentBarControl, "Current Bar Control: " + percentdiff + "%",
(if (BuyVolPercent > Sellvolpercent) and highV then Color.cyan
else if (BuyVolPercent > Sellvolpercent) and (percentdiff >= ControlPercent) then Color.green
else if (BuyVolPercent < Sellvolpercent) and (percentdiff >= ControlPercent) then Color.red
else if (percentdiff < ControlPercent) then Color.Gray
else Color.current));

AddLabel(ShowTodayVolume,
if (DaysBias == 1) then "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + "% Above " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == -1) then "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + "% Below " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == 0) and (today > AvgVolume30_Bars) then "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + "% above " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else if (DaysBias == 0) and (today < AvgVolume30_Bars) then "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + "% below " + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_Day, 0)+ ")"
else "Todays Volume: " + (today) + " | " + absvalue(percentDiffdays) + lengthVolAvgLabel + " Day Average (" + Round(AvgVolume30_day, 0)+ ")",
(if (DaysBias == 1) then Color.green
else if (DaysBias == -1) then Color.RED
else if (DaysBias == 0) and (curVolume > AvgVolume30_Day) then color.orange
else if (DaysBias == 0) and (curVolume < AvgVolume30_Day) then color.orange
else color.light_gray));
AddLabel(ShowBarVolume,
if (BarsBias == 1) then "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + "% Above " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == -1) then "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + "% Below " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == 0) and (curVolume > AvgVolume30_Bars) then "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + "% above " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else if (BarsBias == 0) and (curVolume < AvgVolume30_Bars) then "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + "% below " + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")"
else "Current Bar Volume: " + (curVolume) + " | " + absvalue(percentDiffBars) + lengthVolAvgLabel + " Bar Average (" + Round(AvgVolume30_Bars, 0)+ ")",
(if (BarsBias == 1) then Color.green
else if (BarsBias == -1) then Color.RED
else if (BarsBias == 0) and (curVolume > AvgVolume30_Bars) then color.orange
else if (BarsBias == 0) and (curVolume < AvgVolume30_Bars) then color.orange
else Color.light_gray));

addlabel(ShowBuySellPercentAvgXBars,lengthAvgXBarsControl + " Bar Average Buy: " + round(buyavgpercent,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.light_green
else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Gray
else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
else Color.current));
addlabel(ShowBuySellPercentAvgXBars,lengthAvgXBarsControl + " Bar Average Sell: " + round(sellavgpercent,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.gray
else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Light_red
else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
else Color.current));
addlabel(ShowControlAvgXBars,lengthAvgXBarsControl + " Bar Average Control: " + round(perdiffavg,0) + "%",
(if (buyavgpercent > SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.light_green
else if (buyavgpercent < SellingAvgBars) and (perdiffavg >= ControlAvgPercent) then Color.Light_red
else if (perdiffavg < ControlAvgPercent) then Color.light_Gray
else Color.current));
#


Thank you.

sorry, don't understand. use a lot more words and thoroughly describe the rules.
do you want a cloud on the price chart?
what defines a zone top level? the zone bottom level?
 

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

sorry, don't understand. use a lot more words and thoroughly describe the rules.
do you want a cloud on the price chart?
what defines a zone top level? the zone bottom level?
Hi,
When the volume breaks out from the moving average volume( the volume indicator), I would like a cloud to be created on price chart.
That cloud should go across the chart. The cloud color can be red or green based buy/sell pressure on the volume indicator.

I will post more pictures tomm.


Thank you.
 
Not sure if this is something what you're looking for. But I added the volume accelerating as well for pre-detection purpose and potential early breakout as well.

Code:
# Inputs
input ControlPercent = 20;
input ControlAvgPercent = 10;
input lengthVolAvgLabel = 30;
input lengthAvgXBarsControl = 30;
input HotPct = 150.0;
input ShowTodayVolume = yes;
input ShowBarVolume = yes;
input ShowBuySellPercent = yes;
input ShowBuySellPercentAvgXBars = yes;
input ShowCurrentBarControl = yes;
input ShowControlAvgXBars = yes;
input type = {default SMP, EXP};

# Time Parameters
def OpenTime = 0930;
def CloseTime = 1600;
def Begin = SecondsFromTime(OpenTime);
def End = SecondsTillTime(CloseTime);
def tradeDaytimeOnly = yes;
def isIntraDay = GetAggregationPeriod() <= AggregationPeriod.FOUR_HOURS;
def MarketOpen = if !tradeDaytimeOnly or !isIntraDay then 1 else Begin > 0 and End > 0;

# Price and Volume Definitions
def O = open;
def H = high;
def L = low;
def C = close;
def V = volume;

# Moving Average of Volume (MA)
def MA = if type == type.SMP then SimpleMovingAvg(V, lengthVolAvgLabel) else MovAvgExponential(V, lengthVolAvgLabel);

# Volume Breakout Condition (when current volume exceeds MA)
def isVolumeBreakout = V > MA;

# Buy/Sell Volume Calculations
def buying = V * (C - L) / (H - L);
def selling = V * (H - C) / (H - L);
def buyVolPercent = Round((buying / V) * 100, 0);
def sellVolPercent = Round((selling / V) * 100, 0);

# Buy/Sell Pressure Condition
def isBuyPressure = buyVolPercent > sellVolPercent;

# Price Chart Cloud Boundaries
def upperBound = high;
def lowerBound = low;

# Add Green Cloud for Buy Pressure and Red Cloud for Sell Pressure
AddCloud(if isVolumeBreakout and isBuyPressure then upperBound else Double.NaN,
         if isVolumeBreakout and isBuyPressure then lowerBound else Double.NaN,
         Color.GREEN);

AddCloud(if isVolumeBreakout and !isBuyPressure then upperBound else Double.NaN,
         if isVolumeBreakout and !isBuyPressure then lowerBound else Double.NaN,
         Color.RED);

# Labels for Volume Information
AddLabel(ShowBuySellPercent, "Current Buy: " + buyVolPercent + "% | Sell: " + sellVolPercent + "%",
         if buyVolPercent > sellVolPercent then Color.GREEN else Color.RED);

AddLabel(ShowTodayVolume, "Today's Volume: " + V,
         if V > MA then Color.GREEN else Color.RED);

AddLabel(ShowBarVolume, "Current Volume: " + V,
         if isVolumeBreakout then Color.CYAN else Color.GRAY);

# Average Control Over X Bars for Buy/Sell Pressure
def buyAvg = Average(buying, lengthAvgXBarsControl);
def sellAvg = Average(selling, lengthAvgXBarsControl);
def controlAvgDiff = Round((buyAvg - sellAvg) / buyAvg * 100, 0);

AddLabel(ShowControlAvgXBars, "Avg Control Over " + lengthAvgXBarsControl + " Bars: " + controlAvgDiff + "%",
         if controlAvgDiff > 0 then Color.GREEN else Color.RED);

###########################################
# Early Volume Breakout Detection Section #
###########################################

### 1. Volume Rate of Change (ROC) - Detect Acceleration
def volumeROC = (V - V[1]) / V[1] * 100;
def isVolumeAccelerating = volumeROC > 50;  # Customize the threshold as needed

# Label to show Volume Acceleration
AddLabel(isVolumeAccelerating, "Volume Accelerating", Color.CYAN);

### 2. Intrabar Volume Monitoring (relative to average within the current bar)
def currentBarProgress = (SecondsFromTime(0930) / 23400);  # Intraday progress (for a 6.5 hour session)
def expectedVolume = V[1] * currentBarProgress;

# Detect early breakout if current volume exceeds expected intraday volume
def isEarlyBreakout = V > expectedVolume;
AddLabel(isEarlyBreakout, "Potential Early Breakout", Color.YELLOW);

### 3. Gradual Volume Build-up Detection
def volumeIncrease = V > V[1] and V[1] > V[2] and V[2] > V[3];
AddLabel(volumeIncrease, "Volume Building Up", Color.ORANGE);

### 4. On-Balance Volume (OBV) Divergence for Pre-Breakout Detection
def OBV = CompoundValue(1, if close > close[1] then OBV[1] + V else if close < close[1] then OBV[1] - V else OBV[1], V);
def OBVSlope = OBV - OBV[1];
def OBVIncreasing = OBVSlope > 0;
AddLabel(OBVIncreasing, "OBV Rising", Color.GREEN);

### 5. Pre-Breakout Volume Threshold (detect volume approaching the breakout)
def preBreakoutThreshold = 0.9 * MA;  # 90% of MA as the threshold
def isApproachingBreakout = V > preBreakoutThreshold and V < MA;
AddLabel(isApproachingBreakout, "Approaching Breakout", Color.MAGENTA);

### 6. Combine Volume Acceleration, Pre-Breakout, and Volatility for a Strong Signal
# Volatility calculation using ATR (Average True Range)
def ATRLength = 14;
def ATR = Average(TrueRange(H, C, L), ATRLength);
def increasingVolatility = ATR > ATR[1];

# Combine signals: volume acceleration + approaching breakout + increasing volatility
def combinedSignal = isVolumeAccelerating and isApproachingBreakout and increasingVolatility;
AddLabel(combinedSignal, "Strong Breakout Signal", Color.RED);
 
Not sure if this is something what you're looking for. But I added the volume accelerating as well for pre-detection purpose and potential early breakout as well.

Code:
# Inputs
input ControlPercent = 20;
input ControlAvgPercent = 10;
input lengthVolAvgLabel = 30;
input lengthAvgXBarsControl = 30;
input HotPct = 150.0;
input ShowTodayVolume = yes;
input ShowBarVolume = yes;
input ShowBuySellPercent = yes;
input ShowBuySellPercentAvgXBars = yes;
input ShowCurrentBarControl = yes;
input ShowControlAvgXBars = yes;
input type = {default SMP, EXP};

# Time Parameters
def OpenTime = 0930;
def CloseTime = 1600;
def Begin = SecondsFromTime(OpenTime);
def End = SecondsTillTime(CloseTime);
def tradeDaytimeOnly = yes;
def isIntraDay = GetAggregationPeriod() <= AggregationPeriod.FOUR_HOURS;
def MarketOpen = if !tradeDaytimeOnly or !isIntraDay then 1 else Begin > 0 and End > 0;

# Price and Volume Definitions
def O = open;
def H = high;
def L = low;
def C = close;
def V = volume;

# Moving Average of Volume (MA)
def MA = if type == type.SMP then SimpleMovingAvg(V, lengthVolAvgLabel) else MovAvgExponential(V, lengthVolAvgLabel);

# Volume Breakout Condition (when current volume exceeds MA)
def isVolumeBreakout = V > MA;

# Buy/Sell Volume Calculations
def buying = V * (C - L) / (H - L);
def selling = V * (H - C) / (H - L);
def buyVolPercent = Round((buying / V) * 100, 0);
def sellVolPercent = Round((selling / V) * 100, 0);

# Buy/Sell Pressure Condition
def isBuyPressure = buyVolPercent > sellVolPercent;

# Price Chart Cloud Boundaries
def upperBound = high;
def lowerBound = low;

# Add Green Cloud for Buy Pressure and Red Cloud for Sell Pressure
AddCloud(if isVolumeBreakout and isBuyPressure then upperBound else Double.NaN,
         if isVolumeBreakout and isBuyPressure then lowerBound else Double.NaN,
         Color.GREEN);

AddCloud(if isVolumeBreakout and !isBuyPressure then upperBound else Double.NaN,
         if isVolumeBreakout and !isBuyPressure then lowerBound else Double.NaN,
         Color.RED);

# Labels for Volume Information
AddLabel(ShowBuySellPercent, "Current Buy: " + buyVolPercent + "% | Sell: " + sellVolPercent + "%",
         if buyVolPercent > sellVolPercent then Color.GREEN else Color.RED);

AddLabel(ShowTodayVolume, "Today's Volume: " + V,
         if V > MA then Color.GREEN else Color.RED);

AddLabel(ShowBarVolume, "Current Volume: " + V,
         if isVolumeBreakout then Color.CYAN else Color.GRAY);

# Average Control Over X Bars for Buy/Sell Pressure
def buyAvg = Average(buying, lengthAvgXBarsControl);
def sellAvg = Average(selling, lengthAvgXBarsControl);
def controlAvgDiff = Round((buyAvg - sellAvg) / buyAvg * 100, 0);

AddLabel(ShowControlAvgXBars, "Avg Control Over " + lengthAvgXBarsControl + " Bars: " + controlAvgDiff + "%",
         if controlAvgDiff > 0 then Color.GREEN else Color.RED);

###########################################
# Early Volume Breakout Detection Section #
###########################################

### 1. Volume Rate of Change (ROC) - Detect Acceleration
def volumeROC = (V - V[1]) / V[1] * 100;
def isVolumeAccelerating = volumeROC > 50;  # Customize the threshold as needed

# Label to show Volume Acceleration
AddLabel(isVolumeAccelerating, "Volume Accelerating", Color.CYAN);

### 2. Intrabar Volume Monitoring (relative to average within the current bar)
def currentBarProgress = (SecondsFromTime(0930) / 23400);  # Intraday progress (for a 6.5 hour session)
def expectedVolume = V[1] * currentBarProgress;

# Detect early breakout if current volume exceeds expected intraday volume
def isEarlyBreakout = V > expectedVolume;
AddLabel(isEarlyBreakout, "Potential Early Breakout", Color.YELLOW);

### 3. Gradual Volume Build-up Detection
def volumeIncrease = V > V[1] and V[1] > V[2] and V[2] > V[3];
AddLabel(volumeIncrease, "Volume Building Up", Color.ORANGE);

### 4. On-Balance Volume (OBV) Divergence for Pre-Breakout Detection
def OBV = CompoundValue(1, if close > close[1] then OBV[1] + V else if close < close[1] then OBV[1] - V else OBV[1], V);
def OBVSlope = OBV - OBV[1];
def OBVIncreasing = OBVSlope > 0;
AddLabel(OBVIncreasing, "OBV Rising", Color.GREEN);

### 5. Pre-Breakout Volume Threshold (detect volume approaching the breakout)
def preBreakoutThreshold = 0.9 * MA;  # 90% of MA as the threshold
def isApproachingBreakout = V > preBreakoutThreshold and V < MA;
AddLabel(isApproachingBreakout, "Approaching Breakout", Color.MAGENTA);

### 6. Combine Volume Acceleration, Pre-Breakout, and Volatility for a Strong Signal
# Volatility calculation using ATR (Average True Range)
def ATRLength = 14;
def ATR = Average(TrueRange(H, C, L), ATRLength);
def increasingVolatility = ATR > ATR[1];

# Combine signals: volume acceleration + approaching breakout + increasing volatility
def combinedSignal = isVolumeAccelerating and isApproachingBreakout and increasingVolatility;
AddLabel(combinedSignal, "Strong Breakout Signal", Color.RED);
Would you able to do for the all the candles that break out of moving average volume line as well as have the cloud go across the chart until the next volume break out occurs?
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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