How to create HOD BAR volume bubble that displays HOD volume


0
0

Hello Pete ,  I need help creating a bubble that only shows at the HOD Price after 9:30am (not factoring in Premarket )

 

this bubble will only display the intraday HOD bars volume .

if that current HOD candle volume is over 300k, the bubble will be red, of under 300k. The bubble will be white .

if the stock has traded under 4 million volume on the day , the bubble will display ( ill liquid )

 

 

a walk through on this would be nice .

thank you

Marked as spam
Posted by (Questions: 6, Answers: 3)
Asked on February 21, 2020 11:10 am
39 views
0
Private answer

The only way to do this is to use a function named HighestAll(). This function does not let us exclude any particular part of the trading day or a given trading session. So the chart would need to be set NOT to show extended session trade data. During the market hours as new bars are added to the chart the bubble will be changing locations as new highs are made.

Here is the code:

def today = GetDay() == GetLastDay();
def highOfDay = HighestAll(if GetDay() == GetLastDay() then high else Double.NaN);
def matchVolume = if today and high == highOfDay then volume else Double.NaN;
def dailyVolume = volume(period = AggregationPeriod.DAY);
AddChartBubble(today and high == highOfDay, high, if dailyVolume < 4000000 then "ill liquid" else Concat(matchVolume, ""), if matchVolume > 300000 then Color.RED else Color.WHITE);

Stepping through the code:

  1. Determine which section of the chart contains today's market data
  2. For only the current day, check every candle on the chart to get the highest high
  3. For the candle of the current day which has a high matching that high, get the volume
  4. Grab the current daily volume from the daily time frame (this will never match intraday time and this has already been explained here: https://www.hahn-tech.com/ans/how-to-calculate-volume-from-the-open/)
  5. Add chart bubble only if the bar matches the highest high for the current day. Check the daily volume and high of day volume to dynamically set the text and color of the chart bubble.

If there happen to be two or more bars in the current day's trade that match the highest high, the chart bubble will appear on each and the volume data may grab the first or another bar's volume and therefore it's broken.

Marked as spam
Posted by (Questions: 37, Answers: 2830)
Answered on February 21, 2020 7:37 pm
this code is beautiful, I will use it also, I just have one question to Pete or the OP. Is there a way to hide the bubble if it triggers premarket so it only shows intraday
( at February 24, 2020 7:58 pm)
I'm pretty sure I already answered that in the my opening statements. The function named HIghestAll() is the key to making this work. Which requires that you apply this only to a chart that does NOT display extended trade data. Any attempts to prevent the chart bubble from plotting during extended hours sessions will break it entirely. Meaning the bubble will completely fail to plot if the high of day occurs during the extended hours session.
( at February 25, 2020 7:55 am)