this is an upper chart study. i'm not sure if it can be used in a scan, i didn't test it.
it works on after hours, but because of inconsistant quantity of bars in after hours, i recommend using it on normal trading hours.
in the middle of the code , are the 4 main variables for high, low, open, close.
notice the sides of the shading are vertical. it alternates between 2 clouds, so they are separate. if just 1 cloud was used, they would be joined.
good
it finds open, high, low, close levels, in custom time frames / periods.
any number of minutes can be used for the time period, from 2 to ...500, 1000,...
ex. 15/1, 15/3, 30/5, 25/5, 60/5 (user min / chart min)
if you use 195 minutes on a 1min chart, you will have 2 periods for the day. or try 195/5 , or 195/15,...
it tests if the user time is a multiple of the chart time and calculates how many bars are in a period.
it will show a warning label if invalid numbers are used.
if invalid numbers are used, it defaults to a period of 1 bar and doesn't draw anything.
bad
it doesn't find OHLC values during the last/active time period. because of this if used in a scan, would have to look back x bars, to read valid OHLC data.
i tried a couple things, but didn't get it working. i thought i would share what i have so far and maybe i or someone can update it.
Code:
# bigagg_01
# ---------------------------------
# halcyonguy
# 21-08-03
# find OHLC levels, in user defined time periods
# period minutes, (any number > 1)
# (if user time is a multiple of chart time, ex. 15/1, 15/3, 30/5, 25/5,...)
# draw high/low lines and shading
# labels to display,
# quantity of bars per time period
# open,high,low,close values (currently shows n/a during day)
# options,
# bubbles to show OHLC levels, on 1st bar or all bars
# bubbles to show just high and low
# ---------------------------------
def bn = BarNumber();
def na = Double.NaN;
def barCount = HighestAll(If(IsNaN(close), 0, bn));
def chartagg = GetAggregationPeriod();
def chartmin = (chartagg / 1000) / 60;
input bigcandlemin = 30;
# is chartmin a multiple of bigcandlemin?
def bigmulti = (bigcandlemin / chartmin) == floor(bigcandlemin / chartmin);
def bigbar2 = if (!bigmulti or bigcandlemin <= chartmin) then 1 else (bigcandlemin / chartmin);
# add offset -1 to bar#. want 2nd 30min start to be on bar31, not 30
def bnoff = -1;
# find first bar in a group of bigbar bars
def bigbarfirst = ((bn + bnoff) / bigbar2) == Floor((bn + bnoff) / bigbar2);
def bigbar = bigbar2;
addlabel(bigmulti, "group bars " + bigbar + " / " + bigcandlemin + "min", color.yellow);
addlabel(!bigmulti, "group minutes " + bigcandlemin + " is not a multiple of cchart time " + chartmin, color.yellow);
# count bar groups
def bigbarcnt = if bigbarfirst then bigbarcnt[1] + 1 else bigbarcnt[1];
def bigbareven = (bigbarcnt/2) == Floor(bigbarcnt/2);
# highest in bigbar period
def hi2 = if bigbarfirst then Highest(high[-(bigbar-1)], bigbar) else hi2[1];
# lowest in bigbar period
def lo2 = if bigbarfirst then lowest(low[-(bigbar-1)], bigbar) else lo2[1];
# ===============================
def bighi = round(hi2,3);
def biglo = round(lo2,3);
def bigopen = if bigbarfirst then open else bigopen[1];
def bigclose = if bigbarfirst then close[-(bigbar-1)] else bigclose[1];
# ===============================
plot hilvla = if bigbareven then bighi else na;
plot hilvlb = if !bigbareven then bighi else na;
hilvla.setdefaultcolor(color.green);
hilvlb.setdefaultcolor(color.green);
plot lolvla = if bigbareven then biglo else na;
plot lolvlb = if !bigbareven then biglo else na;
lolvla.setdefaultcolor(color.red);
lolvlb.setdefaultcolor(color.red);
input show_label_stats = yes;
Addlabel(show_label_stats and bigmulti, "O " + bigopen + " H " + bighi + " L " + biglo + " C" + bigclose , Color.yellow);
input show_shading = yes;
def bighieven = if show_shading and bigbareven then bighi else na;
def bighiodd = if show_shading and !bigbareven then bighi else na;
addcloud(bighieven, biglo, color.gray, color.gray);
addcloud(bighiodd, biglo, color.gray, color.gray);
# test data ------------------------
#AddChartBubble(1, hi2, bn , Color.MAGENTA, yes);
input show_one_test_bubbles_OHLC = yes;
AddChartBubble(show_one_test_bubbles_OHLC and bigbarfirst and bigmulti, lo2, "O " + bigopen + "\nH " + bighi + "\nL " + biglo + "\nC " + bigclose , Color.MAGENTA, no);
input show_all_test_bubbles_OHLC = no;
AddChartBubble(show_all_test_bubbles_OHLC and bigmulti, lo2, bigopen + "\n" + bighi + "\n" + biglo + "\n" + bigclose , Color.MAGENTA, no);
input show_hilo_price_bubbles = no;
AddChartBubble(show_hilo_price_bubbles and bigbarfirst and bigmulti, bighi, bighi, Color.dark_gray, yes);
AddChartBubble(show_hilo_price_bubbles and bigbarfirst and bigmulti, biglo, biglo, Color.dark_gray, no);
#