Volume Pressure Demarcations

npthr33

New member
im looking to create a script that will allow me to plot a green or red icon of some sort (ideally just a small circle) above or below respectively if specific criteria are met. i dont think im explaining it well enough to chatgpt, or what im looking for just doesnt exist. i am looking to have a green dot plotted above each candle if that candle or the last dominance candle was bullish. if the last dominant candle was bearish i would like for a red dot to be plotted below that candle.

i have added below what ive completed (possibly incorrect) thus far:

Code:
# 5 period average volume
Def 5avgvol = average(volume,5);
Def domcan = volume >= 5avgvol;

# Each candle has a certain amount of buying volume and selling volume
Def Buyingvolume = ((close – low) / (high – low)) * volume;
Def Sellingvolume = ((high – close) / (high – low)) * volume;

# Each individual candle is defined as “Bullish” or “Bearish”
Def Bullish = Buyingvolume > Sellingvolume;
Def Bearish = Sellingvolume > Buyingvolume;
Def Neutral = Buyingvolume = Sellingvolume;

# is the prior dominant candle bullish or bearish
Def BullDom = domcan and bullish;
Def BearDom = domcan and bearish;
Def NeutDom = domcan and Neutral;
 
Last edited by a moderator:
Solution
Ruby:
# 5 period average volume
Def Fiveavgvol = average(volume,5);
Def domcan = volume >= Fiveavgvol;

# Each candle has a certain amount of buying volume and selling volume
Def Buyingvolume = ((close – low) / (high – low)) * volume;
Def Sellingvolume = ((high – close) / (high – low)) * volume;

# Each individual candle is defined as “Bullish” or “Bearish”
Def Bullish = Buyingvolume > Sellingvolume;
Def Bearish = Sellingvolume > Buyingvolume;
Def Neutral = Buyingvolume == Sellingvolume;

# is the prior dominant candle bullish or bearish
Def BullDom = domcan and bullish;
Def BearDom = domcan and bearish;
Def NeutDom = domcan and Neutral;

Def DotDom = If BullDom then 1 else if BearDom then 0 else DotDom[1];

Plot DotDomPlot = If DotDom...
Ruby:
# 5 period average volume
Def Fiveavgvol = average(volume,5);
Def domcan = volume >= Fiveavgvol;

# Each candle has a certain amount of buying volume and selling volume
Def Buyingvolume = ((close – low) / (high – low)) * volume;
Def Sellingvolume = ((high – close) / (high – low)) * volume;

# Each individual candle is defined as “Bullish” or “Bearish”
Def Bullish = Buyingvolume > Sellingvolume;
Def Bearish = Sellingvolume > Buyingvolume;
Def Neutral = Buyingvolume == Sellingvolume;

# is the prior dominant candle bullish or bearish
Def BullDom = domcan and bullish;
Def BearDom = domcan and bearish;
Def NeutDom = domcan and Neutral;

Def DotDom = If BullDom then 1 else if BearDom then 0 else DotDom[1];

Plot DotDomPlot = If DotDom then high+ticksize() else low-ticksize();
DotDomPlot.SetPaintingStrategy(PaintingStrategy.POINTS);
DotDomPlot.AssignValueColor(if DotDom then Color.GREEN else Color.RED)
 
Solution
Updated the script to account for unfilled gaps...

Code:
# Specify volume period to generate average volume
Input volume_period = 5;
Def Fiveavgvol = average(volume, volume_period);
Def domcan = volume >= Fiveavgvol;

# Calculate buying/selling volume accounting for unfilled gaps
def H = high;
def C = close;
def L = low;
def V = volume;

# Unfilled Gap down: Use prior close as high
def equivHi = if H < C[1] then C[1] else H;
# Unfilled Gap up: Use prior close as low
def equivLo = if L > C[1] then C[1] else L;

def Buyingvolume = Round(V * (C - equivLo) / (equivHi - equivLo), 0);
def Sellingvolume = Round(V * (equivHi - C) / (equivHi - equivLo), 0);

# Each individual candle is defined as “Bullish” or “Bearish”
Def Bullish = Buyingvolume > Sellingvolume;
Def Bearish = Sellingvolume > Buyingvolume;
Def Neutral = Buyingvolume == Sellingvolume;

# is the prior dominant candle bullish or bearish
Def BullDom = domcan and bullish;
Def BearDom = domcan and bearish;
Def NeutDom = domcan and Neutral;

Def DotDom = If BullDom then 1 else if BearDom then 0 else DotDom[1];

Plot DotDomPlot = If DotDom then high+ticksize() else low-ticksize();
DotDomPlot.SetPaintingStrategy(PaintingStrategy.POINTS);
DotDomPlot.AssignValueColor(if DotDom then Color.GREEN else Color.RED);

Hope this helps...

Good Luck and Good Trading :cool:
 

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