Zanger Volume Ratio Indicator for ThinkorSwim

I am trying to make Zanger Volume Ratio work in TOS. This script was made by @horserider. I am modifying it to match Dan Zanger's settings.
One thing I noticed is that I get different values if I use RTH data. When I include pre and post-market data, it works. I would like to change the settings so that it works for RTH data only.

Grid with pre and post-market data: https://tos.mx/49nT0sO
Grid with RTH data: https://tos.mx/QZQ6UkL

Code:
#fl_zanger_volume_ratio_accumSTUDY.ts
#
#Fil
#Creation date: 10/17/2015
#Edit Log (Date/Editor):
#
#
#
#hint: Conversion of eSignal ZVR; see http://www.esignal.com/partners/add-on-formula-studies/chartpattern.aspx
#hint i_print_label_accumulation: Toggles the <b>ACCUMULATION</b> label
#hint i_print_label_pct: Toggles the <b>PERCENT</b> label
#hint i_days_length: Specifies the number of days over which to compute the average <b>DAILY</b> volume

#INPUTS

input i_print_label_accumulation = YES;
input i_print_label_pct = YES;
input i_days_length = 20;

#ESTABLISH RTH
def v_days_from_epoch = DaysFromDate(19700101);
def v_rth_start = (RegularTradingStart(GetYYYYMMDD())) / (1000 * 60 * 60 * 24);
def v_rth_start_in_minutes = Round((24 * (v_rth_start - v_days_from_epoch) - 5) * 60, 0);

def v_rth_end = (RegularTradingEnd(GetYYYYMMDD())) / (1000 * 60 * 60 * 24);
def v_rth_end_in_minutes = Round((24 * (v_rth_end - v_days_from_epoch) - 5) * 60, 0);

def v_eth_pre = if SecondsFromTime(0) / 60 < v_rth_start_in_minutes then 1 else 0;
def v_eth_post = if SecondsFromTime(0) / 60 >= v_rth_end_in_minutes then 1 else 0;
def v_rth = if (SecondsFromTime(0) / 60) >= v_rth_start_in_minutes and (SecondsFromTime(0) / 60) < v_rth_end_in_minutes then 1 else 0;

#COUNTERS AND STATES
def v_agg_period = GetAggregationPeriod() / 1000;
def v_rth_barnum = if v_rth then RoundDown((SecondsFromTime(0) - v_rth_start_in_minutes * 60) / v_agg_period, 0) + 1 else 0;
def v_max_bars_in_rth = (v_rth_end_in_minutes - v_rth_start_in_minutes) * 60 / v_agg_period;

def v_days = CompoundValue(1, if GetYYYYMMDD() <> GetYYYYMMDD()[1] then v_days[1] + 1 else v_days[1], 1);
def v_days_divisor = if v_days > 1 then (if v_eth_pre then v_days - 1 else v_days) else 1;

#RELATIVE INDIVIDUAL BAR VOLUME
def v_aggregated_volume_001 = if v_rth_barnum == 1 then v_aggregated_volume_001[1] + volume else if 1 <= v_max_bars_in_rth then v_aggregated_volume_001[1] else Double.NaN;
def v_aggregated_volume_002 = if v_rth_barnum == 2 then v_aggregated_volume_002[1] + volume else if 2 <= v_max_bars_in_rth then v_aggregated_volume_002[1] else Double.NaN;
def v_aggregated_volume_003 = if v_rth_barnum == 3 then v_aggregated_volume_003[1] + volume else if 3 <= v_max_bars_in_rth then v_aggregated_volume_003[1] else Double.NaN;
def v_aggregated_volume_004 = if v_rth_barnum == 4 then v_aggregated_volume_004[1] + volume else if 4 <= v_max_bars_in_rth then v_aggregated_volume_004[1] else Double.NaN;
def v_aggregated_volume_005 = if v_rth_barnum == 5 then v_aggregated_volume_005[1] + volume else if 5 <= v_max_bars_in_rth then v_aggregated_volume_005[1] else Double.NaN;
def v_aggregated_volume_006 = if v_rth_barnum == 6 then v_aggregated_volume_006[1] + volume else if 6 <= v_max_bars_in_rth then v_aggregated_volume_006[1] else Double.NaN;
def v_aggregated_volume_007 = if v_rth_barnum == 7 then v_aggregated_volume_007[1] + volume else if 7 <= v_max_bars_in_rth then v_aggregated_volume_007[1] else Double.NaN;
def v_aggregated_volume_008 = if v_rth_barnum == 8 then v_aggregated_volume_008[1] + volume else if 8 <= v_max_bars_in_rth then v_aggregated_volume_008[1] else Double.NaN;
def v_aggregated_volume_009 = if v_rth_barnum == 9 then v_aggregated_volume_009[1] + volume else if 9 <= v_max_bars_in_rth then v_aggregated_volume_009[1] else Double.NaN;
def v_aggregated_volume_010 = if v_rth_barnum == 10 then v_aggregated_volume_010[1] + volume else if 10 <= v_max_bars_in_rth then v_aggregated_volume_010[1] else Double.NaN;
def v_aggregated_volume_011 = if v_rth_barnum == 11 then v_aggregated_volume_011[1] + volume else if 11 <= v_max_bars_in_rth then v_aggregated_volume_011[1] else Double.NaN;
def v_aggregated_volume_012 = if v_rth_barnum == 12 then v_aggregated_volume_012[1] + volume else if 12 <= v_max_bars_in_rth then v_aggregated_volume_012[1] else Double.NaN;
def v_aggregated_volume_013 = if v_rth_barnum == 13 then v_aggregated_volume_013[1] + volume else if 13 <= v_max_bars_in_rth then v_aggregated_volume_013[1] else Double.NaN;
def v_aggregated_volume_014 = if v_rth_barnum == 14 then v_aggregated_volume_014[1] + volume else if 14 <= v_max_bars_in_rth then v_aggregated_volume_014[1] else Double.NaN;
def v_aggregated_volume_015 = if v_rth_barnum == 15 then v_aggregated_volume_015[1] + volume else if 15 <= v_max_bars_in_rth then v_aggregated_volume_015[1] else Double.NaN;
def v_aggregated_volume_016 = if v_rth_barnum == 16 then v_aggregated_volume_016[1] + volume else if 16 <= v_max_bars_in_rth then v_aggregated_volume_016[1] else Double.NaN;
def v_aggregated_volume_017 = if v_rth_barnum == 17 then v_aggregated_volume_017[1] + volume else if 17 <= v_max_bars_in_rth then v_aggregated_volume_017[1] else Double.NaN;
def v_aggregated_volume_018 = if v_rth_barnum == 18 then v_aggregated_volume_018[1] + volume else if 18 <= v_max_bars_in_rth then v_aggregated_volume_018[1] else Double.NaN;
def v_aggregated_volume_019 = if v_rth_barnum == 19 then v_aggregated_volume_019[1] + volume else if 19 <= v_max_bars_in_rth then v_aggregated_volume_019[1] else Double.NaN;
def v_aggregated_volume_020 = if v_rth_barnum == 20 then v_aggregated_volume_020[1] + volume else if 20 <= v_max_bars_in_rth then v_aggregated_volume_020[1] else Double.NaN;
def v_aggregated_volume_021 = if v_rth_barnum == 21 then v_aggregated_volume_021[1] + volume else if 21 <= v_max_bars_in_rth then v_aggregated_volume_021[1] else Double.NaN;
def v_aggregated_volume_022 = if v_rth_barnum == 22 then v_aggregated_volume_022[1] + volume else if 22 <= v_max_bars_in_rth then v_aggregated_volume_022[1] else Double.NaN;
def v_aggregated_volume_023 = if v_rth_barnum == 23 then v_aggregated_volume_023[1] + volume else if 23 <= v_max_bars_in_rth then v_aggregated_volume_023[1] else Double.NaN;
def v_aggregated_volume_024 = if v_rth_barnum == 24 then v_aggregated_volume_024[1] + volume else if 24 <= v_max_bars_in_rth then v_aggregated_volume_024[1] else Double.NaN;
def v_aggregated_volume_025 = if v_rth_barnum == 25 then v_aggregated_volume_025[1] + volume else if 25 <= v_max_bars_in_rth then v_aggregated_volume_025[1] else Double.NaN;
def v_aggregated_volume_026 = if v_rth_barnum == 26 then v_aggregated_volume_026[1] + volume else if 26 <= v_max_bars_in_rth then v_aggregated_volume_026[1] else Double.NaN;
def v_aggregated_volume_027 = if v_rth_barnum == 27 then v_aggregated_volume_027[1] + volume else if 27 <= v_max_bars_in_rth then v_aggregated_volume_027[1] else Double.NaN;
def v_aggregated_volume_028 = if v_rth_barnum == 28 then v_aggregated_volume_028[1] + volume else if 28 <= v_max_bars_in_rth then v_aggregated_volume_028[1] else Double.NaN;
def v_aggregated_volume_029 = if v_rth_barnum == 29 then v_aggregated_volume_029[1] + volume else if 29 <= v_max_bars_in_rth then v_aggregated_volume_029[1] else Double.NaN;
def v_aggregated_volume_030 = if v_rth_barnum == 30 then v_aggregated_volume_030[1] + volume else if 30 <= v_max_bars_in_rth then v_aggregated_volume_030[1] else Double.NaN;
def v_aggregated_volume_031 = if v_rth_barnum == 31 then v_aggregated_volume_031[1] + volume else if 31 <= v_max_bars_in_rth then v_aggregated_volume_031[1] else Double.NaN;
def v_aggregated_volume_032 = if v_rth_barnum == 32 then v_aggregated_volume_032[1] + volume else if 32 <= v_max_bars_in_rth then v_aggregated_volume_032[1] else Double.NaN;
def v_aggregated_volume_033 = if v_rth_barnum == 33 then v_aggregated_volume_033[1] + volume else if 33 <= v_max_bars_in_rth then v_aggregated_volume_033[1] else Double.NaN;
def v_aggregated_volume_034 = if v_rth_barnum == 34 then v_aggregated_volume_034[1] + volume else if 34 <= v_max_bars_in_rth then v_aggregated_volume_034[1] else Double.NaN;
def v_aggregated_volume_035 = if v_rth_barnum == 35 then v_aggregated_volume_035[1] + volume else if 35 <= v_max_bars_in_rth then v_aggregated_volume_035[1] else Double.NaN;
def v_aggregated_volume_036 = if v_rth_barnum == 36 then v_aggregated_volume_036[1] + volume else if 36 <= v_max_bars_in_rth then v_aggregated_volume_036[1] else Double.NaN;
def v_aggregated_volume_037 = if v_rth_barnum == 37 then v_aggregated_volume_037[1] + volume else if 37 <= v_max_bars_in_rth then v_aggregated_volume_037[1] else Double.NaN;
def v_aggregated_volume_038 = if v_rth_barnum == 38 then v_aggregated_volume_038[1] + volume else if 38 <= v_max_bars_in_rth then v_aggregated_volume_038[1] else Double.NaN;
def v_aggregated_volume_039 = if v_rth_barnum == 39 then v_aggregated_volume_039[1] + volume else if 39 <= v_max_bars_in_rth then v_aggregated_volume_039[1] else Double.NaN;
def v_aggregated_volume_040 = if v_rth_barnum == 40 then v_aggregated_volume_040[1] + volume else if 40 <= v_max_bars_in_rth then v_aggregated_volume_040[1] else Double.NaN;
def v_aggregated_volume_041 = if v_rth_barnum == 41 then v_aggregated_volume_041[1] + volume else if 41 <= v_max_bars_in_rth then v_aggregated_volume_041[1] else Double.NaN;
def v_aggregated_volume_042 = if v_rth_barnum == 42 then v_aggregated_volume_042[1] + volume else if 42 <= v_max_bars_in_rth then v_aggregated_volume_042[1] else Double.NaN;
def v_aggregated_volume_043 = if v_rth_barnum == 43 then v_aggregated_volume_043[1] + volume else if 43 <= v_max_bars_in_rth then v_aggregated_volume_043[1] else Double.NaN;
def v_aggregated_volume_044 = if v_rth_barnum == 44 then v_aggregated_volume_044[1] + volume else if 44 <= v_max_bars_in_rth then v_aggregated_volume_044[1] else Double.NaN;
def v_aggregated_volume_045 = if v_rth_barnum == 45 then v_aggregated_volume_045[1] + volume else if 45 <= v_max_bars_in_rth then v_aggregated_volume_045[1] else Double.NaN;
def v_aggregated_volume_046 = if v_rth_barnum == 46 then v_aggregated_volume_046[1] + volume else if 46 <= v_max_bars_in_rth then v_aggregated_volume_046[1] else Double.NaN;
def v_aggregated_volume_047 = if v_rth_barnum == 47 then v_aggregated_volume_047[1] + volume else if 47 <= v_max_bars_in_rth then v_aggregated_volume_047[1] else Double.NaN;
def v_aggregated_volume_048 = if v_rth_barnum == 48 then v_aggregated_volume_048[1] + volume else if 48 <= v_max_bars_in_rth then v_aggregated_volume_048[1] else Double.NaN;
def v_aggregated_volume_049 = if v_rth_barnum == 49 then v_aggregated_volume_049[1] + volume else if 49 <= v_max_bars_in_rth then v_aggregated_volume_049[1] else Double.NaN;
def v_aggregated_volume_050 = if v_rth_barnum == 50 then v_aggregated_volume_050[1] + volume else if 50 <= v_max_bars_in_rth then v_aggregated_volume_050[1] else Double.NaN;
def v_aggregated_volume_051 = if v_rth_barnum == 51 then v_aggregated_volume_051[1] + volume else if 51 <= v_max_bars_in_rth then v_aggregated_volume_051[1] else Double.NaN;
def v_aggregated_volume_052 = if v_rth_barnum == 52 then v_aggregated_volume_052[1] + volume else if 52 <= v_max_bars_in_rth then v_aggregated_volume_052[1] else Double.NaN;
def v_aggregated_volume_053 = if v_rth_barnum == 53 then v_aggregated_volume_053[1] + volume else if 53 <= v_max_bars_in_rth then v_aggregated_volume_053[1] else Double.NaN;
def v_aggregated_volume_054 = if v_rth_barnum == 54 then v_aggregated_volume_054[1] + volume else if 54 <= v_max_bars_in_rth then v_aggregated_volume_054[1] else Double.NaN;
def v_aggregated_volume_055 = if v_rth_barnum == 55 then v_aggregated_volume_055[1] + volume else if 55 <= v_max_bars_in_rth then v_aggregated_volume_055[1] else Double.NaN;
def v_aggregated_volume_056 = if v_rth_barnum == 56 then v_aggregated_volume_056[1] + volume else if 56 <= v_max_bars_in_rth then v_aggregated_volume_056[1] else Double.NaN;
def v_aggregated_volume_057 = if v_rth_barnum == 57 then v_aggregated_volume_057[1] + volume else if 57 <= v_max_bars_in_rth then v_aggregated_volume_057[1] else Double.NaN;
def v_aggregated_volume_058 = if v_rth_barnum == 58 then v_aggregated_volume_058[1] + volume else if 58 <= v_max_bars_in_rth then v_aggregated_volume_058[1] else Double.NaN;
def v_aggregated_volume_059 = if v_rth_barnum == 59 then v_aggregated_volume_059[1] + volume else if 59 <= v_max_bars_in_rth then v_aggregated_volume_059[1] else Double.NaN;
def v_aggregated_volume_060 = if v_rth_barnum == 60 then v_aggregated_volume_060[1] + volume else if 60 <= v_max_bars_in_rth then v_aggregated_volume_060[1] else Double.NaN;
def v_aggregated_volume_061 = if v_rth_barnum == 61 then v_aggregated_volume_061[1] + volume else if 61 <= v_max_bars_in_rth then v_aggregated_volume_061[1] else Double.NaN;
def v_aggregated_volume_062 = if v_rth_barnum == 62 then v_aggregated_volume_062[1] + volume else if 62 <= v_max_bars_in_rth then v_aggregated_volume_062[1] else Double.NaN;
def v_aggregated_volume_063 = if v_rth_barnum == 63 then v_aggregated_volume_063[1] + volume else if 63 <= v_max_bars_in_rth then v_aggregated_volume_063[1] else Double.NaN;
def v_aggregated_volume_064 = if v_rth_barnum == 64 then v_aggregated_volume_064[1] + volume else if 64 <= v_max_bars_in_rth then v_aggregated_volume_064[1] else Double.NaN;
def v_aggregated_volume_065 = if v_rth_barnum == 65 then v_aggregated_volume_065[1] + volume else if 65 <= v_max_bars_in_rth then v_aggregated_volume_065[1] else Double.NaN;
def v_aggregated_volume_066 = if v_rth_barnum == 66 then v_aggregated_volume_066[1] + volume else if 66 <= v_max_bars_in_rth then v_aggregated_volume_066[1] else Double.NaN;
def v_aggregated_volume_067 = if v_rth_barnum == 67 then v_aggregated_volume_067[1] + volume else if 67 <= v_max_bars_in_rth then v_aggregated_volume_067[1] else Double.NaN;
def v_aggregated_volume_068 = if v_rth_barnum == 68 then v_aggregated_volume_068[1] + volume else if 68 <= v_max_bars_in_rth then v_aggregated_volume_068[1] else Double.NaN;
def v_aggregated_volume_069 = if v_rth_barnum == 69 then v_aggregated_volume_069[1] + volume else if 69 <= v_max_bars_in_rth then v_aggregated_volume_069[1] else Double.NaN;
def v_aggregated_volume_070 = if v_rth_barnum == 70 then v_aggregated_volume_070[1] + volume else if 70 <= v_max_bars_in_rth then v_aggregated_volume_070[1] else Double.NaN;
def v_aggregated_volume_071 = if v_rth_barnum == 71 then v_aggregated_volume_071[1] + volume else if 71 <= v_max_bars_in_rth then v_aggregated_volume_071[1] else Double.NaN;
def v_aggregated_volume_072 = if v_rth_barnum == 72 then v_aggregated_volume_072[1] + volume else if 72 <= v_max_bars_in_rth then v_aggregated_volume_072[1] else Double.NaN;
def v_aggregated_volume_073 = if v_rth_barnum == 73 then v_aggregated_volume_073[1] + volume else if 73 <= v_max_bars_in_rth then v_aggregated_volume_073[1] else Double.NaN;
def v_aggregated_volume_074 = if v_rth_barnum == 74 then v_aggregated_volume_074[1] + volume else if 74 <= v_max_bars_in_rth then v_aggregated_volume_074[1] else Double.NaN;
def v_aggregated_volume_075 = if v_rth_barnum == 75 then v_aggregated_volume_075[1] + volume else if 75 <= v_max_bars_in_rth then v_aggregated_volume_075[1] else Double.NaN;
def v_aggregated_volume_076 = if v_rth_barnum == 76 then v_aggregated_volume_076[1] + volume else if 76 <= v_max_bars_in_rth then v_aggregated_volume_076[1] else Double.NaN;
def v_aggregated_volume_077 = if v_rth_barnum == 77 then v_aggregated_volume_077[1] + volume else if 77 <= v_max_bars_in_rth then v_aggregated_volume_077[1] else Double.NaN;
def v_aggregated_volume_078 = if v_rth_barnum == 78 then v_aggregated_volume_078[1] + volume else if 78 <= v_max_bars_in_rth then v_aggregated_volume_078[1] else Double.NaN;
def v_aggregated_volume_079 = if v_rth_barnum == 79 then v_aggregated_volume_079[1] + volume else if 79 <= v_max_bars_in_rth then v_aggregated_volume_079[1] else Double.NaN;
def v_aggregated_volume_080 = if v_rth_barnum == 80 then v_aggregated_volume_080[1] + volume else if 80 <= v_max_bars_in_rth then v_aggregated_volume_080[1] else Double.NaN;
def v_aggregated_volume_081 = if v_rth_barnum == 81 then v_aggregated_volume_081[1] + volume else if 81 <= v_max_bars_in_rth then v_aggregated_volume_081[1] else Double.NaN;
def v_aggregated_volume_082 = if v_rth_barnum == 82 then v_aggregated_volume_082[1] + volume else if 82 <= v_max_bars_in_rth then v_aggregated_volume_082[1] else Double.NaN;
def v_aggregated_volume_083 = if v_rth_barnum == 83 then v_aggregated_volume_083[1] + volume else if 83 <= v_max_bars_in_rth then v_aggregated_volume_083[1] else Double.NaN;
def v_aggregated_volume_084 = if v_rth_barnum == 84 then v_aggregated_volume_084[1] + volume else if 84 <= v_max_bars_in_rth then v_aggregated_volume_084[1] else Double.NaN;
def v_aggregated_volume_085 = if v_rth_barnum == 85 then v_aggregated_volume_085[1] + volume else if 85 <= v_max_bars_in_rth then v_aggregated_volume_085[1] else Double.NaN;
def v_aggregated_volume_086 = if v_rth_barnum == 86 then v_aggregated_volume_086[1] + volume else if 86 <= v_max_bars_in_rth then v_aggregated_volume_086[1] else Double.NaN;
def v_aggregated_volume_087 = if v_rth_barnum == 87 then v_aggregated_volume_087[1] + volume else if 87 <= v_max_bars_in_rth then v_aggregated_volume_087[1] else Double.NaN;
def v_aggregated_volume_088 = if v_rth_barnum == 88 then v_aggregated_volume_088[1] + volume else if 88 <= v_max_bars_in_rth then v_aggregated_volume_088[1] else Double.NaN;
def v_aggregated_volume_089 = if v_rth_barnum == 89 then v_aggregated_volume_089[1] + volume else if 89 <= v_max_bars_in_rth then v_aggregated_volume_089[1] else Double.NaN;
def v_aggregated_volume_090 = if v_rth_barnum == 90 then v_aggregated_volume_090[1] + volume else if 90 <= v_max_bars_in_rth then v_aggregated_volume_090[1] else Double.NaN;
def v_aggregated_volume_091 = if v_rth_barnum == 91 then v_aggregated_volume_091[1] + volume else if 91 <= v_max_bars_in_rth then v_aggregated_volume_091[1] else Double.NaN;
def v_aggregated_volume_092 = if v_rth_barnum == 92 then v_aggregated_volume_092[1] + volume else if 92 <= v_max_bars_in_rth then v_aggregated_volume_092[1] else Double.NaN;
def v_aggregated_volume_093 = if v_rth_barnum == 93 then v_aggregated_volume_093[1] + volume else if 93 <= v_max_bars_in_rth then v_aggregated_volume_093[1] else Double.NaN;
def v_aggregated_volume_094 = if v_rth_barnum == 94 then v_aggregated_volume_094[1] + volume else if 94 <= v_max_bars_in_rth then v_aggregated_volume_094[1] else Double.NaN;
def v_aggregated_volume_095 = if v_rth_barnum == 95 then v_aggregated_volume_095[1] + volume else if 95 <= v_max_bars_in_rth then v_aggregated_volume_095[1] else Double.NaN;
def v_aggregated_volume_096 = if v_rth_barnum == 96 then v_aggregated_volume_096[1] + volume else if 96 <= v_max_bars_in_rth then v_aggregated_volume_096[1] else Double.NaN;
def v_aggregated_volume_097 = if v_rth_barnum == 97 then v_aggregated_volume_097[1] + volume else if 97 <= v_max_bars_in_rth then v_aggregated_volume_097[1] else Double.NaN;
def v_aggregated_volume_098 = if v_rth_barnum == 98 then v_aggregated_volume_098[1] + volume else if 98 <= v_max_bars_in_rth then v_aggregated_volume_098[1] else Double.NaN;
def v_aggregated_volume_099 = if v_rth_barnum == 99 then v_aggregated_volume_099[1] + volume else if 99 <= v_max_bars_in_rth then v_aggregated_volume_099[1] else Double.NaN;
def v_aggregated_volume_100 = if v_rth_barnum == 100 then v_aggregated_volume_100[1] + volume else if 100 <= v_max_bars_in_rth then v_aggregated_volume_100[1] else Double.NaN;
def v_aggregated_volume_101 = if v_rth_barnum == 101 then v_aggregated_volume_101[1] + volume else if 101 <= v_max_bars_in_rth then v_aggregated_volume_101[1] else Double.NaN;
def v_aggregated_volume_102 = if v_rth_barnum == 102 then v_aggregated_volume_102[1] + volume else if 102 <= v_max_bars_in_rth then v_aggregated_volume_102[1] else Double.NaN;
def v_aggregated_volume_103 = if v_rth_barnum == 103 then v_aggregated_volume_103[1] + volume else if 103 <= v_max_bars_in_rth then v_aggregated_volume_103[1] else Double.NaN;
def v_aggregated_volume_104 = if v_rth_barnum == 104 then v_aggregated_volume_104[1] + volume else if 104 <= v_max_bars_in_rth then v_aggregated_volume_104[1] else Double.NaN;
def v_aggregated_volume_105 = if v_rth_barnum == 105 then v_aggregated_volume_105[1] + volume else if 105 <= v_max_bars_in_rth then v_aggregated_volume_105[1] else Double.NaN;
def v_aggregated_volume_106 = if v_rth_barnum == 106 then v_aggregated_volume_106[1] + volume else if 106 <= v_max_bars_in_rth then v_aggregated_volume_106[1] else Double.NaN;
def v_aggregated_volume_107 = if v_rth_barnum == 107 then v_aggregated_volume_107[1] + volume else if 107 <= v_max_bars_in_rth then v_aggregated_volume_107[1] else Double.NaN;
def v_aggregated_volume_108 = if v_rth_barnum == 108 then v_aggregated_volume_108[1] + volume else if 108 <= v_max_bars_in_rth then v_aggregated_volume_108[1] else Double.NaN;
def v_aggregated_volume_109 = if v_rth_barnum == 109 then v_aggregated_volume_109[1] + volume else if 109 <= v_max_bars_in_rth then v_aggregated_volume_109[1] else Double.NaN;
def v_aggregated_volume_110 = if v_rth_barnum == 110 then v_aggregated_volume_110[1] + volume else if 110 <= v_max_bars_in_rth then v_aggregated_volume_110[1] else Double.NaN;
def v_aggregated_volume_111 = if v_rth_barnum == 111 then v_aggregated_volume_111[1] + volume else if 111 <= v_max_bars_in_rth then v_aggregated_volume_111[1] else Double.NaN;
def v_aggregated_volume_112 = if v_rth_barnum == 112 then v_aggregated_volume_112[1] + volume else if 112 <= v_max_bars_in_rth then v_aggregated_volume_112[1] else Double.NaN;
def v_aggregated_volume_113 = if v_rth_barnum == 113 then v_aggregated_volume_113[1] + volume else if 113 <= v_max_bars_in_rth then v_aggregated_volume_113[1] else Double.NaN;
def v_aggregated_volume_114 = if v_rth_barnum == 114 then v_aggregated_volume_114[1] + volume else if 114 <= v_max_bars_in_rth then v_aggregated_volume_114[1] else Double.NaN;
def v_aggregated_volume_115 = if v_rth_barnum == 115 then v_aggregated_volume_115[1] + volume else if 115 <= v_max_bars_in_rth then v_aggregated_volume_115[1] else Double.NaN;
def v_aggregated_volume_116 = if v_rth_barnum == 116 then v_aggregated_volume_116[1] + volume else if 116 <= v_max_bars_in_rth then v_aggregated_volume_116[1] else Double.NaN;
def v_aggregated_volume_117 = if v_rth_barnum == 117 then v_aggregated_volume_117[1] + volume else if 117 <= v_max_bars_in_rth then v_aggregated_volume_117[1] else Double.NaN;
def v_aggregated_volume_118 = if v_rth_barnum == 118 then v_aggregated_volume_118[1] + volume else if 118 <= v_max_bars_in_rth then v_aggregated_volume_118[1] else Double.NaN;
def v_aggregated_volume_119 = if v_rth_barnum == 119 then v_aggregated_volume_119[1] + volume else if 119 <= v_max_bars_in_rth then v_aggregated_volume_119[1] else Double.NaN;
def v_aggregated_volume_120 = if v_rth_barnum == 120 then v_aggregated_volume_120[1] + volume else if 120 <= v_max_bars_in_rth then v_aggregated_volume_120[1] else Double.NaN;
def v_aggregated_volume_121 = if v_rth_barnum == 121 then v_aggregated_volume_121[1] + volume else if 121 <= v_max_bars_in_rth then v_aggregated_volume_121[1] else Double.NaN;
def v_aggregated_volume_122 = if v_rth_barnum == 122 then v_aggregated_volume_122[1] + volume else if 122 <= v_max_bars_in_rth then v_aggregated_volume_122[1] else Double.NaN;
def v_aggregated_volume_123 = if v_rth_barnum == 123 then v_aggregated_volume_123[1] + volume else if 123 <= v_max_bars_in_rth then v_aggregated_volume_123[1] else Double.NaN;
def v_aggregated_volume_124 = if v_rth_barnum == 124 then v_aggregated_volume_124[1] + volume else if 124 <= v_max_bars_in_rth then v_aggregated_volume_124[1] else Double.NaN;
def v_aggregated_volume_125 = if v_rth_barnum == 125 then v_aggregated_volume_125[1] + volume else if 125 <= v_max_bars_in_rth then v_aggregated_volume_125[1] else Double.NaN;
def v_aggregated_volume_126 = if v_rth_barnum == 126 then v_aggregated_volume_126[1] + volume else if 126 <= v_max_bars_in_rth then v_aggregated_volume_126[1] else Double.NaN;
def v_aggregated_volume_127 = if v_rth_barnum == 127 then v_aggregated_volume_127[1] + volume else if 127 <= v_max_bars_in_rth then v_aggregated_volume_127[1] else Double.NaN;
def v_aggregated_volume_128 = if v_rth_barnum == 128 then v_aggregated_volume_128[1] + volume else if 128 <= v_max_bars_in_rth then v_aggregated_volume_128[1] else Double.NaN;
def v_aggregated_volume_129 = if v_rth_barnum == 129 then v_aggregated_volume_129[1] + volume else if 129 <= v_max_bars_in_rth then v_aggregated_volume_129[1] else Double.NaN;
def v_aggregated_volume_130 = if v_rth_barnum == 130 then v_aggregated_volume_130[1] + volume else if 130 <= v_max_bars_in_rth then v_aggregated_volume_130[1] else Double.NaN;
def v_aggregated_volume_131 = if v_rth_barnum == 131 then v_aggregated_volume_131[1] + volume else if 131 <= v_max_bars_in_rth then v_aggregated_volume_131[1] else Double.NaN;
def v_aggregated_volume_132 = if v_rth_barnum == 132 then v_aggregated_volume_132[1] + volume else if 132 <= v_max_bars_in_rth then v_aggregated_volume_132[1] else Double.NaN;
def v_aggregated_volume_133 = if v_rth_barnum == 133 then v_aggregated_volume_133[1] + volume else if 133 <= v_max_bars_in_rth then v_aggregated_volume_133[1] else Double.NaN;
def v_aggregated_volume_134 = if v_rth_barnum == 134 then v_aggregated_volume_134[1] + volume else if 134 <= v_max_bars_in_rth then v_aggregated_volume_134[1] else Double.NaN;
def v_aggregated_volume_135 = if v_rth_barnum == 135 then v_aggregated_volume_135[1] + volume else if 135 <= v_max_bars_in_rth then v_aggregated_volume_135[1] else Double.NaN;
def v_aggregated_volume_136 = if v_rth_barnum == 136 then v_aggregated_volume_136[1] + volume else if 136 <= v_max_bars_in_rth then v_aggregated_volume_136[1] else Double.NaN;
def v_aggregated_volume_137 = if v_rth_barnum == 137 then v_aggregated_volume_137[1] + volume else if 137 <= v_max_bars_in_rth then v_aggregated_volume_137[1] else Double.NaN;
def v_aggregated_volume_138 = if v_rth_barnum == 138 then v_aggregated_volume_138[1] + volume else if 138 <= v_max_bars_in_rth then v_aggregated_volume_138[1] else Double.NaN;
def v_aggregated_volume_139 = if v_rth_barnum == 139 then v_aggregated_volume_139[1] + volume else if 139 <= v_max_bars_in_rth then v_aggregated_volume_139[1] else Double.NaN;
def v_aggregated_volume_140 = if v_rth_barnum == 140 then v_aggregated_volume_140[1] + volume else if 140 <= v_max_bars_in_rth then v_aggregated_volume_140[1] else Double.NaN;
def v_aggregated_volume_141 = if v_rth_barnum == 141 then v_aggregated_volume_141[1] + volume else if 141 <= v_max_bars_in_rth then v_aggregated_volume_141[1] else Double.NaN;
def v_aggregated_volume_142 = if v_rth_barnum == 142 then v_aggregated_volume_142[1] + volume else if 142 <= v_max_bars_in_rth then v_aggregated_volume_142[1] else Double.NaN;
def v_aggregated_volume_143 = if v_rth_barnum == 143 then v_aggregated_volume_143[1] + volume else if 143 <= v_max_bars_in_rth then v_aggregated_volume_143[1] else Double.NaN;
def v_aggregated_volume_144 = if v_rth_barnum == 144 then v_aggregated_volume_144[1] + volume else if 144 <= v_max_bars_in_rth then v_aggregated_volume_144[1] else Double.NaN;
def v_aggregated_volume_145 = if v_rth_barnum == 145 then v_aggregated_volume_145[1] + volume else if 145 <= v_max_bars_in_rth then v_aggregated_volume_145[1] else Double.NaN;
def v_aggregated_volume_146 = if v_rth_barnum == 146 then v_aggregated_volume_146[1] + volume else if 146 <= v_max_bars_in_rth then v_aggregated_volume_146[1] else Double.NaN;
def v_aggregated_volume_147 = if v_rth_barnum == 147 then v_aggregated_volume_147[1] + volume else if 147 <= v_max_bars_in_rth then v_aggregated_volume_147[1] else Double.NaN;
def v_aggregated_volume_148 = if v_rth_barnum == 148 then v_aggregated_volume_148[1] + volume else if 148 <= v_max_bars_in_rth then v_aggregated_volume_148[1] else Double.NaN;
def v_aggregated_volume_149 = if v_rth_barnum == 149 then v_aggregated_volume_149[1] + volume else if 149 <= v_max_bars_in_rth then v_aggregated_volume_149[1] else Double.NaN;
def v_aggregated_volume_150 = if v_rth_barnum == 150 then v_aggregated_volume_150[1] + volume else if 150 <= v_max_bars_in_rth then v_aggregated_volume_150[1] else Double.NaN;
def v_aggregated_volume_151 = if v_rth_barnum == 151 then v_aggregated_volume_151[1] + volume else if 151 <= v_max_bars_in_rth then v_aggregated_volume_151[1] else Double.NaN;
def v_aggregated_volume_152 = if v_rth_barnum == 152 then v_aggregated_volume_152[1] + volume else if 152 <= v_max_bars_in_rth then v_aggregated_volume_152[1] else Double.NaN;
def v_aggregated_volume_153 = if v_rth_barnum == 153 then v_aggregated_volume_153[1] + volume else if 153 <= v_max_bars_in_rth then v_aggregated_volume_153[1] else Double.NaN;
def v_aggregated_volume_154 = if v_rth_barnum == 154 then v_aggregated_volume_154[1] + volume else if 154 <= v_max_bars_in_rth then v_aggregated_volume_154[1] else Double.NaN;
def v_aggregated_volume_155 = if v_rth_barnum == 155 then v_aggregated_volume_155[1] + volume else if 155 <= v_max_bars_in_rth then v_aggregated_volume_155[1] else Double.NaN;
def v_aggregated_volume_156 = if v_rth_barnum == 156 then v_aggregated_volume_156[1] + volume else if 156 <= v_max_bars_in_rth then v_aggregated_volume_156[1] else Double.NaN;
def v_aggregated_volume_157 = if v_rth_barnum == 157 then v_aggregated_volume_157[1] + volume else if 157 <= v_max_bars_in_rth then v_aggregated_volume_157[1] else Double.NaN;
def v_aggregated_volume_158 = if v_rth_barnum == 158 then v_aggregated_volume_158[1] + volume else if 158 <= v_max_bars_in_rth then v_aggregated_volume_158[1] else Double.NaN;
def v_aggregated_volume_159 = if v_rth_barnum == 159 then v_aggregated_volume_159[1] + volume else if 159 <= v_max_bars_in_rth then v_aggregated_volume_159[1] else Double.NaN;
def v_aggregated_volume_160 = if v_rth_barnum == 160 then v_aggregated_volume_160[1] + volume else if 160 <= v_max_bars_in_rth then v_aggregated_volume_160[1] else Double.NaN;
def v_aggregated_volume_161 = if v_rth_barnum == 161 then v_aggregated_volume_161[1] + volume else if 161 <= v_max_bars_in_rth then v_aggregated_volume_161[1] else Double.NaN;
def v_aggregated_volume_162 = if v_rth_barnum == 162 then v_aggregated_volume_162[1] + volume else if 162 <= v_max_bars_in_rth then v_aggregated_volume_162[1] else Double.NaN;
def v_aggregated_volume_163 = if v_rth_barnum == 163 then v_aggregated_volume_163[1] + volume else if 163 <= v_max_bars_in_rth then v_aggregated_volume_163[1] else Double.NaN;
def v_aggregated_volume_164 = if v_rth_barnum == 164 then v_aggregated_volume_164[1] + volume else if 164 <= v_max_bars_in_rth then v_aggregated_volume_164[1] else Double.NaN;
def v_aggregated_volume_165 = if v_rth_barnum == 165 then v_aggregated_volume_165[1] + volume else if 165 <= v_max_bars_in_rth then v_aggregated_volume_165[1] else Double.NaN;
def v_aggregated_volume_166 = if v_rth_barnum == 166 then v_aggregated_volume_166[1] + volume else if 166 <= v_max_bars_in_rth then v_aggregated_volume_166[1] else Double.NaN;
def v_aggregated_volume_167 = if v_rth_barnum == 167 then v_aggregated_volume_167[1] + volume else if 167 <= v_max_bars_in_rth then v_aggregated_volume_167[1] else Double.NaN;
def v_aggregated_volume_168 = if v_rth_barnum == 168 then v_aggregated_volume_168[1] + volume else if 168 <= v_max_bars_in_rth then v_aggregated_volume_168[1] else Double.NaN;
def v_aggregated_volume_169 = if v_rth_barnum == 169 then v_aggregated_volume_169[1] + volume else if 169 <= v_max_bars_in_rth then v_aggregated_volume_169[1] else Double.NaN;
def v_aggregated_volume_170 = if v_rth_barnum == 170 then v_aggregated_volume_170[1] + volume else if 170 <= v_max_bars_in_rth then v_aggregated_volume_170[1] else Double.NaN;
def v_aggregated_volume_171 = if v_rth_barnum == 171 then v_aggregated_volume_171[1] + volume else if 171 <= v_max_bars_in_rth then v_aggregated_volume_171[1] else Double.NaN;
def v_aggregated_volume_172 = if v_rth_barnum == 172 then v_aggregated_volume_172[1] + volume else if 172 <= v_max_bars_in_rth then v_aggregated_volume_172[1] else Double.NaN;
def v_aggregated_volume_173 = if v_rth_barnum == 173 then v_aggregated_volume_173[1] + volume else if 173 <= v_max_bars_in_rth then v_aggregated_volume_173[1] else Double.NaN;
def v_aggregated_volume_174 = if v_rth_barnum == 174 then v_aggregated_volume_174[1] + volume else if 174 <= v_max_bars_in_rth then v_aggregated_volume_174[1] else Double.NaN;
def v_aggregated_volume_175 = if v_rth_barnum == 175 then v_aggregated_volume_175[1] + volume else if 175 <= v_max_bars_in_rth then v_aggregated_volume_175[1] else Double.NaN;
def v_aggregated_volume_176 = if v_rth_barnum == 176 then v_aggregated_volume_176[1] + volume else if 176 <= v_max_bars_in_rth then v_aggregated_volume_176[1] else Double.NaN;
def v_aggregated_volume_177 = if v_rth_barnum == 177 then v_aggregated_volume_177[1] + volume else if 177 <= v_max_bars_in_rth then v_aggregated_volume_177[1] else Double.NaN;
def v_aggregated_volume_178 = if v_rth_barnum == 178 then v_aggregated_volume_178[1] + volume else if 178 <= v_max_bars_in_rth then v_aggregated_volume_178[1] else Double.NaN;
def v_aggregated_volume_179 = if v_rth_barnum == 179 then v_aggregated_volume_179[1] + volume else if 179 <= v_max_bars_in_rth then v_aggregated_volume_179[1] else Double.NaN;
def v_aggregated_volume_180 = if v_rth_barnum == 180 then v_aggregated_volume_180[1] + volume else if 180 <= v_max_bars_in_rth then v_aggregated_volume_180[1] else Double.NaN;
def v_aggregated_volume_181 = if v_rth_barnum == 181 then v_aggregated_volume_181[1] + volume else if 181 <= v_max_bars_in_rth then v_aggregated_volume_181[1] else Double.NaN;
def v_aggregated_volume_182 = if v_rth_barnum == 182 then v_aggregated_volume_182[1] + volume else if 182 <= v_max_bars_in_rth then v_aggregated_volume_182[1] else Double.NaN;
def v_aggregated_volume_183 = if v_rth_barnum == 183 then v_aggregated_volume_183[1] + volume else if 183 <= v_max_bars_in_rth then v_aggregated_volume_183[1] else Double.NaN;
def v_aggregated_volume_184 = if v_rth_barnum == 184 then v_aggregated_volume_184[1] + volume else if 184 <= v_max_bars_in_rth then v_aggregated_volume_184[1] else Double.NaN;
def v_aggregated_volume_185 = if v_rth_barnum == 185 then v_aggregated_volume_185[1] + volume else if 185 <= v_max_bars_in_rth then v_aggregated_volume_185[1] else Double.NaN;
def v_aggregated_volume_186 = if v_rth_barnum == 186 then v_aggregated_volume_186[1] + volume else if 186 <= v_max_bars_in_rth then v_aggregated_volume_186[1] else Double.NaN;
def v_aggregated_volume_187 = if v_rth_barnum == 187 then v_aggregated_volume_187[1] + volume else if 187 <= v_max_bars_in_rth then v_aggregated_volume_187[1] else Double.NaN;
def v_aggregated_volume_188 = if v_rth_barnum == 188 then v_aggregated_volume_188[1] + volume else if 188 <= v_max_bars_in_rth then v_aggregated_volume_188[1] else Double.NaN;
def v_aggregated_volume_189 = if v_rth_barnum == 189 then v_aggregated_volume_189[1] + volume else if 189 <= v_max_bars_in_rth then v_aggregated_volume_189[1] else Double.NaN;
def v_aggregated_volume_190 = if v_rth_barnum == 190 then v_aggregated_volume_190[1] + volume else if 190 <= v_max_bars_in_rth then v_aggregated_volume_190[1] else Double.NaN;
def v_aggregated_volume_191 = if v_rth_barnum == 191 then v_aggregated_volume_191[1] + volume else if 191 <= v_max_bars_in_rth then v_aggregated_volume_191[1] else Double.NaN;
def v_aggregated_volume_192 = if v_rth_barnum == 192 then v_aggregated_volume_192[1] + volume else if 192 <= v_max_bars_in_rth then v_aggregated_volume_192[1] else Double.NaN;
def v_aggregated_volume_193 = if v_rth_barnum == 193 then v_aggregated_volume_193[1] + volume else if 193 <= v_max_bars_in_rth then v_aggregated_volume_193[1] else Double.NaN;
def v_aggregated_volume_194 = if v_rth_barnum == 194 then v_aggregated_volume_194[1] + volume else if 194 <= v_max_bars_in_rth then v_aggregated_volume_194[1] else Double.NaN;
def v_aggregated_volume_195 = if v_rth_barnum == 195 then v_aggregated_volume_195[1] + volume else if 195 <= v_max_bars_in_rth then v_aggregated_volume_195[1] else Double.NaN;
def v_aggregated_volume_196 = if v_rth_barnum == 196 then v_aggregated_volume_196[1] + volume else if 196 <= v_max_bars_in_rth then v_aggregated_volume_196[1] else Double.NaN;
def v_aggregated_volume_197 = if v_rth_barnum == 197 then v_aggregated_volume_197[1] + volume else if 197 <= v_max_bars_in_rth then v_aggregated_volume_197[1] else Double.NaN;
def v_aggregated_volume_198 = if v_rth_barnum == 198 then v_aggregated_volume_198[1] + volume else if 198 <= v_max_bars_in_rth then v_aggregated_volume_198[1] else Double.NaN;
def v_aggregated_volume_199 = if v_rth_barnum == 199 then v_aggregated_volume_199[1] + volume else if 199 <= v_max_bars_in_rth then v_aggregated_volume_199[1] else Double.NaN;
def v_aggregated_volume_200 = if v_rth_barnum == 200 then v_aggregated_volume_200[1] + volume else if 200 <= v_max_bars_in_rth then v_aggregated_volume_200[1] else Double.NaN;
def v_aggregated_volume_201 = if v_rth_barnum == 201 then v_aggregated_volume_201[1] + volume else if 201 <= v_max_bars_in_rth then v_aggregated_volume_201[1] else Double.NaN;
def v_aggregated_volume_202 = if v_rth_barnum == 202 then v_aggregated_volume_202[1] + volume else if 202 <= v_max_bars_in_rth then v_aggregated_volume_202[1] else Double.NaN;
def v_aggregated_volume_203 = if v_rth_barnum == 203 then v_aggregated_volume_203[1] + volume else if 203 <= v_max_bars_in_rth then v_aggregated_volume_203[1] else Double.NaN;


def v_avg_volume_001 = v_aggregated_volume_001 / (if v_rth_barnum >= 1 then v_days else v_days_divisor);
def v_avg_volume_002 = v_aggregated_volume_002 / (if v_rth_barnum >= 2 then v_days else v_days_divisor);
def v_avg_volume_003 = v_aggregated_volume_003 / (if v_rth_barnum >= 3 then v_days else v_days_divisor);
def v_avg_volume_004 = v_aggregated_volume_004 / (if v_rth_barnum >= 4 then v_days else v_days_divisor);
def v_avg_volume_005 = v_aggregated_volume_005 / (if v_rth_barnum >= 5 then v_days else v_days_divisor);
def v_avg_volume_006 = v_aggregated_volume_006 / (if v_rth_barnum >= 6 then v_days else v_days_divisor);
def v_avg_volume_007 = v_aggregated_volume_007 / (if v_rth_barnum >= 7 then v_days else v_days_divisor);
def v_avg_volume_008 = v_aggregated_volume_008 / (if v_rth_barnum >= 8 then v_days else v_days_divisor);
def v_avg_volume_009 = v_aggregated_volume_009 / (if v_rth_barnum >= 9 then v_days else v_days_divisor);
def v_avg_volume_010 = v_aggregated_volume_010 / (if v_rth_barnum >= 10 then v_days else v_days_divisor);
def v_avg_volume_011 = v_aggregated_volume_011 / (if v_rth_barnum >= 11 then v_days else v_days_divisor);
def v_avg_volume_012 = v_aggregated_volume_012 / (if v_rth_barnum >= 12 then v_days else v_days_divisor);
def v_avg_volume_013 = v_aggregated_volume_013 / (if v_rth_barnum >= 13 then v_days else v_days_divisor);
def v_avg_volume_014 = v_aggregated_volume_014 / (if v_rth_barnum >= 14 then v_days else v_days_divisor);
def v_avg_volume_015 = v_aggregated_volume_015 / (if v_rth_barnum >= 15 then v_days else v_days_divisor);
def v_avg_volume_016 = v_aggregated_volume_016 / (if v_rth_barnum >= 16 then v_days else v_days_divisor);
def v_avg_volume_017 = v_aggregated_volume_017 / (if v_rth_barnum >= 17 then v_days else v_days_divisor);
def v_avg_volume_018 = v_aggregated_volume_018 / (if v_rth_barnum >= 18 then v_days else v_days_divisor);
def v_avg_volume_019 = v_aggregated_volume_019 / (if v_rth_barnum >= 19 then v_days else v_days_divisor);
def v_avg_volume_020 = v_aggregated_volume_020 / (if v_rth_barnum >= 20 then v_days else v_days_divisor);
def v_avg_volume_021 = v_aggregated_volume_021 / (if v_rth_barnum >= 21 then v_days else v_days_divisor);
def v_avg_volume_022 = v_aggregated_volume_022 / (if v_rth_barnum >= 22 then v_days else v_days_divisor);
def v_avg_volume_023 = v_aggregated_volume_023 / (if v_rth_barnum >= 23 then v_days else v_days_divisor);
def v_avg_volume_024 = v_aggregated_volume_024 / (if v_rth_barnum >= 24 then v_days else v_days_divisor);
def v_avg_volume_025 = v_aggregated_volume_025 / (if v_rth_barnum >= 25 then v_days else v_days_divisor);
def v_avg_volume_026 = v_aggregated_volume_026 / (if v_rth_barnum >= 26 then v_days else v_days_divisor);
def v_avg_volume_027 = v_aggregated_volume_027 / (if v_rth_barnum >= 27 then v_days else v_days_divisor);
def v_avg_volume_028 = v_aggregated_volume_028 / (if v_rth_barnum >= 28 then v_days else v_days_divisor);
def v_avg_volume_029 = v_aggregated_volume_029 / (if v_rth_barnum >= 29 then v_days else v_days_divisor);
def v_avg_volume_030 = v_aggregated_volume_030 / (if v_rth_barnum >= 30 then v_days else v_days_divisor);
def v_avg_volume_031 = v_aggregated_volume_031 / (if v_rth_barnum >= 31 then v_days else v_days_divisor);
def v_avg_volume_032 = v_aggregated_volume_032 / (if v_rth_barnum >= 32 then v_days else v_days_divisor);
def v_avg_volume_033 = v_aggregated_volume_033 / (if v_rth_barnum >= 33 then v_days else v_days_divisor);
def v_avg_volume_034 = v_aggregated_volume_034 / (if v_rth_barnum >= 34 then v_days else v_days_divisor);
def v_avg_volume_035 = v_aggregated_volume_035 / (if v_rth_barnum >= 35 then v_days else v_days_divisor);
def v_avg_volume_036 = v_aggregated_volume_036 / (if v_rth_barnum >= 36 then v_days else v_days_divisor);
def v_avg_volume_037 = v_aggregated_volume_037 / (if v_rth_barnum >= 37 then v_days else v_days_divisor);
def v_avg_volume_038 = v_aggregated_volume_038 / (if v_rth_barnum >= 38 then v_days else v_days_divisor);
def v_avg_volume_039 = v_aggregated_volume_039 / (if v_rth_barnum >= 39 then v_days else v_days_divisor);
def v_avg_volume_040 = v_aggregated_volume_040 / (if v_rth_barnum >= 40 then v_days else v_days_divisor);
def v_avg_volume_041 = v_aggregated_volume_041 / (if v_rth_barnum >= 41 then v_days else v_days_divisor);
def v_avg_volume_042 = v_aggregated_volume_042 / (if v_rth_barnum >= 42 then v_days else v_days_divisor);
def v_avg_volume_043 = v_aggregated_volume_043 / (if v_rth_barnum >= 43 then v_days else v_days_divisor);
def v_avg_volume_044 = v_aggregated_volume_044 / (if v_rth_barnum >= 44 then v_days else v_days_divisor);
def v_avg_volume_045 = v_aggregated_volume_045 / (if v_rth_barnum >= 45 then v_days else v_days_divisor);
def v_avg_volume_046 = v_aggregated_volume_046 / (if v_rth_barnum >= 46 then v_days else v_days_divisor);
def v_avg_volume_047 = v_aggregated_volume_047 / (if v_rth_barnum >= 47 then v_days else v_days_divisor);
def v_avg_volume_048 = v_aggregated_volume_048 / (if v_rth_barnum >= 48 then v_days else v_days_divisor);
def v_avg_volume_049 = v_aggregated_volume_049 / (if v_rth_barnum >= 49 then v_days else v_days_divisor);
def v_avg_volume_050 = v_aggregated_volume_050 / (if v_rth_barnum >= 50 then v_days else v_days_divisor);
def v_avg_volume_051 = v_aggregated_volume_051 / (if v_rth_barnum >= 51 then v_days else v_days_divisor);
def v_avg_volume_052 = v_aggregated_volume_052 / (if v_rth_barnum >= 52 then v_days else v_days_divisor);
def v_avg_volume_053 = v_aggregated_volume_053 / (if v_rth_barnum >= 53 then v_days else v_days_divisor);
def v_avg_volume_054 = v_aggregated_volume_054 / (if v_rth_barnum >= 54 then v_days else v_days_divisor);
def v_avg_volume_055 = v_aggregated_volume_055 / (if v_rth_barnum >= 55 then v_days else v_days_divisor);
def v_avg_volume_056 = v_aggregated_volume_056 / (if v_rth_barnum >= 56 then v_days else v_days_divisor);
def v_avg_volume_057 = v_aggregated_volume_057 / (if v_rth_barnum >= 57 then v_days else v_days_divisor);
def v_avg_volume_058 = v_aggregated_volume_058 / (if v_rth_barnum >= 58 then v_days else v_days_divisor);
def v_avg_volume_059 = v_aggregated_volume_059 / (if v_rth_barnum >= 59 then v_days else v_days_divisor);
def v_avg_volume_060 = v_aggregated_volume_060 / (if v_rth_barnum >= 60 then v_days else v_days_divisor);
def v_avg_volume_061 = v_aggregated_volume_061 / (if v_rth_barnum >= 61 then v_days else v_days_divisor);
def v_avg_volume_062 = v_aggregated_volume_062 / (if v_rth_barnum >= 62 then v_days else v_days_divisor);
def v_avg_volume_063 = v_aggregated_volume_063 / (if v_rth_barnum >= 63 then v_days else v_days_divisor);
def v_avg_volume_064 = v_aggregated_volume_064 / (if v_rth_barnum >= 64 then v_days else v_days_divisor);
def v_avg_volume_065 = v_aggregated_volume_065 / (if v_rth_barnum >= 65 then v_days else v_days_divisor);
def v_avg_volume_066 = v_aggregated_volume_066 / (if v_rth_barnum >= 66 then v_days else v_days_divisor);
def v_avg_volume_067 = v_aggregated_volume_067 / (if v_rth_barnum >= 67 then v_days else v_days_divisor);
def v_avg_volume_068 = v_aggregated_volume_068 / (if v_rth_barnum >= 68 then v_days else v_days_divisor);
def v_avg_volume_069 = v_aggregated_volume_069 / (if v_rth_barnum >= 69 then v_days else v_days_divisor);
def v_avg_volume_070 = v_aggregated_volume_070 / (if v_rth_barnum >= 70 then v_days else v_days_divisor);
def v_avg_volume_071 = v_aggregated_volume_071 / (if v_rth_barnum >= 71 then v_days else v_days_divisor);
def v_avg_volume_072 = v_aggregated_volume_072 / (if v_rth_barnum >= 72 then v_days else v_days_divisor);
def v_avg_volume_073 = v_aggregated_volume_073 / (if v_rth_barnum >= 73 then v_days else v_days_divisor);
def v_avg_volume_074 = v_aggregated_volume_074 / (if v_rth_barnum >= 74 then v_days else v_days_divisor);
def v_avg_volume_075 = v_aggregated_volume_075 / (if v_rth_barnum >= 75 then v_days else v_days_divisor);
def v_avg_volume_076 = v_aggregated_volume_076 / (if v_rth_barnum >= 76 then v_days else v_days_divisor);
def v_avg_volume_077 = v_aggregated_volume_077 / (if v_rth_barnum >= 77 then v_days else v_days_divisor);
def v_avg_volume_078 = v_aggregated_volume_078 / (if v_rth_barnum >= 78 then v_days else v_days_divisor);
def v_avg_volume_079 = v_aggregated_volume_079 / (if v_rth_barnum >= 79 then v_days else v_days_divisor);
def v_avg_volume_080 = v_aggregated_volume_080 / (if v_rth_barnum >= 80 then v_days else v_days_divisor);
def v_avg_volume_081 = v_aggregated_volume_081 / (if v_rth_barnum >= 81 then v_days else v_days_divisor);
def v_avg_volume_082 = v_aggregated_volume_082 / (if v_rth_barnum >= 82 then v_days else v_days_divisor);
def v_avg_volume_083 = v_aggregated_volume_083 / (if v_rth_barnum >= 83 then v_days else v_days_divisor);
def v_avg_volume_084 = v_aggregated_volume_084 / (if v_rth_barnum >= 84 then v_days else v_days_divisor);
def v_avg_volume_085 = v_aggregated_volume_085 / (if v_rth_barnum >= 85 then v_days else v_days_divisor);
def v_avg_volume_086 = v_aggregated_volume_086 / (if v_rth_barnum >= 86 then v_days else v_days_divisor);
def v_avg_volume_087 = v_aggregated_volume_087 / (if v_rth_barnum >= 87 then v_days else v_days_divisor);
def v_avg_volume_088 = v_aggregated_volume_088 / (if v_rth_barnum >= 88 then v_days else v_days_divisor);
def v_avg_volume_089 = v_aggregated_volume_089 / (if v_rth_barnum >= 89 then v_days else v_days_divisor);
def v_avg_volume_090 = v_aggregated_volume_090 / (if v_rth_barnum >= 90 then v_days else v_days_divisor);
def v_avg_volume_091 = v_aggregated_volume_091 / (if v_rth_barnum >= 91 then v_days else v_days_divisor);
def v_avg_volume_092 = v_aggregated_volume_092 / (if v_rth_barnum >= 92 then v_days else v_days_divisor);
def v_avg_volume_093 = v_aggregated_volume_093 / (if v_rth_barnum >= 93 then v_days else v_days_divisor);
def v_avg_volume_094 = v_aggregated_volume_094 / (if v_rth_barnum >= 94 then v_days else v_days_divisor);
def v_avg_volume_095 = v_aggregated_volume_095 / (if v_rth_barnum >= 95 then v_days else v_days_divisor);
def v_avg_volume_096 = v_aggregated_volume_096 / (if v_rth_barnum >= 96 then v_days else v_days_divisor);
def v_avg_volume_097 = v_aggregated_volume_097 / (if v_rth_barnum >= 97 then v_days else v_days_divisor);
def v_avg_volume_098 = v_aggregated_volume_098 / (if v_rth_barnum >= 98 then v_days else v_days_divisor);
def v_avg_volume_099 = v_aggregated_volume_099 / (if v_rth_barnum >= 99 then v_days else v_days_divisor);
def v_avg_volume_100 = v_aggregated_volume_100 / (if v_rth_barnum >= 100 then v_days else v_days_divisor);
def v_avg_volume_101 = v_aggregated_volume_101 / (if v_rth_barnum >= 101 then v_days else v_days_divisor);
def v_avg_volume_102 = v_aggregated_volume_102 / (if v_rth_barnum >= 102 then v_days else v_days_divisor);
def v_avg_volume_103 = v_aggregated_volume_103 / (if v_rth_barnum >= 103 then v_days else v_days_divisor);
def v_avg_volume_104 = v_aggregated_volume_104 / (if v_rth_barnum >= 104 then v_days else v_days_divisor);
def v_avg_volume_105 = v_aggregated_volume_105 / (if v_rth_barnum >= 105 then v_days else v_days_divisor);
def v_avg_volume_106 = v_aggregated_volume_106 / (if v_rth_barnum >= 106 then v_days else v_days_divisor);
def v_avg_volume_107 = v_aggregated_volume_107 / (if v_rth_barnum >= 107 then v_days else v_days_divisor);
def v_avg_volume_108 = v_aggregated_volume_108 / (if v_rth_barnum >= 108 then v_days else v_days_divisor);
def v_avg_volume_109 = v_aggregated_volume_109 / (if v_rth_barnum >= 109 then v_days else v_days_divisor);
def v_avg_volume_110 = v_aggregated_volume_110 / (if v_rth_barnum >= 110 then v_days else v_days_divisor);
def v_avg_volume_111 = v_aggregated_volume_111 / (if v_rth_barnum >= 111 then v_days else v_days_divisor);
def v_avg_volume_112 = v_aggregated_volume_112 / (if v_rth_barnum >= 112 then v_days else v_days_divisor);
def v_avg_volume_113 = v_aggregated_volume_113 / (if v_rth_barnum >= 113 then v_days else v_days_divisor);
def v_avg_volume_114 = v_aggregated_volume_114 / (if v_rth_barnum >= 114 then v_days else v_days_divisor);
def v_avg_volume_115 = v_aggregated_volume_115 / (if v_rth_barnum >= 115 then v_days else v_days_divisor);
def v_avg_volume_116 = v_aggregated_volume_116 / (if v_rth_barnum >= 116 then v_days else v_days_divisor);
def v_avg_volume_117 = v_aggregated_volume_117 / (if v_rth_barnum >= 117 then v_days else v_days_divisor);
def v_avg_volume_118 = v_aggregated_volume_118 / (if v_rth_barnum >= 118 then v_days else v_days_divisor);
def v_avg_volume_119 = v_aggregated_volume_119 / (if v_rth_barnum >= 119 then v_days else v_days_divisor);
def v_avg_volume_120 = v_aggregated_volume_120 / (if v_rth_barnum >= 120 then v_days else v_days_divisor);
def v_avg_volume_121 = v_aggregated_volume_121 / (if v_rth_barnum >= 121 then v_days else v_days_divisor);
def v_avg_volume_122 = v_aggregated_volume_122 / (if v_rth_barnum >= 122 then v_days else v_days_divisor);
def v_avg_volume_123 = v_aggregated_volume_123 / (if v_rth_barnum >= 123 then v_days else v_days_divisor);
def v_avg_volume_124 = v_aggregated_volume_124 / (if v_rth_barnum >= 124 then v_days else v_days_divisor);
def v_avg_volume_125 = v_aggregated_volume_125 / (if v_rth_barnum >= 125 then v_days else v_days_divisor);
def v_avg_volume_126 = v_aggregated_volume_126 / (if v_rth_barnum >= 126 then v_days else v_days_divisor);
def v_avg_volume_127 = v_aggregated_volume_127 / (if v_rth_barnum >= 127 then v_days else v_days_divisor);
def v_avg_volume_128 = v_aggregated_volume_128 / (if v_rth_barnum >= 128 then v_days else v_days_divisor);
def v_avg_volume_129 = v_aggregated_volume_129 / (if v_rth_barnum >= 129 then v_days else v_days_divisor);
def v_avg_volume_130 = v_aggregated_volume_130 / (if v_rth_barnum >= 130 then v_days else v_days_divisor);
def v_avg_volume_131 = v_aggregated_volume_131 / (if v_rth_barnum >= 131 then v_days else v_days_divisor);
def v_avg_volume_132 = v_aggregated_volume_132 / (if v_rth_barnum >= 132 then v_days else v_days_divisor);
def v_avg_volume_133 = v_aggregated_volume_133 / (if v_rth_barnum >= 133 then v_days else v_days_divisor);
def v_avg_volume_134 = v_aggregated_volume_134 / (if v_rth_barnum >= 134 then v_days else v_days_divisor);
def v_avg_volume_135 = v_aggregated_volume_135 / (if v_rth_barnum >= 135 then v_days else v_days_divisor);
def v_avg_volume_136 = v_aggregated_volume_136 / (if v_rth_barnum >= 136 then v_days else v_days_divisor);
def v_avg_volume_137 = v_aggregated_volume_137 / (if v_rth_barnum >= 137 then v_days else v_days_divisor);
def v_avg_volume_138 = v_aggregated_volume_138 / (if v_rth_barnum >= 138 then v_days else v_days_divisor);
def v_avg_volume_139 = v_aggregated_volume_139 / (if v_rth_barnum >= 139 then v_days else v_days_divisor);
def v_avg_volume_140 = v_aggregated_volume_140 / (if v_rth_barnum >= 140 then v_days else v_days_divisor);
def v_avg_volume_141 = v_aggregated_volume_141 / (if v_rth_barnum >= 141 then v_days else v_days_divisor);
def v_avg_volume_142 = v_aggregated_volume_142 / (if v_rth_barnum >= 142 then v_days else v_days_divisor);
def v_avg_volume_143 = v_aggregated_volume_143 / (if v_rth_barnum >= 143 then v_days else v_days_divisor);
def v_avg_volume_144 = v_aggregated_volume_144 / (if v_rth_barnum >= 144 then v_days else v_days_divisor);
def v_avg_volume_145 = v_aggregated_volume_145 / (if v_rth_barnum >= 145 then v_days else v_days_divisor);
def v_avg_volume_146 = v_aggregated_volume_146 / (if v_rth_barnum >= 146 then v_days else v_days_divisor);
def v_avg_volume_147 = v_aggregated_volume_147 / (if v_rth_barnum >= 147 then v_days else v_days_divisor);
def v_avg_volume_148 = v_aggregated_volume_148 / (if v_rth_barnum >= 148 then v_days else v_days_divisor);
def v_avg_volume_149 = v_aggregated_volume_149 / (if v_rth_barnum >= 149 then v_days else v_days_divisor);
def v_avg_volume_150 = v_aggregated_volume_150 / (if v_rth_barnum >= 150 then v_days else v_days_divisor);
def v_avg_volume_151 = v_aggregated_volume_151 / (if v_rth_barnum >= 151 then v_days else v_days_divisor);
def v_avg_volume_152 = v_aggregated_volume_152 / (if v_rth_barnum >= 152 then v_days else v_days_divisor);
def v_avg_volume_153 = v_aggregated_volume_153 / (if v_rth_barnum >= 153 then v_days else v_days_divisor);
def v_avg_volume_154 = v_aggregated_volume_154 / (if v_rth_barnum >= 154 then v_days else v_days_divisor);
def v_avg_volume_155 = v_aggregated_volume_155 / (if v_rth_barnum >= 155 then v_days else v_days_divisor);
def v_avg_volume_156 = v_aggregated_volume_156 / (if v_rth_barnum >= 156 then v_days else v_days_divisor);
def v_avg_volume_157 = v_aggregated_volume_157 / (if v_rth_barnum >= 157 then v_days else v_days_divisor);
def v_avg_volume_158 = v_aggregated_volume_158 / (if v_rth_barnum >= 158 then v_days else v_days_divisor);
def v_avg_volume_159 = v_aggregated_volume_159 / (if v_rth_barnum >= 159 then v_days else v_days_divisor);
def v_avg_volume_160 = v_aggregated_volume_160 / (if v_rth_barnum >= 160 then v_days else v_days_divisor);
def v_avg_volume_161 = v_aggregated_volume_161 / (if v_rth_barnum >= 161 then v_days else v_days_divisor);
def v_avg_volume_162 = v_aggregated_volume_162 / (if v_rth_barnum >= 162 then v_days else v_days_divisor);
def v_avg_volume_163 = v_aggregated_volume_163 / (if v_rth_barnum >= 163 then v_days else v_days_divisor);
def v_avg_volume_164 = v_aggregated_volume_164 / (if v_rth_barnum >= 164 then v_days else v_days_divisor);
def v_avg_volume_165 = v_aggregated_volume_165 / (if v_rth_barnum >= 165 then v_days else v_days_divisor);
def v_avg_volume_166 = v_aggregated_volume_166 / (if v_rth_barnum >= 166 then v_days else v_days_divisor);
def v_avg_volume_167 = v_aggregated_volume_167 / (if v_rth_barnum >= 167 then v_days else v_days_divisor);
def v_avg_volume_168 = v_aggregated_volume_168 / (if v_rth_barnum >= 168 then v_days else v_days_divisor);
def v_avg_volume_169 = v_aggregated_volume_169 / (if v_rth_barnum >= 169 then v_days else v_days_divisor);
def v_avg_volume_170 = v_aggregated_volume_170 / (if v_rth_barnum >= 170 then v_days else v_days_divisor);
def v_avg_volume_171 = v_aggregated_volume_171 / (if v_rth_barnum >= 171 then v_days else v_days_divisor);
def v_avg_volume_172 = v_aggregated_volume_172 / (if v_rth_barnum >= 172 then v_days else v_days_divisor);
def v_avg_volume_173 = v_aggregated_volume_173 / (if v_rth_barnum >= 173 then v_days else v_days_divisor);
def v_avg_volume_174 = v_aggregated_volume_174 / (if v_rth_barnum >= 174 then v_days else v_days_divisor);
def v_avg_volume_175 = v_aggregated_volume_175 / (if v_rth_barnum >= 175 then v_days else v_days_divisor);
def v_avg_volume_176 = v_aggregated_volume_176 / (if v_rth_barnum >= 176 then v_days else v_days_divisor);
def v_avg_volume_177 = v_aggregated_volume_177 / (if v_rth_barnum >= 177 then v_days else v_days_divisor);
def v_avg_volume_178 = v_aggregated_volume_178 / (if v_rth_barnum >= 178 then v_days else v_days_divisor);
def v_avg_volume_179 = v_aggregated_volume_179 / (if v_rth_barnum >= 179 then v_days else v_days_divisor);
def v_avg_volume_180 = v_aggregated_volume_180 / (if v_rth_barnum >= 180 then v_days else v_days_divisor);
def v_avg_volume_181 = v_aggregated_volume_181 / (if v_rth_barnum >= 181 then v_days else v_days_divisor);
def v_avg_volume_182 = v_aggregated_volume_182 / (if v_rth_barnum >= 182 then v_days else v_days_divisor);
def v_avg_volume_183 = v_aggregated_volume_183 / (if v_rth_barnum >= 183 then v_days else v_days_divisor);
def v_avg_volume_184 = v_aggregated_volume_184 / (if v_rth_barnum >= 184 then v_days else v_days_divisor);
def v_avg_volume_185 = v_aggregated_volume_185 / (if v_rth_barnum >= 185 then v_days else v_days_divisor);
def v_avg_volume_186 = v_aggregated_volume_186 / (if v_rth_barnum >= 186 then v_days else v_days_divisor);
def v_avg_volume_187 = v_aggregated_volume_187 / (if v_rth_barnum >= 187 then v_days else v_days_divisor);
def v_avg_volume_188 = v_aggregated_volume_188 / (if v_rth_barnum >= 188 then v_days else v_days_divisor);
def v_avg_volume_189 = v_aggregated_volume_189 / (if v_rth_barnum >= 189 then v_days else v_days_divisor);
def v_avg_volume_190 = v_aggregated_volume_190 / (if v_rth_barnum >= 190 then v_days else v_days_divisor);
def v_avg_volume_191 = v_aggregated_volume_191 / (if v_rth_barnum >= 191 then v_days else v_days_divisor);
def v_avg_volume_192 = v_aggregated_volume_192 / (if v_rth_barnum >= 192 then v_days else v_days_divisor);
def v_avg_volume_193 = v_aggregated_volume_193 / (if v_rth_barnum >= 193 then v_days else v_days_divisor);
def v_avg_volume_194 = v_aggregated_volume_194 / (if v_rth_barnum >= 194 then v_days else v_days_divisor);
def v_avg_volume_195 = v_aggregated_volume_195 / (if v_rth_barnum >= 195 then v_days else v_days_divisor);
def v_avg_volume_196 = v_aggregated_volume_196 / (if v_rth_barnum >= 196 then v_days else v_days_divisor);
def v_avg_volume_197 = v_aggregated_volume_197 / (if v_rth_barnum >= 197 then v_days else v_days_divisor);
def v_avg_volume_198 = v_aggregated_volume_198 / (if v_rth_barnum >= 198 then v_days else v_days_divisor);
def v_avg_volume_199 = v_aggregated_volume_199 / (if v_rth_barnum >= 199 then v_days else v_days_divisor);
def v_avg_volume_200 = v_aggregated_volume_200 / (if v_rth_barnum >= 200 then v_days else v_days_divisor);
def v_avg_volume_201 = v_aggregated_volume_201 / (if v_rth_barnum >= 201 then v_days else v_days_divisor);
def v_avg_volume_202 = v_aggregated_volume_202 / (if v_rth_barnum >= 202 then v_days else v_days_divisor);
def v_avg_volume_203 = v_aggregated_volume_203 / (if v_rth_barnum >= 203 then v_days else v_days_divisor);

def v_avg_bar_volume =
     if v_rth_barnum == 1 then v_avg_volume_001
else if v_rth_barnum == 2 then v_avg_volume_002
else if v_rth_barnum == 3 then v_avg_volume_003
else if v_rth_barnum == 4 then v_avg_volume_004
else if v_rth_barnum == 5 then v_avg_volume_005
else if v_rth_barnum == 6 then v_avg_volume_006
else if v_rth_barnum == 7 then v_avg_volume_007
else if v_rth_barnum == 8 then v_avg_volume_008
else if v_rth_barnum == 9 then v_avg_volume_009
else if v_rth_barnum == 10 then v_avg_volume_010
else if v_rth_barnum == 11 then v_avg_volume_011
else if v_rth_barnum == 12 then v_avg_volume_012
else if v_rth_barnum == 13 then v_avg_volume_013
else if v_rth_barnum == 14 then v_avg_volume_014
else if v_rth_barnum == 15 then v_avg_volume_015
else if v_rth_barnum == 16 then v_avg_volume_016
else if v_rth_barnum == 17 then v_avg_volume_017
else if v_rth_barnum == 18 then v_avg_volume_018
else if v_rth_barnum == 19 then v_avg_volume_019
else if v_rth_barnum == 20 then v_avg_volume_020
else if v_rth_barnum == 21 then v_avg_volume_021
else if v_rth_barnum == 22 then v_avg_volume_022
else if v_rth_barnum == 23 then v_avg_volume_023
else if v_rth_barnum == 24 then v_avg_volume_024
else if v_rth_barnum == 25 then v_avg_volume_025
else if v_rth_barnum == 26 then v_avg_volume_026
else if v_rth_barnum == 27 then v_avg_volume_027
else if v_rth_barnum == 28 then v_avg_volume_028
else if v_rth_barnum == 29 then v_avg_volume_029
else if v_rth_barnum == 30 then v_avg_volume_030
else if v_rth_barnum == 31 then v_avg_volume_031
else if v_rth_barnum == 32 then v_avg_volume_032
else if v_rth_barnum == 33 then v_avg_volume_033
else if v_rth_barnum == 34 then v_avg_volume_034
else if v_rth_barnum == 35 then v_avg_volume_035
else if v_rth_barnum == 36 then v_avg_volume_036
else if v_rth_barnum == 37 then v_avg_volume_037
else if v_rth_barnum == 38 then v_avg_volume_038
else if v_rth_barnum == 39 then v_avg_volume_039
else if v_rth_barnum == 40 then v_avg_volume_040
else if v_rth_barnum == 41 then v_avg_volume_041
else if v_rth_barnum == 42 then v_avg_volume_042
else if v_rth_barnum == 43 then v_avg_volume_043
else if v_rth_barnum == 44 then v_avg_volume_044
else if v_rth_barnum == 45 then v_avg_volume_045
else if v_rth_barnum == 46 then v_avg_volume_046
else if v_rth_barnum == 47 then v_avg_volume_047
else if v_rth_barnum == 48 then v_avg_volume_048
else if v_rth_barnum == 49 then v_avg_volume_049
else if v_rth_barnum == 50 then v_avg_volume_050
else if v_rth_barnum == 51 then v_avg_volume_051
else if v_rth_barnum == 52 then v_avg_volume_052
else if v_rth_barnum == 53 then v_avg_volume_053
else if v_rth_barnum == 54 then v_avg_volume_054
else if v_rth_barnum == 55 then v_avg_volume_055
else if v_rth_barnum == 56 then v_avg_volume_056
else if v_rth_barnum == 57 then v_avg_volume_057
else if v_rth_barnum == 58 then v_avg_volume_058
else if v_rth_barnum == 59 then v_avg_volume_059
else if v_rth_barnum == 60 then v_avg_volume_060
else if v_rth_barnum == 61 then v_avg_volume_061
else if v_rth_barnum == 62 then v_avg_volume_062
else if v_rth_barnum == 63 then v_avg_volume_063
else if v_rth_barnum == 64 then v_avg_volume_064
else if v_rth_barnum == 65 then v_avg_volume_065
else if v_rth_barnum == 66 then v_avg_volume_066
else if v_rth_barnum == 67 then v_avg_volume_067
else if v_rth_barnum == 68 then v_avg_volume_068
else if v_rth_barnum == 69 then v_avg_volume_069
else if v_rth_barnum == 70 then v_avg_volume_070
else if v_rth_barnum == 71 then v_avg_volume_071
else if v_rth_barnum == 72 then v_avg_volume_072
else if v_rth_barnum == 73 then v_avg_volume_073
else if v_rth_barnum == 74 then v_avg_volume_074
else if v_rth_barnum == 75 then v_avg_volume_075
else if v_rth_barnum == 76 then v_avg_volume_076
else if v_rth_barnum == 77 then v_avg_volume_077
else if v_rth_barnum == 78 then v_avg_volume_078
else if v_rth_barnum == 79 then v_avg_volume_079
else if v_rth_barnum == 80 then v_avg_volume_080
else if v_rth_barnum == 81 then v_avg_volume_081
else if v_rth_barnum == 82 then v_avg_volume_082
else if v_rth_barnum == 83 then v_avg_volume_083
else if v_rth_barnum == 84 then v_avg_volume_084
else if v_rth_barnum == 85 then v_avg_volume_085
else if v_rth_barnum == 86 then v_avg_volume_086
else if v_rth_barnum == 87 then v_avg_volume_087
else if v_rth_barnum == 88 then v_avg_volume_088
else if v_rth_barnum == 89 then v_avg_volume_089
else if v_rth_barnum == 90 then v_avg_volume_090
else if v_rth_barnum == 91 then v_avg_volume_091
else if v_rth_barnum == 92 then v_avg_volume_092
else if v_rth_barnum == 93 then v_avg_volume_093
else if v_rth_barnum == 94 then v_avg_volume_094
else if v_rth_barnum == 95 then v_avg_volume_095
else if v_rth_barnum == 96 then v_avg_volume_096
else if v_rth_barnum == 97 then v_avg_volume_097
else if v_rth_barnum == 98 then v_avg_volume_098
else if v_rth_barnum == 99 then v_avg_volume_099
else if v_rth_barnum == 100 then v_avg_volume_100
else if v_rth_barnum == 101 then v_avg_volume_101
else if v_rth_barnum == 102 then v_avg_volume_102
else if v_rth_barnum == 103 then v_avg_volume_103
else if v_rth_barnum == 104 then v_avg_volume_104
else if v_rth_barnum == 105 then v_avg_volume_105
else if v_rth_barnum == 106 then v_avg_volume_106
else if v_rth_barnum == 107 then v_avg_volume_107
else if v_rth_barnum == 108 then v_avg_volume_108
else if v_rth_barnum == 109 then v_avg_volume_109
else if v_rth_barnum == 110 then v_avg_volume_110
else if v_rth_barnum == 111 then v_avg_volume_111
else if v_rth_barnum == 112 then v_avg_volume_112
else if v_rth_barnum == 113 then v_avg_volume_113
else if v_rth_barnum == 114 then v_avg_volume_114
else if v_rth_barnum == 115 then v_avg_volume_115
else if v_rth_barnum == 116 then v_avg_volume_116
else if v_rth_barnum == 117 then v_avg_volume_117
else if v_rth_barnum == 118 then v_avg_volume_118
else if v_rth_barnum == 119 then v_avg_volume_119
else if v_rth_barnum == 120 then v_avg_volume_120
else if v_rth_barnum == 121 then v_avg_volume_121
else if v_rth_barnum == 122 then v_avg_volume_122
else if v_rth_barnum == 123 then v_avg_volume_123
else if v_rth_barnum == 124 then v_avg_volume_124
else if v_rth_barnum == 125 then v_avg_volume_125
else if v_rth_barnum == 126 then v_avg_volume_126
else if v_rth_barnum == 127 then v_avg_volume_127
else if v_rth_barnum == 128 then v_avg_volume_128
else if v_rth_barnum == 129 then v_avg_volume_129
else if v_rth_barnum == 130 then v_avg_volume_130
else if v_rth_barnum == 131 then v_avg_volume_131
else if v_rth_barnum == 132 then v_avg_volume_132
else if v_rth_barnum == 133 then v_avg_volume_133
else if v_rth_barnum == 134 then v_avg_volume_134
else if v_rth_barnum == 135 then v_avg_volume_135
else if v_rth_barnum == 136 then v_avg_volume_136
else if v_rth_barnum == 137 then v_avg_volume_137
else if v_rth_barnum == 138 then v_avg_volume_138
else if v_rth_barnum == 139 then v_avg_volume_139
else if v_rth_barnum == 140 then v_avg_volume_140
else if v_rth_barnum == 141 then v_avg_volume_141
else if v_rth_barnum == 142 then v_avg_volume_142
else if v_rth_barnum == 143 then v_avg_volume_143
else if v_rth_barnum == 144 then v_avg_volume_144
else if v_rth_barnum == 145 then v_avg_volume_145
else if v_rth_barnum == 146 then v_avg_volume_146
else if v_rth_barnum == 147 then v_avg_volume_147
else if v_rth_barnum == 148 then v_avg_volume_148
else if v_rth_barnum == 149 then v_avg_volume_149
else if v_rth_barnum == 150 then v_avg_volume_150
else if v_rth_barnum == 151 then v_avg_volume_151
else if v_rth_barnum == 152 then v_avg_volume_152
else if v_rth_barnum == 153 then v_avg_volume_153
else if v_rth_barnum == 154 then v_avg_volume_154
else if v_rth_barnum == 155 then v_avg_volume_155
else if v_rth_barnum == 156 then v_avg_volume_156
else if v_rth_barnum == 157 then v_avg_volume_157
else if v_rth_barnum == 158 then v_avg_volume_158
else if v_rth_barnum == 159 then v_avg_volume_159
else if v_rth_barnum == 160 then v_avg_volume_160
else if v_rth_barnum == 161 then v_avg_volume_161
else if v_rth_barnum == 162 then v_avg_volume_162
else if v_rth_barnum == 163 then v_avg_volume_163
else if v_rth_barnum == 164 then v_avg_volume_164
else if v_rth_barnum == 165 then v_avg_volume_165
else if v_rth_barnum == 166 then v_avg_volume_166
else if v_rth_barnum == 167 then v_avg_volume_167
else if v_rth_barnum == 168 then v_avg_volume_168
else if v_rth_barnum == 169 then v_avg_volume_169
else if v_rth_barnum == 170 then v_avg_volume_170
else if v_rth_barnum == 171 then v_avg_volume_171
else if v_rth_barnum == 172 then v_avg_volume_172
else if v_rth_barnum == 173 then v_avg_volume_173
else if v_rth_barnum == 174 then v_avg_volume_174
else if v_rth_barnum == 175 then v_avg_volume_175
else if v_rth_barnum == 176 then v_avg_volume_176
else if v_rth_barnum == 177 then v_avg_volume_177
else if v_rth_barnum == 178 then v_avg_volume_178
else if v_rth_barnum == 179 then v_avg_volume_179
else if v_rth_barnum == 180 then v_avg_volume_180
else if v_rth_barnum == 181 then v_avg_volume_181
else if v_rth_barnum == 182 then v_avg_volume_182
else if v_rth_barnum == 183 then v_avg_volume_183
else if v_rth_barnum == 184 then v_avg_volume_184
else if v_rth_barnum == 185 then v_avg_volume_185
else if v_rth_barnum == 186 then v_avg_volume_186
else if v_rth_barnum == 187 then v_avg_volume_187
else if v_rth_barnum == 188 then v_avg_volume_188
else if v_rth_barnum == 189 then v_avg_volume_189
else if v_rth_barnum == 190 then v_avg_volume_190
else if v_rth_barnum == 191 then v_avg_volume_191
else if v_rth_barnum == 192 then v_avg_volume_192
else if v_rth_barnum == 193 then v_avg_volume_193
else if v_rth_barnum == 194 then v_avg_volume_194
else if v_rth_barnum == 195 then v_avg_volume_195
else if v_rth_barnum == 196 then v_avg_volume_196
else if v_rth_barnum == 197 then v_avg_volume_197
else if v_rth_barnum == 198 then v_avg_volume_198
else if v_rth_barnum == 199 then v_avg_volume_199
else if v_rth_barnum == 200 then v_avg_volume_200
else if v_rth_barnum == 201 then v_avg_volume_201
else if v_rth_barnum == 202 then v_avg_volume_202
else if v_rth_barnum == 203 then v_avg_volume_203
else Double.NaN;

def v_accumulated_volume = if v_rth then volume + v_accumulated_volume[1] else 0;
def v_avg_accumulated_volume = if v_rth then v_avg_bar_volume + v_avg_accumulated_volume[1] else 0;
def v_avg_daily_volume = volume(period = AggregationPeriod.DAY)[i_days_length];
def v_pct_to_avg = (v_accumulated_volume / v_avg_accumulated_volume - 1) * 100;
def v_pct_to_avg_pos = if v_pct_to_avg > 0 then v_pct_to_avg else Double.NaN;
def v_pct_to_avg_neg = if v_pct_to_avg < 0 then v_pct_to_avg else Double.NaN;

#PLOTS
plot p_0 = 0;
plot p_avg_daily_volume = v_avg_daily_volume;
plot p_avg_accumulated_volume = v_avg_accumulated_volume;
plot p_accumulated_volume = v_accumulated_volume;
plot p_pct_to_avg_pos = v_pct_to_avg_pos;
plot p_pct_to_avg_neg = v_pct_to_avg_neg;

#PLOT STYLES & SETTINGS
p_0.AssignValueColor(Color.WHITE);
p_avg_daily_volume.SetPaintingStrategy(PaintingStrategy.DASHES);
p_avg_daily_volume.SetDefaultColor(Color.WHITE);
p_avg_accumulated_volume.SetPaintingStrategy(PaintingStrategy.LINE);
p_avg_accumulated_volume.SetDefaultColor(Color.WHITE);
p_avg_accumulated_volume.SetLineWeight(1);
p_accumulated_volume.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
p_accumulated_volume.AssignValueColor(if v_accumulated_volume > v_avg_accumulated_volume then Color.GREEN else Color.RED);
p_pct_to_avg_pos.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
p_pct_to_avg_pos.AssignNormGradientColor(v_rth_barnum + 1, Color.WHITE, Color.GREEN);
p_pct_to_avg_neg.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
p_pct_to_avg_neg.AssignNormGradientColor(v_rth_barnum + 1, Color.RED, Color.WHITE);

#LABELS
AddLabel(i_print_label_accumulation, "ACCUMULATED VOLUME: " + v_accumulated_volume, if v_accumulated_volume > v_avg_accumulated_volume then Color.LIGHT_GREEN else if v_accumulated_volume < v_avg_accumulated_volume then Color.PINK else Color.WHITE);
AddLabel(i_print_label_pct, "PERCENTAGE +/- FROM AVG ACCUMULATION: " + v_pct_to_avg, if v_accumulated_volume > v_avg_accumulated_volume then Color.LIGHT_GREEN else if v_accumulated_volume < v_avg_accumulated_volume then Color.PINK else Color.WHITE);

plot RVOL = v_accumulated_volume / v_avg_accumulated_volume  * 100;
RVOL.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

#v_pct_to_avg.AssignNormGradientColor(20, Color.LIGHT_RED, Color.Green);
RVOL.assignValueColor(if RVOL > 161.8 then Color.green
else if 127 < RVOL and  RVOL < 161.8 then Color.light_green
else if 78.6 < RVOL and  RVOL < 127 then Color.gray
else if 61.8 < RVOL and  RVOL < 78.6 then Color.yellow
else if 38.2 < RVOL and  RVOL < 61.8 then Color.pink
else Color.red);

Thanks in advance.

Regards,
Alok
 

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

Thanks for help @XeoNoX.

But it did not work. I am trying to figure out why its giving wrong values when i exclude pre-market/afterhours data in chart settings. When I include pre-market /afterhours, code works fine.:confused:
 
@alokranjan3 go into your Thinkorswim chart settings by clicking on the gear icon and then go to "equities" tab and turn off "show extended hours"... you can do the same for options and futures if you want.
 
Hey @rad14733

I went through the code and I found that these bold highlighted portion has has RTH, ETH and PRE market. One I fix it, it will work exactly as ZVR in eSignal.

@malone1020, after I get ZVR working properly, I will upload TOS and eSignal plots side by side. Please, wait for coupe of days.

Code:
#fl_zanger_volume_ratio_accumSTUDY.ts
#
#Fil
#Creation date: 10/17/2015
#Edit Log (Date/Editor):
#
#
#
#hint: Conversion of eSignal ZVR; see http://www.esignal.com/partners/add-on-formula-studies/chartpattern.aspx
#hint i_print_label_accumulation: Toggles the <b>ACCUMULATION</b> label
#hint i_print_label_pct: Toggles the <b>PERCENT</b> label
#hint i_days_length: Specifies the number of days over which to compute the average <b>DAILY</b> volume

#INPUTS
input i_print_label_accumulation = YES;
input i_print_label_pct = YES;
input i_days_length = 20;

#ESTABLISH RTH
def v_days_from_epoch = DaysFromDate(19700101);
def v_rth_start = (RegularTradingStart(GetYYYYMMDD())) / (1000 * 60 * 60 * 24);
def v_rth_start_in_minutes = Round((24 * (v_rth_start - v_days_from_epoch) - 5) * 60, 0);

def v_rth_end = (RegularTradingEnd(GetYYYYMMDD())) / (1000 * 60 * 60 * 24);
def v_rth_end_in_minutes = Round((24 * (v_rth_end - v_days_from_epoch) - 5) * 60, 0);

def v_eth_pre = if SecondsFromTime(0) / 60 < v_rth_start_in_minutes then 1 else 0;
def v_eth_post = if SecondsFromTime(0) / 60 >= v_rth_end_in_minutes then 1 else 0;
def v_rth = if (SecondsFromTime(0) / 60) >= v_rth_start_in_minutes and (SecondsFromTime(0) / 60) < v_rth_end_in_minutes then 1 else 0;

#COUNTERS AND STATES
def v_agg_period = GetAggregationPeriod() / 1000;
def v_rth_barnum = if v_rth then RoundDown((SecondsFromTime(0) - v_rth_start_in_minutes * 60) / v_agg_period, 0) + 1 else 0;
def v_max_bars_in_rth = (v_rth_end_in_minutes - v_rth_start_in_minutes) * 60 / v_agg_period;

def v_days = CompoundValue(1, if GetYYYYMMDD() <> GetYYYYMMDD()[1] then v_days[1] + 1 else v_days[1], 1);
def v_days_divisor = if v_days > 1 then (if v_eth_pre then v_days - 1 else v_days) else 1;
 
Last edited:
def v_days_divisor = if v_days > 1 then (if v_eth_pre then v_days - 1 else v_days) else 1;

Its used in the calculation of v_avg_volume_001, v_avg_volume_002.........


Code:
def v_avg_volume_001 = v_aggregated_volume_001 / (if v_rth_barnum >= 1 then v_days else v_days_divisor);
def v_avg_volume_002 = v_aggregated_volume_002 / (if v_rth_barnum >= 2 then v_days else v_days_divisor);
def v_avg_volume_003 = v_aggregated_volume_003 / (if v_rth_barnum >= 3 then v_days else v_days_divisor);
def v_avg_volume_004 = v_aggregated_volume_004 / (if v_rth_barnum >= 4 then v_days else v_days_divisor);
def v_avg_volume_005 = v_aggregated_volume_005 / (if v_rth_barnum >= 5 then v_days else v_days_divisor);
def v_avg_volume_006 = v_aggregated_volume_006 / (if v_rth_barnum >= 6 then v_days else v_days_divisor);
def v_avg_volume_007 = v_aggregated_volume_007 / (if v_rth_barnum >= 7 then v_days else v_days_divisor);
def v_avg_volume_008 = v_aggregated_volume_008 / (if v_rth_barnum >= 8 then v_days else v_days_divisor);
def v_avg_volume_009 = v_aggregated_volume_009 / (if v_rth_barnum >= 9 then v_days else v_days_divisor);
def v_avg_volume_010 = v_aggregated_volume_010 / (if v_rth_barnum >= 10 then v_days else v_days_divisor);
def v_avg_volume_011 = v_aggregated_volume_011 / (if v_rth_barnum >= 11 then v_days else v_days_divisor);
def v_avg_volume_012 = v_aggregated_volume_012 / (if v_rth_barnum >= 12 then v_days else v_days_divisor);
def v_avg_volume_013 = v_aggregated_volume_013 / (if v_rth_barnum >= 13 then v_days else v_days_divisor);
def v_avg_volume_014 = v_aggregated_volume_014 / (if v_rth_barnum >= 14 then v_days else v_days_divisor);
def v_avg_volume_015 = v_aggregated_volume_015 / (if v_rth_barnum >= 15 then v_days else v_days_divisor);
def v_avg_volume_016 = v_aggregated_volume_016 / (if v_rth_barnum >= 16 then v_days else v_days_divisor);
def v_avg_volume_017 = v_aggregated_volume_017 / (if v_rth_barnum >= 17 then v_days else v_days_divisor);
def v_avg_volume_018 = v_aggregated_volume_018 / (if v_rth_barnum >= 18 then v_days else v_days_divisor);
def v_avg_volume_019 = v_aggregated_volume_019 / (if v_rth_barnum >= 19 then v_days else v_days_divisor);
def v_avg_volume_020 = v_aggregated_volume_020 / (if v_rth_barnum >= 20 then v_days else v_days_divisor);
def v_avg_volume_021 = v_aggregated_volume_021 / (if v_rth_barnum >= 21 then v_days else v_days_divisor);
def v_avg_volume_022 = v_aggregated_volume_022 / (if v_rth_barnum >= 22 then v_days else v_days_divisor);
def v_avg_volume_023 = v_aggregated_volume_023 / (if v_rth_barnum >= 23 then v_days else v_days_divisor);
def v_avg_volume_024 = v_aggregated_volume_024 / (if v_rth_barnum >= 24 then v_days else v_days_divisor);
def v_avg_volume_025 = v_aggregated_volume_025 / (if v_rth_barnum >= 25 then v_days else v_days_divisor);
def v_avg_volume_026 = v_aggregated_volume_026 / (if v_rth_barnum >= 26 then v_days else v_days_divisor);
def v_avg_volume_027 = v_aggregated_volume_027 / (if v_rth_barnum >= 27 then v_days else v_days_divisor);
def v_avg_volume_028 = v_aggregated_volume_028 / (if v_rth_barnum >= 28 then v_days else v_days_divisor);
def v_avg_volume_029 = v_aggregated_volume_029 / (if v_rth_barnum >= 29 then v_days else v_days_divisor);
def v_avg_volume_030 = v_aggregated_volume_030 / (if v_rth_barnum >= 30 then v_days else v_days_divisor);
def v_avg_volume_031 = v_aggregated_volume_031 / (if v_rth_barnum >= 31 then v_days else v_days_divisor);
def v_avg_volume_032 = v_aggregated_volume_032 / (if v_rth_barnum >= 32 then v_days else v_days_divisor);
def v_avg_volume_033 = v_aggregated_volume_033 / (if v_rth_barnum >= 33 then v_days else v_days_divisor);
def v_avg_volume_034 = v_aggregated_volume_034 / (if v_rth_barnum >= 34 then v_days else v_days_divisor);
def v_avg_volume_035 = v_aggregated_volume_035 / (if v_rth_barnum >= 35 then v_days else v_days_divisor);
def v_avg_volume_036 = v_aggregated_volume_036 / (if v_rth_barnum >= 36 then v_days else v_days_divisor);
def v_avg_volume_037 = v_aggregated_volume_037 / (if v_rth_barnum >= 37 then v_days else v_days_divisor);
def v_avg_volume_038 = v_aggregated_volume_038 / (if v_rth_barnum >= 38 then v_days else v_days_divisor);
def v_avg_volume_039 = v_aggregated_volume_039 / (if v_rth_barnum >= 39 then v_days else v_days_divisor);
def v_avg_volume_040 = v_aggregated_volume_040 / (if v_rth_barnum >= 40 then v_days else v_days_divisor);
def v_avg_volume_041 = v_aggregated_volume_041 / (if v_rth_barnum >= 41 then v_days else v_days_divisor);
def v_avg_volume_042 = v_aggregated_volume_042 / (if v_rth_barnum >= 42 then v_days else v_days_divisor);
def v_avg_volume_043 = v_aggregated_volume_043 / (if v_rth_barnum >= 43 then v_days else v_days_divisor);
def v_avg_volume_044 = v_aggregated_volume_044 / (if v_rth_barnum >= 44 then v_days else v_days_divisor);
def v_avg_volume_045 = v_aggregated_volume_045 / (if v_rth_barnum >= 45 then v_days else v_days_divisor);
def v_avg_volume_046 = v_aggregated_volume_046 / (if v_rth_barnum >= 46 then v_days else v_days_divisor);
def v_avg_volume_047 = v_aggregated_volume_047 / (if v_rth_barnum >= 47 then v_days else v_days_divisor);
def v_avg_volume_048 = v_aggregated_volume_048 / (if v_rth_barnum >= 48 then v_days else v_days_divisor);
def v_avg_volume_049 = v_aggregated_volume_049 / (if v_rth_barnum >= 49 then v_days else v_days_divisor);
def v_avg_volume_050 = v_aggregated_volume_050 / (if v_rth_barnum >= 50 then v_days else v_days_divisor);
def v_avg_volume_051 = v_aggregated_volume_051 / (if v_rth_barnum >= 51 then v_days else v_days_divisor);
def v_avg_volume_052 = v_aggregated_volume_052 / (if v_rth_barnum >= 52 then v_days else v_days_divisor);
def v_avg_volume_053 = v_aggregated_volume_053 / (if v_rth_barnum >= 53 then v_days else v_days_divisor);
def v_avg_volume_054 = v_aggregated_volume_054 / (if v_rth_barnum >= 54 then v_days else v_days_divisor);
def v_avg_volume_055 = v_aggregated_volume_055 / (if v_rth_barnum >= 55 then v_days else v_days_divisor);
def v_avg_volume_056 = v_aggregated_volume_056 / (if v_rth_barnum >= 56 then v_days else v_days_divisor);
def v_avg_volume_057 = v_aggregated_volume_057 / (if v_rth_barnum >= 57 then v_days else v_days_divisor);
def v_avg_volume_058 = v_aggregated_volume_058 / (if v_rth_barnum >= 58 then v_days else v_days_divisor);
def v_avg_volume_059 = v_aggregated_volume_059 / (if v_rth_barnum >= 59 then v_days else v_days_divisor);
def v_avg_volume_060 = v_aggregated_volume_060 / (if v_rth_barnum >= 60 then v_days else v_days_divisor);
def v_avg_volume_061 = v_aggregated_volume_061 / (if v_rth_barnum >= 61 then v_days else v_days_divisor);
def v_avg_volume_062 = v_aggregated_volume_062 / (if v_rth_barnum >= 62 then v_days else v_days_divisor);
def v_avg_volume_063 = v_aggregated_volume_063 / (if v_rth_barnum >= 63 then v_days else v_days_divisor);
def v_avg_volume_064 = v_aggregated_volume_064 / (if v_rth_barnum >= 64 then v_days else v_days_divisor);
def v_avg_volume_065 = v_aggregated_volume_065 / (if v_rth_barnum >= 65 then v_days else v_days_divisor);
def v_avg_volume_066 = v_aggregated_volume_066 / (if v_rth_barnum >= 66 then v_days else v_days_divisor);
def v_avg_volume_067 = v_aggregated_volume_067 / (if v_rth_barnum >= 67 then v_days else v_days_divisor);
def v_avg_volume_068 = v_aggregated_volume_068 / (if v_rth_barnum >= 68 then v_days else v_days_divisor);
def v_avg_volume_069 = v_aggregated_volume_069 / (if v_rth_barnum >= 69 then v_days else v_days_divisor);
def v_avg_volume_070 = v_aggregated_volume_070 / (if v_rth_barnum >= 70 then v_days else v_days_divisor);
def v_avg_volume_071 = v_aggregated_volume_071 / (if v_rth_barnum >= 71 then v_days else v_days_divisor);
def v_avg_volume_072 = v_aggregated_volume_072 / (if v_rth_barnum >= 72 then v_days else v_days_divisor);
def v_avg_volume_073 = v_aggregated_volume_073 / (if v_rth_barnum >= 73 then v_days else v_days_divisor);
def v_avg_volume_074 = v_aggregated_volume_074 / (if v_rth_barnum >= 74 then v_days else v_days_divisor);
def v_avg_volume_075 = v_aggregated_volume_075 / (if v_rth_barnum >= 75 then v_days else v_days_divisor);
def v_avg_volume_076 = v_aggregated_volume_076 / (if v_rth_barnum >= 76 then v_days else v_days_divisor);
def v_avg_volume_077 = v_aggregated_volume_077 / (if v_rth_barnum >= 77 then v_days else v_days_divisor);
def v_avg_volume_078 = v_aggregated_volume_078 / (if v_rth_barnum >= 78 then v_days else v_days_divisor);
def v_avg_volume_079 = v_aggregated_volume_079 / (if v_rth_barnum >= 79 then v_days else v_days_divisor);
def v_avg_volume_080 = v_aggregated_volume_080 / (if v_rth_barnum >= 80 then v_days else v_days_divisor);
def v_avg_volume_081 = v_aggregated_volume_081 / (if v_rth_barnum >= 81 then v_days else v_days_divisor);
def v_avg_volume_082 = v_aggregated_volume_082 / (if v_rth_barnum >= 82 then v_days else v_days_divisor);
def v_avg_volume_083 = v_aggregated_volume_083 / (if v_rth_barnum >= 83 then v_days else v_days_divisor);
def v_avg_volume_084 = v_aggregated_volume_084 / (if v_rth_barnum >= 84 then v_days else v_days_divisor);
def v_avg_volume_085 = v_aggregated_volume_085 / (if v_rth_barnum >= 85 then v_days else v_days_divisor);
def v_avg_volume_086 = v_aggregated_volume_086 / (if v_rth_barnum >= 86 then v_days else v_days_divisor);
def v_avg_volume_087 = v_aggregated_volume_087 / (if v_rth_barnum >= 87 then v_days else v_days_divisor);
def v_avg_volume_088 = v_aggregated_volume_088 / (if v_rth_barnum >= 88 then v_days else v_days_divisor);
def v_avg_volume_089 = v_aggregated_volume_089 / (if v_rth_barnum >= 89 then v_days else v_days_divisor);
def v_avg_volume_090 = v_aggregated_volume_090 / (if v_rth_barnum >= 90 then v_days else v_days_divisor);
def v_avg_volume_091 = v_aggregated_volume_091 / (if v_rth_barnum >= 91 then v_days else v_days_divisor);
def v_avg_volume_092 = v_aggregated_volume_092 / (if v_rth_barnum >= 92 then v_days else v_days_divisor);
def v_avg_volume_093 = v_aggregated_volume_093 / (if v_rth_barnum >= 93 then v_days else v_days_divisor);
def v_avg_volume_094 = v_aggregated_volume_094 / (if v_rth_barnum >= 94 then v_days else v_days_divisor);
def v_avg_volume_095 = v_aggregated_volume_095 / (if v_rth_barnum >= 95 then v_days else v_days_divisor);
def v_avg_volume_096 = v_aggregated_volume_096 / (if v_rth_barnum >= 96 then v_days else v_days_divisor);
def v_avg_volume_097 = v_aggregated_volume_097 / (if v_rth_barnum >= 97 then v_days else v_days_divisor);
def v_avg_volume_098 = v_aggregated_volume_098 / (if v_rth_barnum >= 98 then v_days else v_days_divisor);
def v_avg_volume_099 = v_aggregated_volume_099 / (if v_rth_barnum >= 99 then v_days else v_days_divisor);
def v_avg_volume_100 = v_aggregated_volume_100 / (if v_rth_barnum >= 100 then v_days else v_days_divisor);
def v_avg_volume_101 = v_aggregated_volume_101 / (if v_rth_barnum >= 101 then v_days else v_days_divisor);
def v_avg_volume_102 = v_aggregated_volume_102 / (if v_rth_barnum >= 102 then v_days else v_days_divisor);
def v_avg_volume_103 = v_aggregated_volume_103 / (if v_rth_barnum >= 103 then v_days else v_days_divisor);
def v_avg_volume_104 = v_aggregated_volume_104 / (if v_rth_barnum >= 104 then v_days else v_days_divisor);
def v_avg_volume_105 = v_aggregated_volume_105 / (if v_rth_barnum >= 105 then v_days else v_days_divisor);
def v_avg_volume_106 = v_aggregated_volume_106 / (if v_rth_barnum >= 106 then v_days else v_days_divisor);
def v_avg_volume_107 = v_aggregated_volume_107 / (if v_rth_barnum >= 107 then v_days else v_days_divisor);
def v_avg_volume_108 = v_aggregated_volume_108 / (if v_rth_barnum >= 108 then v_days else v_days_divisor);
def v_avg_volume_109 = v_aggregated_volume_109 / (if v_rth_barnum >= 109 then v_days else v_days_divisor);
def v_avg_volume_110 = v_aggregated_volume_110 / (if v_rth_barnum >= 110 then v_days else v_days_divisor);
def v_avg_volume_111 = v_aggregated_volume_111 / (if v_rth_barnum >= 111 then v_days else v_days_divisor);
def v_avg_volume_112 = v_aggregated_volume_112 / (if v_rth_barnum >= 112 then v_days else v_days_divisor);
def v_avg_volume_113 = v_aggregated_volume_113 / (if v_rth_barnum >= 113 then v_days else v_days_divisor);
def v_avg_volume_114 = v_aggregated_volume_114 / (if v_rth_barnum >= 114 then v_days else v_days_divisor);
def v_avg_volume_115 = v_aggregated_volume_115 / (if v_rth_barnum >= 115 then v_days else v_days_divisor);
def v_avg_volume_116 = v_aggregated_volume_116 / (if v_rth_barnum >= 116 then v_days else v_days_divisor);
def v_avg_volume_117 = v_aggregated_volume_117 / (if v_rth_barnum >= 117 then v_days else v_days_divisor);
def v_avg_volume_118 = v_aggregated_volume_118 / (if v_rth_barnum >= 118 then v_days else v_days_divisor);
def v_avg_volume_119 = v_aggregated_volume_119 / (if v_rth_barnum >= 119 then v_days else v_days_divisor);
def v_avg_volume_120 = v_aggregated_volume_120 / (if v_rth_barnum >= 120 then v_days else v_days_divisor);
def v_avg_volume_121 = v_aggregated_volume_121 / (if v_rth_barnum >= 121 then v_days else v_days_divisor);
def v_avg_volume_122 = v_aggregated_volume_122 / (if v_rth_barnum >= 122 then v_days else v_days_divisor);
def v_avg_volume_123 = v_aggregated_volume_123 / (if v_rth_barnum >= 123 then v_days else v_days_divisor);
def v_avg_volume_124 = v_aggregated_volume_124 / (if v_rth_barnum >= 124 then v_days else v_days_divisor);
def v_avg_volume_125 = v_aggregated_volume_125 / (if v_rth_barnum >= 125 then v_days else v_days_divisor);
def v_avg_volume_126 = v_aggregated_volume_126 / (if v_rth_barnum >= 126 then v_days else v_days_divisor);
def v_avg_volume_127 = v_aggregated_volume_127 / (if v_rth_barnum >= 127 then v_days else v_days_divisor);
def v_avg_volume_128 = v_aggregated_volume_128 / (if v_rth_barnum >= 128 then v_days else v_days_divisor);
def v_avg_volume_129 = v_aggregated_volume_129 / (if v_rth_barnum >= 129 then v_days else v_days_divisor);
def v_avg_volume_130 = v_aggregated_volume_130 / (if v_rth_barnum >= 130 then v_days else v_days_divisor);
def v_avg_volume_131 = v_aggregated_volume_131 / (if v_rth_barnum >= 131 then v_days else v_days_divisor);
def v_avg_volume_132 = v_aggregated_volume_132 / (if v_rth_barnum >= 132 then v_days else v_days_divisor);
def v_avg_volume_133 = v_aggregated_volume_133 / (if v_rth_barnum >= 133 then v_days else v_days_divisor);
def v_avg_volume_134 = v_aggregated_volume_134 / (if v_rth_barnum >= 134 then v_days else v_days_divisor);
def v_avg_volume_135 = v_aggregated_volume_135 / (if v_rth_barnum >= 135 then v_days else v_days_divisor);
def v_avg_volume_136 = v_aggregated_volume_136 / (if v_rth_barnum >= 136 then v_days else v_days_divisor);
def v_avg_volume_137 = v_aggregated_volume_137 / (if v_rth_barnum >= 137 then v_days else v_days_divisor);
def v_avg_volume_138 = v_aggregated_volume_138 / (if v_rth_barnum >= 138 then v_days else v_days_divisor);
def v_avg_volume_139 = v_aggregated_volume_139 / (if v_rth_barnum >= 139 then v_days else v_days_divisor);
def v_avg_volume_140 = v_aggregated_volume_140 / (if v_rth_barnum >= 140 then v_days else v_days_divisor);
def v_avg_volume_141 = v_aggregated_volume_141 / (if v_rth_barnum >= 141 then v_days else v_days_divisor);
def v_avg_volume_142 = v_aggregated_volume_142 / (if v_rth_barnum >= 142 then v_days else v_days_divisor);
def v_avg_volume_143 = v_aggregated_volume_143 / (if v_rth_barnum >= 143 then v_days else v_days_divisor);
def v_avg_volume_144 = v_aggregated_volume_144 / (if v_rth_barnum >= 144 then v_days else v_days_divisor);
def v_avg_volume_145 = v_aggregated_volume_145 / (if v_rth_barnum >= 145 then v_days else v_days_divisor);
def v_avg_volume_146 = v_aggregated_volume_146 / (if v_rth_barnum >= 146 then v_days else v_days_divisor);
def v_avg_volume_147 = v_aggregated_volume_147 / (if v_rth_barnum >= 147 then v_days else v_days_divisor);
def v_avg_volume_148 = v_aggregated_volume_148 / (if v_rth_barnum >= 148 then v_days else v_days_divisor);
def v_avg_volume_149 = v_aggregated_volume_149 / (if v_rth_barnum >= 149 then v_days else v_days_divisor);
def v_avg_volume_150 = v_aggregated_volume_150 / (if v_rth_barnum >= 150 then v_days else v_days_divisor);
def v_avg_volume_151 = v_aggregated_volume_151 / (if v_rth_barnum >= 151 then v_days else v_days_divisor);
def v_avg_volume_152 = v_aggregated_volume_152 / (if v_rth_barnum >= 152 then v_days else v_days_divisor);
def v_avg_volume_153 = v_aggregated_volume_153 / (if v_rth_barnum >= 153 then v_days else v_days_divisor);
def v_avg_volume_154 = v_aggregated_volume_154 / (if v_rth_barnum >= 154 then v_days else v_days_divisor);
def v_avg_volume_155 = v_aggregated_volume_155 / (if v_rth_barnum >= 155 then v_days else v_days_divisor);
def v_avg_volume_156 = v_aggregated_volume_156 / (if v_rth_barnum >= 156 then v_days else v_days_divisor);
def v_avg_volume_157 = v_aggregated_volume_157 / (if v_rth_barnum >= 157 then v_days else v_days_divisor);
def v_avg_volume_158 = v_aggregated_volume_158 / (if v_rth_barnum >= 158 then v_days else v_days_divisor);
def v_avg_volume_159 = v_aggregated_volume_159 / (if v_rth_barnum >= 159 then v_days else v_days_divisor);
def v_avg_volume_160 = v_aggregated_volume_160 / (if v_rth_barnum >= 160 then v_days else v_days_divisor);
def v_avg_volume_161 = v_aggregated_volume_161 / (if v_rth_barnum >= 161 then v_days else v_days_divisor);
def v_avg_volume_162 = v_aggregated_volume_162 / (if v_rth_barnum >= 162 then v_days else v_days_divisor);
def v_avg_volume_163 = v_aggregated_volume_163 / (if v_rth_barnum >= 163 then v_days else v_days_divisor);
def v_avg_volume_164 = v_aggregated_volume_164 / (if v_rth_barnum >= 164 then v_days else v_days_divisor);
def v_avg_volume_165 = v_aggregated_volume_165 / (if v_rth_barnum >= 165 then v_days else v_days_divisor);
def v_avg_volume_166 = v_aggregated_volume_166 / (if v_rth_barnum >= 166 then v_days else v_days_divisor);
def v_avg_volume_167 = v_aggregated_volume_167 / (if v_rth_barnum >= 167 then v_days else v_days_divisor);
def v_avg_volume_168 = v_aggregated_volume_168 / (if v_rth_barnum >= 168 then v_days else v_days_divisor);
def v_avg_volume_169 = v_aggregated_volume_169 / (if v_rth_barnum >= 169 then v_days else v_days_divisor);
def v_avg_volume_170 = v_aggregated_volume_170 / (if v_rth_barnum >= 170 then v_days else v_days_divisor);
def v_avg_volume_171 = v_aggregated_volume_171 / (if v_rth_barnum >= 171 then v_days else v_days_divisor);
def v_avg_volume_172 = v_aggregated_volume_172 / (if v_rth_barnum >= 172 then v_days else v_days_divisor);
def v_avg_volume_173 = v_aggregated_volume_173 / (if v_rth_barnum >= 173 then v_days else v_days_divisor);
def v_avg_volume_174 = v_aggregated_volume_174 / (if v_rth_barnum >= 174 then v_days else v_days_divisor);
def v_avg_volume_175 = v_aggregated_volume_175 / (if v_rth_barnum >= 175 then v_days else v_days_divisor);
def v_avg_volume_176 = v_aggregated_volume_176 / (if v_rth_barnum >= 176 then v_days else v_days_divisor);
def v_avg_volume_177 = v_aggregated_volume_177 / (if v_rth_barnum >= 177 then v_days else v_days_divisor);
def v_avg_volume_178 = v_aggregated_volume_178 / (if v_rth_barnum >= 178 then v_days else v_days_divisor);
def v_avg_volume_179 = v_aggregated_volume_179 / (if v_rth_barnum >= 179 then v_days else v_days_divisor);
def v_avg_volume_180 = v_aggregated_volume_180 / (if v_rth_barnum >= 180 then v_days else v_days_divisor);
def v_avg_volume_181 = v_aggregated_volume_181 / (if v_rth_barnum >= 181 then v_days else v_days_divisor);
def v_avg_volume_182 = v_aggregated_volume_182 / (if v_rth_barnum >= 182 then v_days else v_days_divisor);
def v_avg_volume_183 = v_aggregated_volume_183 / (if v_rth_barnum >= 183 then v_days else v_days_divisor);
def v_avg_volume_184 = v_aggregated_volume_184 / (if v_rth_barnum >= 184 then v_days else v_days_divisor);
def v_avg_volume_185 = v_aggregated_volume_185 / (if v_rth_barnum >= 185 then v_days else v_days_divisor);
def v_avg_volume_186 = v_aggregated_volume_186 / (if v_rth_barnum >= 186 then v_days else v_days_divisor);
def v_avg_volume_187 = v_aggregated_volume_187 / (if v_rth_barnum >= 187 then v_days else v_days_divisor);
def v_avg_volume_188 = v_aggregated_volume_188 / (if v_rth_barnum >= 188 then v_days else v_days_divisor);
def v_avg_volume_189 = v_aggregated_volume_189 / (if v_rth_barnum >= 189 then v_days else v_days_divisor);
def v_avg_volume_190 = v_aggregated_volume_190 / (if v_rth_barnum >= 190 then v_days else v_days_divisor);
def v_avg_volume_191 = v_aggregated_volume_191 / (if v_rth_barnum >= 191 then v_days else v_days_divisor);
def v_avg_volume_192 = v_aggregated_volume_192 / (if v_rth_barnum >= 192 then v_days else v_days_divisor);
def v_avg_volume_193 = v_aggregated_volume_193 / (if v_rth_barnum >= 193 then v_days else v_days_divisor);
def v_avg_volume_194 = v_aggregated_volume_194 / (if v_rth_barnum >= 194 then v_days else v_days_divisor);
def v_avg_volume_195 = v_aggregated_volume_195 / (if v_rth_barnum >= 195 then v_days else v_days_divisor);
def v_avg_volume_196 = v_aggregated_volume_196 / (if v_rth_barnum >= 196 then v_days else v_days_divisor);
def v_avg_volume_197 = v_aggregated_volume_197 / (if v_rth_barnum >= 197 then v_days else v_days_divisor);
def v_avg_volume_198 = v_aggregated_volume_198 / (if v_rth_barnum >= 198 then v_days else v_days_divisor);
def v_avg_volume_199 = v_aggregated_volume_199 / (if v_rth_barnum >= 199 then v_days else v_days_divisor);
def v_avg_volume_200 = v_aggregated_volume_200 / (if v_rth_barnum >= 200 then v_days else v_days_divisor);
def v_avg_volume_201 = v_aggregated_volume_201 / (if v_rth_barnum >= 201 then v_days else v_days_divisor);
def v_avg_volume_202 = v_aggregated_volume_202 / (if v_rth_barnum >= 202 then v_days else v_days_divisor);
def v_avg_volume_203 = v_aggregated_volume_203 / (if v_rth_barnum >= 203 then v_days else v_days_divisor);
 
I tried following changes.

Code:
def v_days_divisor = if v_days > 1 then (if gettime() crosses above RegularTradingStart(GetYYYYMMDD())  then v_days else v_days-1) else 1;

Still, it's not working. I am going to give up to fix it.
 
anytime timeframe under a day only calculates what's visible on your chart. so if you have extended off, it will not calculate the extended. You can aggregate day (aggregation.day) in the script and it will calculate the days total.
 
any intraday coded timeframe you use will only use what is visible on your chart. if you attempt to aggregate for the total in the day you will have to show extended hours or aggregate the ENTIRE script for use with aggegation.day where needed. TOS intraday volume data does not add up to the end of day official market recorded volume as noted on the single DAILY bar. In other words if you add up all the intraday volume bars, it will sometimes not add up to whats recorded on a single 1 day volume bar.
 
Last edited:
Any updates on this? I tried to use it in a scanner, TOS said it's too complex to execute. But it's a great idea to compare intraday volume.

There probably isn't a fix because the error is most likely due to the manipulation of AggregationPeriod() and the TOS scanners do not accept secondary aggregations...
 
@MerryDay Did anyone fix this indicator? I read all the feeds and watched the video and looks like an amazing too to be utilized? Do you know where I can get a revised version? If there is a revised version? I tried the previous code and TOS said the complexity of the code might not work with live trading? Is that normal?
 
ehhhhhm Really wish this was figured out. This Zanger code that I've seen throughout here doesn't even look remotely related to the ZVR. All the red and green are showing is if the cumulative volume is a bit more than average for the time (it seems) so its nothing but cumulative volume average.... The entire thesis behind the ZVR is knowing HOW big the relative size of the volume is vs the average and those figures can obviously get up to double, triple the size of average. Like Malone said, I fail to see how this
Using-Volume-to-Make-Better-Trades-Figure-3.png


was ported to this and deemed comparable to this....

c26c1e1502c0c0ce3b35f9e8bd693a02.png


Just don't want anybody thinking they're getting even remotely the same trading setup.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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