The middle and high of the first volume bar at open

ahramper1

Member
VIP
Good afternoon
I was wondering if it was possible to make an indicator that would take into consideration the size of the first volume candle of the NY session (5, 10, or 15-minute time frame) and would plot the middle (50%) and high (100%) of that first candle, and have those lines drawn until the end of the session.

I do this manually every day as can be seen in screenshot
I'm also including a share link to my chart https://tos.mx/!tYkdn4fz
Screenshot 2024-09-20 Volume_Bars_50%_and_100%_Examples.png


  • The indicator would also need to place a Wedge or Dot above each volume candle that closed at or above the middle line (50%),
    • for each green volume candle that met that condition a cyan wedge (dot) would appear,
    • and for each red volume candle a magenta wedge (dot).
  • In the case that a volume candle closed at the high line (100%) or above that line, a wedge (dot) would appear on that candle,
    • in this case, if the candle was green a green wedge (dot),
    • and if the candle was red a red wedge (dot).

This is something that I draw and mark on my charts as a visual aid to highlight the size of the bars that reach or cross those two levels drawn from the first bar of the session. I'm using the Volume or Volumeavg from TOS to draw those lines, arrows, wedges, or dots.

And you could be able to select the opening (9:30 am) until, say, 3:50 pm, because the bars after that time are mostly for the MOC (Market on Close). Thank you very much in advance for your help.

green volume bars = close greater than close from 1 bars ago;
red volume bars = close less than close from 1 bars ago ;
Ruby:
#
# Charles Schwab & Co. (c) 2007-2024
#

declare lower;
declare zerobase;

input length = 50;

plot Vol = volume;
plot VolAvg = Average(volume, length);

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.UPTICK);
Vol.DefineColor("Down", Color.DOWNTICK);
Vol.AssignValueColor(if close > close[1] then Vol.color("Up") else if close < close[1] then Vol.color("Down") else GetColor(1));
VolAvg.SetDefaultColor(GetColor(8));
 
Last edited by a moderator:
Solution
This should get you close but I didn't do anything with the end of day ideas.

Code:
declare lower;

plot v = VOLUME;

v.setPaintingStrategy(paintingStrategy.HISTOGRAM);
v.AssignValueColor(if close > open then color.dark_green else color.dark_red);

def t = SecondsFromTime(0930);

addVerticalLine(t[1] < 0 AND t >= 0, "open",color.black);

def threshold = if t[1] < 0 and t >= 0 then v/2 else threshold[1];
def openingVolume = if t[1] < 0 and t >= 0 then v else openingVolume[1];

plot openVol = openingVolume;
openVol.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
openVol.SetDefaultColor(color.gray);

plot halfOpenVol = threshold;
halfOpenVol.SetPaintingStrategy(PaintingStrategy.DASHES);
halfOpenVol.SetDefaultColor(color.gray);

plot...
This should get you close but I didn't do anything with the end of day ideas.

Code:
declare lower;

plot v = VOLUME;

v.setPaintingStrategy(paintingStrategy.HISTOGRAM);
v.AssignValueColor(if close > open then color.dark_green else color.dark_red);

def t = SecondsFromTime(0930);

addVerticalLine(t[1] < 0 AND t >= 0, "open",color.black);

def threshold = if t[1] < 0 and t >= 0 then v/2 else threshold[1];
def openingVolume = if t[1] < 0 and t >= 0 then v else openingVolume[1];

plot openVol = openingVolume;
openVol.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
openVol.SetDefaultColor(color.gray);

plot halfOpenVol = threshold;
halfOpenVol.SetPaintingStrategy(PaintingStrategy.DASHES);
halfOpenVol.SetDefaultColor(color.gray);

plot UpCandleVolumeAlert = if close > open and v > threshold then v * 1.1 else double.nan;
upCandleVolumeAlert.SetPaintingStrategy(paintingStrategy.Points);
upCandleVolumeAlert.SetDefaultColor(color.Cyan);

plot DnCandleVolumeAlert = if close < open and v > threshold then v * 1.1 else double.nan;
DnCandleVolumeAlert.SetPaintingStrategy(paintingStrategy.Points);
DnCandleVolumeAlert.SetDefaultColor(color.magENTA);

plot UpCandleHighVolumeAlert = if close > open and v > openingVolume then v * 1.1 else double.nan;
upCandleHighVolumeAlert.SetPaintingStrategy(paintingStrategy.Triangles);
upCandleHighVolumeAlert.SetLineWeight(3);
upCandleHighVolumeAlert.SetDefaultColor(color.green);

plot DnCandleHighVolumeAlert = if close < open and v > openingVolume then v * 1.1 else double.nan;
DnCandleHighVolumeAlert.SetPaintingStrategy(paintingStrategy.TRIANGLES);
DnCandleHighVolumeAlert.SetLineWeight(3);
DnCandleHighVolumeAlert.SetDefaultColor(color.red);

-mashume
 
Solution

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

This should get you close but I didn't do anything with the end of day ideas.

Code:
declare lower;

plot v = VOLUME;

v.setPaintingStrategy(paintingStrategy.HISTOGRAM);
v.AssignValueColor(if close > open then color.dark_green else color.dark_red);

def t = SecondsFromTime(0930);

addVerticalLine(t[1] < 0 AND t >= 0, "open",color.black);

def threshold = if t[1] < 0 and t >= 0 then v/2 else threshold[1];
def openingVolume = if t[1] < 0 and t >= 0 then v else openingVolume[1];

plot openVol = openingVolume;
openVol.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
openVol.SetDefaultColor(color.gray);

plot halfOpenVol = threshold;
halfOpenVol.SetPaintingStrategy(PaintingStrategy.DASHES);
halfOpenVol.SetDefaultColor(color.gray);

plot UpCandleVolumeAlert = if close > open and v > threshold then v * 1.1 else double.nan;
upCandleVolumeAlert.SetPaintingStrategy(paintingStrategy.Points);
upCandleVolumeAlert.SetDefaultColor(color.Cyan);

plot DnCandleVolumeAlert = if close < open and v > threshold then v * 1.1 else double.nan;
DnCandleVolumeAlert.SetPaintingStrategy(paintingStrategy.Points);
DnCandleVolumeAlert.SetDefaultColor(color.magENTA);

plot UpCandleHighVolumeAlert = if close > open and v > openingVolume then v * 1.1 else double.nan;
upCandleHighVolumeAlert.SetPaintingStrategy(paintingStrategy.Triangles);
upCandleHighVolumeAlert.SetLineWeight(3);
upCandleHighVolumeAlert.SetDefaultColor(color.green);

plot DnCandleHighVolumeAlert = if close < open and v > openingVolume then v * 1.1 else double.nan;
DnCandleHighVolumeAlert.SetPaintingStrategy(paintingStrategy.TRIANGLES);
DnCandleHighVolumeAlert.SetLineWeight(3);
DnCandleHighVolumeAlert.SetDefaultColor(color.red);

-mashume
Good evening @mashume, I am very grateful for the indicator, I have been checking different assets and time frames, and the indicator plots very well the dots and triangles of the volume bars that meet the established/required conditions. I could observe in my tests of the indicator that when a price bar is a Doji (I am attaching screenshot 1 with some notes), the indicator does not plot a dot or triangle. The truth is that I had not thought about Doji bars before. Still, after observing the size of the volume bar of the Doji, I am thinking that two conditions could be added for the Doji bars: if the size of the volume bar is equal to or greater than the middle line (50%) a Yellow Dot would appear, and if the volume bar is greater than or equal to the high line (100%) an orange triangle would appear. Thank you very much in advance for your help, and thanks to all the programmers in this awesome community.
 

Attachments

  • Screenshot 2024-09-21 DOJI_BAR.png
    Screenshot 2024-09-21 DOJI_BAR.png
    127 KB · Views: 58
Good evening @mashume, I am very grateful for the indicator, I have been checking different assets and time frames, and the indicator plots very well the dots and triangles of the volume bars that meet the established/required conditions. I could observe in my tests of the indicator that when a price bar is a Doji (I am attaching screenshot 1 with some notes), the indicator does not plot a dot or triangle. The truth is that I had not thought about Doji bars before. Still, after observing the size of the volume bar of the Doji, I am thinking that two conditions could be added for the Doji bars: if the size of the volume bar is equal to or greater than the middle line (50%) a Yellow Dot would appear, and if the volume bar is greater than or equal to the high line (100%) an orange triangle would appear. Thank you very much in advance for your help, and thanks to all the programmers in this awesome community.
I'll just type these here in the UTS forum... that is, they aren't tested in ToS, but they should work. I think.

add these lines to the end of the script:
Code:
plot DojiVolumeAlert = if close == open and v > threshold then v * 1.1 else double.nan;
DojiVolumeAlert.SetPaintingStrategy(paintingStrategy.Points);
DojiVolumeAlert.SetDefaultColor(color.Yellow);

plot DojiHighVolumeAlert = if close == open and v > openingVolume then v * 1.1 else double.nan;
DojiHighVolumeAlert.SetPaintingStrategy(paintingStrategy.Points);
DojiHighVolumeAlert.SetDefaultColor(color.orange);

-mashume
 
I'll just type these here in the UTS forum... that is, they aren't tested in ToS, but they should work. I think.

add these lines to the end of the script:
Code:
plot DojiVolumeAlert = if close == open and v > threshold then v * 1.1 else double.nan;
DojiVolumeAlert.SetPaintingStrategy(paintingStrategy.Points);
DojiVolumeAlert.SetDefaultColor(color.Yellow);

plot DojiHighVolumeAlert = if close == open and v > openingVolume then v * 1.1 else double.nan;
DojiHighVolumeAlert.SetPaintingStrategy(paintingStrategy.Points);
DojiHighVolumeAlert.SetDefaultColor(color.orange);

-mashume
Thanks @mashume, I will keep testing the indicator with new modifications.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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