Relative Volume Indicator For ThinkorSwim

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

@markos @tomsk @BenTen Thanks for all of your input on this thread. I've checked out all of the scripts you've provided. I believe there has been a reference made to one or more of these displaying a relative volume number (or something similar to it) in a watchlist column. Is that correct? If so, how would this be added to a watchlist, and what code should be used?

Disregard. I just saw this
 
Here is how you would scan for stocks with volume GREATER THAN 10% above the 30 day simple moving average. I just ran the scan on a daily aggregation of the S&P500 and obtained 478 results

Code:
volume > 1.1 * average(volume,30)
 
This is a volume comparison it labels current and yesterdays total and avg volume I usually dont display vol but the labels work.

Code:
plot Data = close;# 09:30 Mobius: Good Morning - Don't have time to stay but wanted to post a volume study that plots a comparison of yesterdays total volume at the same bar and compares an average volume to the same time yesterday.
# Volume Comparison
# Plots Yesterdays Total Volume At Same Bar and Average Volume At Same Bar
# Mobius
# V02.06.2018 Posted to Chat Room 07.13.2018
declare on_volume;
input avgLength = 10;
def v = volume;
def vD = volume(period = AggregationPeriod.Day);
def c = close;
def x = BarNumber();
def nan = double.nan;
def RTHbar1 = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD())
then x
else RTHbar1[1];
def RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD()) and
GetTime() <= RegularTradingEnd(GetYYYYMMDD());
def PrevRTHbar1 = if RTHbar1 != RTHbar1[1]
then RTHbar1[1]
else PrevRTHbar1[1];
def indexBar = RTHbar1 - PrevRTHbar1;
plot prevVol = if IsNaN(c)
then nan
else GetValue(v, indexBar);
prevVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
prevVol.SetDefaultColor(CreateColor(75, 75, 75));
prevVol.SetLineWeight(1);
plot Vol = v;
Vol.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Vol.AssignValueColor(if close > open then CreateColor(5, 250, 12) else CreateColor(250, 5, 25));
AssignPriceColor(if close > open then CreateColor(5, 250, 12) else CreateColor(250, 5, 25));
def avgPrev = Average(prevVol, avgLength);
def avgCurr = Average(Vol, avgLength);
def prevDailyVol = if RTH and !RTH[1]
then getValue(v, indexBar)
else if RTH
then compoundValue(1, prevDailyVol[1] + GetValue(v, indexBar), GetValue(v, indexBar))
else prevDailyVol[1];
AddLabel(1, "Prev D Vol = " + prevDailyVol +
" Prev Vol avg(" + avgLength + ") = " + Round(avgPrev, 0), prevVol.TakeValueColor());
AddLabel(1, "Current D Vol = " + vD +
" Curr Vol avg(" + avgLength + ") = " + Round(avgCurr, 0), if vD > prevDailyVol
then color.green
else color.red);
# End Code Volume Comparison
 
@alphabeta Per your request I have added the alert you requested for into the above study, here we go ...

Code:
# Volume Comparison  
# Plots Yesterdays Total Volume At Same Bar and Average Volume At Same Bar
# Mobius
# V02.06.2018 Posted to Chat Room 07.13.2018
# tomsk added Alert when today's volume/avgVol > 300%, 1.17.2020

# Plots a comparison of yesterdays total volume at the same bar 
# and compares an average volume to the same time yesterday. 

declare on_volume;

input avgLength = 10;

def v = volume;
def vD = volume(period = AggregationPeriod.Day);
def c = close;
def x = BarNumber();
def nan = double.nan;
def RTHbar1 = if GetTime() crosses above RegularTradingStart(GetYYYYMMDD())
              then x
              else RTHbar1[1];
def RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD()) and
          GetTime() <= RegularTradingEnd(GetYYYYMMDD());
def PrevRTHbar1 = if RTHbar1 != RTHbar1[1]
                  then RTHbar1[1]
                  else PrevRTHbar1[1];
def indexBar = RTHbar1 - PrevRTHbar1;
plot prevVol = if IsNaN(c) 
               then nan
               else GetValue(v, indexBar);
prevVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
prevVol.SetDefaultColor(CreateColor(75, 75, 75));
prevVol.SetLineWeight(1);
plot Vol = v;
Vol.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Vol.AssignValueColor(if close > open then CreateColor(5, 250, 12) else CreateColor(250, 5, 25));
AssignPriceColor(if close > open then CreateColor(5, 250, 12) else CreateColor(250, 5, 25));
def avgPrev = Average(prevVol, avgLength);
def avgCurr = Average(Vol, avgLength);
def prevDailyVol = if RTH and !RTH[1]
                   then getValue(v, indexBar)
                   else if RTH
                        then compoundValue(1, prevDailyVol[1] + GetValue(v, indexBar), GetValue(v, indexBar))
                   else prevDailyVol[1];
AddLabel(1, "Prev D Vol = " + prevDailyVol +
          "  Prev Vol avg(" + avgLength + ") = " + Round(avgPrev, 0), prevVol.TakeValueColor());
AddLabel(1, "Current D Vol = " + vD +
          "  Curr Vol avg(" + avgLength + ") = " + Round(avgCurr, 0), if vD > prevDailyVol
                                                                      then color.green
                                                                      else color.red);
Alert(vD/avgCurr > 3, "Daily Volume > 300% AvgVol", Alert.BAR, Sound.Ring);
# End Code Volume Comparison
 
Code:
declare upper;;
def na = Double.NaN;

def AP = getAggregationPeriod();
rec barcounter = if GetDay() != GetDay()[1] then 1 else barcounter[1] + 1;

rec daycount = if barNumber() == 1 then 0 else if GetDay() > GetDay()[1] then 1 else 0;

def istoday = if GetLastDay() == GetDay() then 1 else 0;

def bar1volume = if istoday then 0 else if barcounter == 1 then volume else 0;
def bar2volume = if istoday then 0 else if barcounter == 2 then volume else 0;
def bar3volume = if istoday then 0 else if barcounter == 3 then volume else 0;
def bar4volume = if istoday then 0 else if barcounter == 4 then volume else 0;
def bar5volume = if istoday then 0 else if barcounter == 5 then volume else 0;
def bar6volume = if istoday then 0 else if barcounter == 6 then volume else 0;
def bar7volume = if istoday then 0 else if barcounter == 7 then volume else 0;
def bar8volume = if istoday then 0 else if barcounter == 8 then volume else 0;
def bar9volume = if istoday then 0 else if barcounter == 9 then volume else 0;
def bar10volume = if istoday then 0 else if barcounter == 10 then volume else 0;
def bar11volume = if istoday then 0 else if barcounter == 11 then volume else 0;
def bar12volume = if istoday then 0 else if barcounter == 12 then volume else 0;
def bar13volume = if istoday then 0 else if barcounter == 13 then volume else 0;
def bar14volume = if istoday then 0 else if barcounter == 14 then volume else 0;
def bar15volume = if istoday then 0 else if barcounter == 15 then volume else 0;
def bar16volume = if istoday then 0 else if barcounter == 16 then volume else 0;
def bar17volume = if istoday then 0 else if barcounter == 17 then volume else 0;
def bar18volume = if istoday then 0 else if barcounter == 18 then volume else 0;
def bar19volume = if istoday then 0 else if barcounter == 19 then volume else 0;
def bar20volume = if istoday then 0 else if barcounter == 20 then volume else 0;
def bar21volume = if istoday then 0 else if barcounter == 21 then volume else 0;
def bar22volume = if istoday then 0 else if barcounter == 22 then volume else 0;
def bar23volume = if istoday then 0 else if barcounter == 23 then volume else 0;
def bar24volume = if istoday then 0 else if barcounter == 24 then volume else 0;
def bar25volume = if istoday then 0 else if barcounter == 25 then volume else 0;
def bar26volume = if istoday then 0 else if barcounter == 26 then volume else 0;
def bar27volume = if istoday then 0 else if barcounter == 27 then volume else 0;
def bar28volume = if istoday then 0 else if barcounter == 28 then volume else 0;
def bar29volume = if istoday then 0 else if barcounter == 29 then volume else 0;
def bar30volume = if istoday then 0 else if barcounter == 30 then volume else 0;
def bar31volume = if istoday then 0 else if barcounter == 31 then volume else 0;
def bar32volume = if istoday then 0 else if barcounter == 32 then volume else 0;
def bar33volume = if istoday then 0 else if barcounter == 33 then volume else 0;
def bar34volume = if istoday then 0 else if barcounter == 34 then volume else 0;
def bar35volume = if istoday then 0 else if barcounter == 35 then volume else 0;
def bar36volume = if istoday then 0 else if barcounter == 36 then volume else 0;
def bar37volume = if istoday then 0 else if barcounter == 37 then volume else 0;
def bar38volume = if istoday then 0 else if barcounter == 38 then volume else 0;
def bar39volume = if istoday then 0 else if barcounter == 39 then volume else 0;
def bar40volume = if istoday then 0 else if barcounter == 40 then volume else 0;
def bar41volume = if istoday then 0 else if barcounter == 41 then volume else 0;
def bar42volume = if istoday then 0 else if barcounter == 42 then volume else 0;
def bar43volume = if istoday then 0 else if barcounter == 43 then volume else 0;
def bar44volume = if istoday then 0 else if barcounter == 44 then volume else 0;
def bar45volume = if istoday then 0 else if barcounter == 45 then volume else 0;
def bar46volume = if istoday then 0 else if barcounter == 46 then volume else 0;
def bar47volume = if istoday then 0 else if barcounter == 47 then volume else 0;
def bar48volume = if istoday then 0 else if barcounter == 48 then volume else 0;
def bar49volume = if istoday then 0 else if barcounter == 49 then volume else 0;
def bar50volume = if istoday then 0 else if barcounter == 50 then volume else 0;
def bar51volume = if istoday then 0 else if barcounter == 51 then volume else 0;
def bar52volume = if istoday then 0 else if barcounter == 52 then volume else 0;
def bar53volume = if istoday then 0 else if barcounter == 53 then volume else 0;
def bar54volume = if istoday then 0 else if barcounter == 54 then volume else 0;
def bar55volume = if istoday then 0 else if barcounter == 55 then volume else 0;
def bar56volume = if istoday then 0 else if barcounter == 56 then volume else 0;
def bar57volume = if istoday then 0 else if barcounter == 57 then volume else 0;
def bar58volume = if istoday then 0 else if barcounter == 58 then volume else 0;
def bar59volume = if istoday then 0 else if barcounter == 59 then volume else 0;
def bar60volume = if istoday then 0 else if barcounter == 60 then volume else 0;
def bar61volume = if istoday then 0 else if barcounter == 61 then volume else 0;
def bar62volume = if istoday then 0 else if barcounter == 62 then volume else 0;
def bar63volume = if istoday then 0 else if barcounter == 63 then volume else 0;
def bar64volume = if istoday then 0 else if barcounter == 64 then volume else 0;
def bar65volume = if istoday then 0 else if barcounter == 65 then volume else 0;
def bar66volume = if istoday then 0 else if barcounter == 66 then volume else 0;
def bar67volume = if istoday then 0 else if barcounter == 67 then volume else 0;
def bar68volume = if istoday then 0 else if barcounter == 68 then volume else 0;
def bar69volume = if istoday then 0 else if barcounter == 69 then volume else 0;
def bar70volume = if istoday then 0 else if barcounter == 70 then volume else 0;
def bar71volume = if istoday then 0 else if barcounter == 71 then volume else 0;
def bar72volume = if istoday then 0 else if barcounter == 72 then volume else 0;
def bar73volume = if istoday then 0 else if barcounter == 73 then volume else 0;
def bar74volume = if istoday then 0 else if barcounter == 74 then volume else 0;
def bar75volume = if istoday then 0 else if barcounter == 75 then volume else 0;
def bar76volume = if istoday then 0 else if barcounter == 76 then volume else 0;
def bar77volume = if istoday then 0 else if barcounter == 77 then volume else 0;
def bar78volume = if istoday then 0 else if barcounter == 78 then volume else 0;
def bar79volume = if istoday then 0 else if barcounter == 79 then volume else 0;
def bar80volume = if istoday then 0 else if barcounter == 80 then volume else 0;
def bar81volume = if istoday then 0 else if barcounter == 81 then volume else 0;
def bar82volume = if istoday then 0 else if barcounter == 82 then volume else 0;
def bar83volume = if istoday then 0 else if barcounter == 83 then volume else 0;
def bar84volume = if istoday then 0 else if barcounter == 84 then volume else 0;
def bar85volume = if istoday then 0 else if barcounter == 85 then volume else 0;
def bar86volume = if istoday then 0 else if barcounter == 86 then volume else 0;
def bar87volume = if istoday then 0 else if barcounter == 87 then volume else 0;
def bar88volume = if istoday then 0 else if barcounter == 88 then volume else 0;
def bar89volume = if istoday then 0 else if barcounter == 89 then volume else 0;
def bar90volume = if istoday then 0 else if barcounter == 90 then volume else 0;
def bar91volume = if istoday then 0 else if barcounter == 91 then volume else 0;
def bar92volume = if istoday then 0 else if barcounter == 92 then volume else 0;
def bar93volume = if istoday then 0 else if barcounter == 93 then volume else 0;
def bar94volume = if istoday then 0 else if barcounter == 94 then volume else 0;
def bar95volume = if istoday then 0 else if barcounter == 95 then volume else 0;
def bar96volume = if istoday then 0 else if barcounter == 96 then volume else 0;
def bar97volume = if istoday then 0 else if barcounter == 97 then volume else 0;
def bar98volume = if istoday then 0 else if barcounter == 98 then volume else 0;
def bar99volume = if istoday then 0 else if barcounter == 99 then volume else 0;
def bar100volume = if istoday then 0 else if barcounter == 100 then volume else 0;
def bar101volume = if istoday then 0 else if barcounter == 101 then volume else 0;
def bar102volume = if istoday then 0 else if barcounter == 102 then volume else 0;
def bar103volume = if istoday then 0 else if barcounter == 103 then volume else 0;
def bar104volume = if istoday then 0 else if barcounter == 104 then volume else 0;
def bar105volume = if istoday then 0 else if barcounter == 105 then volume else 0;
def bar106volume = if istoday then 0 else if barcounter == 106 then volume else 0;
def bar107volume = if istoday then 0 else if barcounter == 107 then volume else 0;
def bar108volume = if istoday then 0 else if barcounter == 108 then volume else 0;
def bar109volume = if istoday then 0 else if barcounter == 109 then volume else 0;
def bar110volume = if istoday then 0 else if barcounter == 110 then volume else 0;
def bar111volume = if istoday then 0 else if barcounter == 111 then volume else 0;
def bar112volume = if istoday then 0 else if barcounter == 112 then volume else 0;
def bar113volume = if istoday then 0 else if barcounter == 113 then volume else 0;
def bar114volume = if istoday then 0 else if barcounter == 114 then volume else 0;
def bar115volume = if istoday then 0 else if barcounter == 115 then volume else 0;
def bar116volume = if istoday then 0 else if barcounter == 116 then volume else 0;
def bar117volume = if istoday then 0 else if barcounter == 117 then volume else 0;
def bar118volume = if istoday then 0 else if barcounter == 118 then volume else 0;
def bar119volume = if istoday then 0 else if barcounter == 119 then volume else 0;
def bar120volume = if istoday then 0 else if barcounter == 120 then volume else 0;
def bar121volume = if istoday then 0 else if barcounter == 121 then volume else 0;
def bar122volume = if istoday then 0 else if barcounter == 122 then volume else 0;
def bar123volume = if istoday then 0 else if barcounter == 123 then volume else 0;
def bar124volume = if istoday then 0 else if barcounter == 124 then volume else 0;
def bar125volume = if istoday then 0 else if barcounter == 125 then volume else 0;
def bar126volume = if istoday then 0 else if barcounter == 126 then volume else 0;
def bar127volume = if istoday then 0 else if barcounter == 127 then volume else 0;
def bar128volume = if istoday then 0 else if barcounter == 128 then volume else 0;
def bar129volume = if istoday then 0 else if barcounter == 129 then volume else 0;
def bar130volume = if istoday then 0 else if barcounter == 130 then volume else 0;
def bar131volume = if istoday then 0 else if barcounter == 131 then volume else 0;
def bar132volume = if istoday then 0 else if barcounter == 132 then volume else 0;
def bar133volume = if istoday then 0 else if barcounter == 133 then volume else 0;
def bar134volume = if istoday then 0 else if barcounter == 134 then volume else 0;
def bar135volume = if istoday then 0 else if barcounter == 135 then volume else 0;
def bar136volume = if istoday then 0 else if barcounter == 136 then volume else 0;
def bar137volume = if istoday then 0 else if barcounter == 137 then volume else 0;
def bar138volume = if istoday then 0 else if barcounter == 138 then volume else 0;
def bar139volume = if istoday then 0 else if barcounter == 139 then volume else 0;
def bar140volume = if istoday then 0 else if barcounter == 140 then volume else 0;
def bar141volume = if istoday then 0 else if barcounter == 141 then volume else 0;
def bar142volume = if istoday then 0 else if barcounter == 142 then volume else 0;
def bar143volume = if istoday then 0 else if barcounter == 143 then volume else 0;
def bar144volume = if istoday then 0 else if barcounter == 144 then volume else 0;
def bar145volume = if istoday then 0 else if barcounter == 145 then volume else 0;
def bar146volume = if istoday then 0 else if barcounter == 146 then volume else 0;
def bar147volume = if istoday then 0 else if barcounter == 147 then volume else 0;
def bar148volume = if istoday then 0 else if barcounter == 148 then volume else 0;
def bar149volume = if istoday then 0 else if barcounter == 149 then volume else 0;
def bar150volume = if istoday then 0 else if barcounter == 150 then volume else 0;
def bar151volume = if istoday then 0 else if barcounter == 151 then volume else 0;
def bar152volume = if istoday then 0 else if barcounter == 152 then volume else 0;
def bar153volume = if istoday then 0 else if barcounter == 153 then volume else 0;
def bar154volume = if istoday then 0 else if barcounter == 154 then volume else 0;
def bar155volume = if istoday then 0 else if barcounter == 155 then volume else 0;
def bar156volume = if istoday then 0 else if barcounter == 156 then volume else 0;
def bar157volume = if istoday then 0 else if barcounter == 157 then volume else 0;
def bar158volume = if istoday then 0 else if barcounter == 158 then volume else 0;
def bar159volume = if istoday then 0 else if barcounter == 159 then volume else 0;
def bar160volume = if istoday then 0 else if barcounter == 160 then volume else 0;
def bar161volume = if istoday then 0 else if barcounter == 161 then volume else 0;
def bar162volume = if istoday then 0 else if barcounter == 162 then volume else 0;
def bar163volume = if istoday then 0 else if barcounter == 163 then volume else 0;
def bar164volume = if istoday then 0 else if barcounter == 164 then volume else 0;
def bar165volume = if istoday then 0 else if barcounter == 165 then volume else 0;
def bar166volume = if istoday then 0 else if barcounter == 166 then volume else 0;
def bar167volume = if istoday then 0 else if barcounter == 167 then volume else 0;
def bar168volume = if istoday then 0 else if barcounter == 168 then volume else 0;
def bar169volume = if istoday then 0 else if barcounter == 169 then volume else 0;
def bar170volume = if istoday then 0 else if barcounter == 170 then volume else 0;
def bar171volume = if istoday then 0 else if barcounter == 171 then volume else 0;
def bar172volume = if istoday then 0 else if barcounter == 172 then volume else 0;
def bar173volume = if istoday then 0 else if barcounter == 173 then volume else 0;
def bar174volume = if istoday then 0 else if barcounter == 174 then volume else 0;
def bar175volume = if istoday then 0 else if barcounter == 175 then volume else 0;
def bar176volume = if istoday then 0 else if barcounter == 176 then volume else 0;
def bar177volume = if istoday then 0 else if barcounter == 177 then volume else 0;
def bar178volume = if istoday then 0 else if barcounter == 178 then volume else 0;
def bar179volume = if istoday then 0 else if barcounter == 179 then volume else 0;
def bar180volume = if istoday then 0 else if barcounter == 180 then volume else 0;
def bar181volume = if istoday then 0 else if barcounter == 181 then volume else 0;
def bar182volume = if istoday then 0 else if barcounter == 182 then volume else 0;
def bar183volume = if istoday then 0 else if barcounter == 183 then volume else 0;
def bar184volume = if istoday then 0 else if barcounter == 184 then volume else 0;
def bar185volume = if istoday then 0 else if barcounter == 185 then volume else 0;
def bar186volume = if istoday then 0 else if barcounter == 186 then volume else 0;
def bar187volume = if istoday then 0 else if barcounter == 187 then volume else 0;
def bar188volume = if istoday then 0 else if barcounter == 188 then volume else 0;
def bar189volume = if istoday then 0 else if barcounter == 189 then volume else 0;
def bar190volume = if istoday then 0 else if barcounter == 190 then volume else 0;
def bar191volume = if istoday then 0 else if barcounter == 191 then volume else 0;
def bar192volume = if istoday then 0 else if barcounter == 192 then volume else 0;
def bar193volume = if istoday then 0 else if barcounter == 193 then volume else 0;
def bar194volume = if istoday then 0 else if barcounter == 194 then volume else 0;
def bar195volume = if istoday then 0 else if barcounter == 195 then volume else 0;
def bar196volume = if istoday then 0 else if barcounter == 196 then volume else 0;
def bar197volume = if istoday then 0 else if barcounter == 197 then volume else 0;
def bar198volume = if istoday then 0 else if barcounter == 198 then volume else 0;
def bar199volume = if istoday then 0 else if barcounter == 199 then volume else 0;
def bar200volume = if istoday then 0 else if barcounter == 200 then volume else 0;
def bar201volume = if istoday then 0 else if barcounter == 201 then volume else 0;
def bar202volume = if istoday then 0 else if barcounter == 202 then volume else 0;
def bar203volume = if istoday then 0 else if barcounter == 203 then volume else 0;
def bar204volume = if istoday then 0 else if barcounter == 204 then volume else 0;
def bar205volume = if istoday then 0 else if barcounter == 205 then volume else 0;
def bar206volume = if istoday then 0 else if barcounter == 206 then volume else 0;
def bar207volume = if istoday then 0 else if barcounter == 207 then volume else 0;
def bar208volume = if istoday then 0 else if barcounter == 208 then volume else 0;
def bar209volume = if istoday then 0 else if barcounter == 209 then volume else 0;
def bar210volume = if istoday then 0 else if barcounter == 210 then volume else 0;
def bar211volume = if istoday then 0 else if barcounter == 211 then volume else 0;
def bar212volume = if istoday then 0 else if barcounter == 212 then volume else 0;
def bar213volume = if istoday then 0 else if barcounter == 213 then volume else 0;
def bar214volume = if istoday then 0 else if barcounter == 214 then volume else 0;
def bar215volume = if istoday then 0 else if barcounter == 215 then volume else 0;
def bar216volume = if istoday then 0 else if barcounter == 216 then volume else 0;
def bar217volume = if istoday then 0 else if barcounter == 217 then volume else 0;
def bar218volume = if istoday then 0 else if barcounter == 218 then volume else 0;
def bar219volume = if istoday then 0 else if barcounter == 219 then volume else 0;
def bar220volume = if istoday then 0 else if barcounter == 220 then volume else 0;
def bar221volume = if istoday then 0 else if barcounter == 221 then volume else 0;
def bar222volume = if istoday then 0 else if barcounter == 222 then volume else 0;
def bar223volume = if istoday then 0 else if barcounter == 223 then volume else 0;
def bar224volume = if istoday then 0 else if barcounter == 224 then volume else 0;
def bar225volume = if istoday then 0 else if barcounter == 225 then volume else 0;
def bar226volume = if istoday then 0 else if barcounter == 226 then volume else 0;
def bar227volume = if istoday then 0 else if barcounter == 227 then volume else 0;
def bar228volume = if istoday then 0 else if barcounter == 228 then volume else 0;
def bar229volume = if istoday then 0 else if barcounter == 229 then volume else 0;
def bar230volume = if istoday then 0 else if barcounter == 230 then volume else 0;
def bar231volume = if istoday then 0 else if barcounter == 231 then volume else 0;
def bar232volume = if istoday then 0 else if barcounter == 232 then volume else 0;
def bar233volume = if istoday then 0 else if barcounter == 233 then volume else 0;
def bar234volume = if istoday then 0 else if barcounter == 234 then volume else 0;
def bar235volume = if istoday then 0 else if barcounter == 235 then volume else 0;
def bar236volume = if istoday then 0 else if barcounter == 236 then volume else 0;
def bar237volume = if istoday then 0 else if barcounter == 237 then volume else 0;
def bar238volume = if istoday then 0 else if barcounter == 238 then volume else 0;
def bar239volume = if istoday then 0 else if barcounter == 239 then volume else 0;
def bar240volume = if istoday then 0 else if barcounter == 240 then volume else 0;
def bar241volume = if istoday then 0 else if barcounter == 241 then volume else 0;
def bar242volume = if istoday then 0 else if barcounter == 242 then volume else 0;
def bar243volume = if istoday then 0 else if barcounter == 243 then volume else 0;
def bar244volume = if istoday then 0 else if barcounter == 244 then volume else 0;
def bar245volume = if istoday then 0 else if barcounter == 245 then volume else 0;
def bar246volume = if istoday then 0 else if barcounter == 246 then volume else 0;
def bar247volume = if istoday then 0 else if barcounter == 247 then volume else 0;
def bar248volume = if istoday then 0 else if barcounter == 248 then volume else 0;
def bar249volume = if istoday then 0 else if barcounter == 249 then volume else 0;
def bar250volume = if istoday then 0 else if barcounter == 250 then volume else 0;
def bar251volume = if istoday then 0 else if barcounter == 251 then volume else 0;
def bar252volume = if istoday then 0 else if barcounter == 252 then volume else 0;
def bar253volume = if istoday then 0 else if barcounter == 253 then volume else 0;
def bar254volume = if istoday then 0 else if barcounter == 254 then volume else 0;
def bar255volume = if istoday then 0 else if barcounter == 255 then volume else 0;
def bar256volume = if istoday then 0 else if barcounter == 256 then volume else 0;
def bar257volume = if istoday then 0 else if barcounter == 257 then volume else 0;
def bar258volume = if istoday then 0 else if barcounter == 258 then volume else 0;
def bar259volume = if istoday then 0 else if barcounter == 259 then volume else 0;
def bar260volume = if istoday then 0 else if barcounter == 260 then volume else 0;
def bar261volume = if istoday then 0 else if barcounter == 261 then volume else 0;
def bar262volume = if istoday then 0 else if barcounter == 262 then volume else 0;
def bar263volume = if istoday then 0 else if barcounter == 263 then volume else 0;
def bar264volume = if istoday then 0 else if barcounter == 264 then volume else 0;
def bar265volume = if istoday then 0 else if barcounter == 265 then volume else 0;
def bar266volume = if istoday then 0 else if barcounter == 266 then volume else 0;
def bar267volume = if istoday then 0 else if barcounter == 267 then volume else 0;
def bar268volume = if istoday then 0 else if barcounter == 268 then volume else 0;
def bar269volume = if istoday then 0 else if barcounter == 269 then volume else 0;
def bar270volume = if istoday then 0 else if barcounter == 270 then volume else 0;
def bar271volume = if istoday then 0 else if barcounter == 271 then volume else 0;
def bar272volume = if istoday then 0 else if barcounter == 272 then volume else 0;
def bar273volume = if istoday then 0 else if barcounter == 273 then volume else 0;
def bar274volume = if istoday then 0 else if barcounter == 274 then volume else 0;
def bar275volume = if istoday then 0 else if barcounter == 275 then volume else 0;
def bar276volume = if istoday then 0 else if barcounter == 276 then volume else 0;
def bar277volume = if istoday then 0 else if barcounter == 277 then volume else 0;
def bar278volume = if istoday then 0 else if barcounter == 278 then volume else 0;
def bar279volume = if istoday then 0 else if barcounter == 279 then volume else 0;
def bar280volume = if istoday then 0 else if barcounter == 280 then volume else 0;
def bar281volume = if istoday then 0 else if barcounter == 281 then volume else 0;
def bar282volume = if istoday then 0 else if barcounter == 282 then volume else 0;
def bar283volume = if istoday then 0 else if barcounter == 283 then volume else 0;
def bar284volume = if istoday then 0 else if barcounter == 284 then volume else 0;
def bar285volume = if istoday then 0 else if barcounter == 285 then volume else 0;
def bar286volume = if istoday then 0 else if barcounter == 286 then volume else 0;
def bar287volume = if istoday then 0 else if barcounter == 287 then volume else 0;
def bar288volume = if istoday then 0 else if barcounter == 288 then volume else 0;
def bar289volume = if istoday then 0 else if barcounter == 289 then volume else 0;
def bar290volume = if istoday then 0 else if barcounter == 290 then volume else 0;
def bar291volume = if istoday then 0 else if barcounter == 291 then volume else 0;
def bar292volume = if istoday then 0 else if barcounter == 292 then volume else 0;
def bar293volume = if istoday then 0 else if barcounter == 293 then volume else 0;
def bar294volume = if istoday then 0 else if barcounter == 294 then volume else 0;
def bar295volume = if istoday then 0 else if barcounter == 295 then volume else 0;
def bar296volume = if istoday then 0 else if barcounter == 296 then volume else 0;
def bar297volume = if istoday then 0 else if barcounter == 297 then volume else 0;
def bar298volume = if istoday then 0 else if barcounter == 298 then volume else 0;
def bar299volume = if istoday then 0 else if barcounter == 299 then volume else 0;
def bar300volume = if istoday then 0 else if barcounter == 300 then volume else 0;
def bar301volume = if istoday then 0 else if barcounter == 301 then volume else 0;
def bar302volume = if istoday then 0 else if barcounter == 302 then volume else 0;
def bar303volume = if istoday then 0 else if barcounter == 303 then volume else 0;
def bar304volume = if istoday then 0 else if barcounter == 304 then volume else 0;
def bar305volume = if istoday then 0 else if barcounter == 305 then volume else 0;
def bar306volume = if istoday then 0 else if barcounter == 306 then volume else 0;
def bar307volume = if istoday then 0 else if barcounter == 307 then volume else 0;
def bar308volume = if istoday then 0 else if barcounter == 308 then volume else 0;
def bar309volume = if istoday then 0 else if barcounter == 309 then volume else 0;
def bar310volume = if istoday then 0 else if barcounter == 310 then volume else 0;
def bar311volume = if istoday then 0 else if barcounter == 311 then volume else 0;
def bar312volume = if istoday then 0 else if barcounter == 312 then volume else 0;
def bar313volume = if istoday then 0 else if barcounter == 313 then volume else 0;
def bar314volume = if istoday then 0 else if barcounter == 314 then volume else 0;
def bar315volume = if istoday then 0 else if barcounter == 315 then volume else 0;
def bar316volume = if istoday then 0 else if barcounter == 316 then volume else 0;
def bar317volume = if istoday then 0 else if barcounter == 317 then volume else 0;
def bar318volume = if istoday then 0 else if barcounter == 318 then volume else 0;
def bar319volume = if istoday then 0 else if barcounter == 319 then volume else 0;
def bar320volume = if istoday then 0 else if barcounter == 320 then volume else 0;
def bar321volume = if istoday then 0 else if barcounter == 321 then volume else 0;
def bar322volume = if istoday then 0 else if barcounter == 322 then volume else 0;
def bar323volume = if istoday then 0 else if barcounter == 323 then volume else 0;
def bar324volume = if istoday then 0 else if barcounter == 324 then volume else 0;
def bar325volume = if istoday then 0 else if barcounter == 325 then volume else 0;
def bar326volume = if istoday then 0 else if barcounter == 326 then volume else 0;
def bar327volume = if istoday then 0 else if barcounter == 327 then volume else 0;
def bar328volume = if istoday then 0 else if barcounter == 328 then volume else 0;
def bar329volume = if istoday then 0 else if barcounter == 329 then volume else 0;
def bar330volume = if istoday then 0 else if barcounter == 330 then volume else 0;
def bar331volume = if istoday then 0 else if barcounter == 331 then volume else 0;
def bar332volume = if istoday then 0 else if barcounter == 332 then volume else 0;
def bar333volume = if istoday then 0 else if barcounter == 333 then volume else 0;
def bar334volume = if istoday then 0 else if barcounter == 334 then volume else 0;
def bar335volume = if istoday then 0 else if barcounter == 335 then volume else 0;
def bar336volume = if istoday then 0 else if barcounter == 336 then volume else 0;
def bar337volume = if istoday then 0 else if barcounter == 337 then volume else 0;
def bar338volume = if istoday then 0 else if barcounter == 338 then volume else 0;
def bar339volume = if istoday then 0 else if barcounter == 339 then volume else 0;
def bar340volume = if istoday then 0 else if barcounter == 340 then volume else 0;
def bar341volume = if istoday then 0 else if barcounter == 341 then volume else 0;
def bar342volume = if istoday then 0 else if barcounter == 342 then volume else 0;
def bar343volume = if istoday then 0 else if barcounter == 343 then volume else 0;
def bar344volume = if istoday then 0 else if barcounter == 344 then volume else 0;
def bar345volume = if istoday then 0 else if barcounter == 345 then volume else 0;
def bar346volume = if istoday then 0 else if barcounter == 346 then volume else 0;
def bar347volume = if istoday then 0 else if barcounter == 347 then volume else 0;
def bar348volume = if istoday then 0 else if barcounter == 348 then volume else 0;
def bar349volume = if istoday then 0 else if barcounter == 349 then volume else 0;
def bar350volume = if istoday then 0 else if barcounter == 350 then volume else 0;
def bar351volume = if istoday then 0 else if barcounter == 351 then volume else 0;
def bar352volume = if istoday then 0 else if barcounter == 352 then volume else 0;
def bar353volume = if istoday then 0 else if barcounter == 353 then volume else 0;
def bar354volume = if istoday then 0 else if barcounter == 354 then volume else 0;
def bar355volume = if istoday then 0 else if barcounter == 355 then volume else 0;
def bar356volume = if istoday then 0 else if barcounter == 356 then volume else 0;
def bar357volume = if istoday then 0 else if barcounter == 357 then volume else 0;
def bar358volume = if istoday then 0 else if barcounter == 358 then volume else 0;
def bar359volume = if istoday then 0 else if barcounter == 359 then volume else 0;
def bar360volume = if istoday then 0 else if barcounter == 360 then volume else 0;
def bar361volume = if istoday then 0 else if barcounter == 361 then volume else 0;
def bar362volume = if istoday then 0 else if barcounter == 362 then volume else 0;
def bar363volume = if istoday then 0 else if barcounter == 363 then volume else 0;
def bar364volume = if istoday then 0 else if barcounter == 364 then volume else 0;
def bar365volume = if istoday then 0 else if barcounter == 365 then volume else 0;
def bar366volume = if istoday then 0 else if barcounter == 366 then volume else 0;
def bar367volume = if istoday then 0 else if barcounter == 367 then volume else 0;
def bar368volume = if istoday then 0 else if barcounter == 368 then volume else 0;
def bar369volume = if istoday then 0 else if barcounter == 369 then volume else 0;
def bar370volume = if istoday then 0 else if barcounter == 370 then volume else 0;
def bar371volume = if istoday then 0 else if barcounter == 371 then volume else 0;
def bar372volume = if istoday then 0 else if barcounter == 372 then volume else 0;
def bar373volume = if istoday then 0 else if barcounter == 373 then volume else 0;
def bar374volume = if istoday then 0 else if barcounter == 374 then volume else 0;
def bar375volume = if istoday then 0 else if barcounter == 375 then volume else 0;
def bar376volume = if istoday then 0 else if barcounter == 376 then volume else 0;
def bar377volume = if istoday then 0 else if barcounter == 377 then volume else 0;
def bar378volume = if istoday then 0 else if barcounter == 378 then volume else 0;
def bar379volume = if istoday then 0 else if barcounter == 379 then volume else 0;
def bar380volume = if istoday then 0 else if barcounter == 380 then volume else 0;
def bar381volume = if istoday then 0 else if barcounter == 381 then volume else 0;
def bar382volume = if istoday then 0 else if barcounter == 382 then volume else 0;
def bar383volume = if istoday then 0 else if barcounter == 383 then volume else 0;
def bar384volume = if istoday then 0 else if barcounter == 384 then volume else 0;
def bar385volume = if istoday then 0 else if barcounter == 385 then volume else 0;
def bar386volume = if istoday then 0 else if barcounter == 386 then volume else 0;
def bar387volume = if istoday then 0 else if barcounter == 387 then volume else 0;
def bar388volume = if istoday then 0 else if barcounter == 388 then volume else 0;
def bar389volume = if istoday then 0 else if barcounter == 389 then volume else 0;
def bar390volume = if istoday then 0 else if barcounter == 390 then volume else 0;

def avgbar1 = TotalSum(bar1volume) / TotalSum(daycount);
def avgbar2 = TotalSum(bar2volume) / TotalSum(daycount);
def avgbar3 = TotalSum(bar3volume) / TotalSum(daycount);
def avgbar4 = TotalSum(bar4volume) / TotalSum(daycount);
def avgbar5 = TotalSum(bar5volume) / TotalSum(daycount);
def avgbar6 = TotalSum(bar6volume) / TotalSum(daycount);
def avgbar7 = TotalSum(bar7volume) / TotalSum(daycount);
def avgbar8 = TotalSum(bar8volume) / TotalSum(daycount);
def avgbar9 = TotalSum(bar9volume) / TotalSum(daycount);
def avgbar10 = TotalSum(bar10volume) / TotalSum(daycount);
def avgbar11 = TotalSum(bar11volume) / TotalSum(daycount);
def avgbar12 = TotalSum(bar12volume) / TotalSum(daycount);
def avgbar13 = TotalSum(bar13volume) / TotalSum(daycount);
def avgbar14 = TotalSum(bar14volume) / TotalSum(daycount);
def avgbar15 = TotalSum(bar15volume) / TotalSum(daycount);
def avgbar16 = TotalSum(bar16volume) / TotalSum(daycount);
def avgbar17 = TotalSum(bar17volume) / TotalSum(daycount);
def avgbar18 = TotalSum(bar18volume) / TotalSum(daycount);
def avgbar19 = TotalSum(bar19volume) / TotalSum(daycount);
def avgbar20 = TotalSum(bar20volume) / TotalSum(daycount);
def avgbar21 = TotalSum(bar21volume) / TotalSum(daycount);
def avgbar22 = TotalSum(bar22volume) / TotalSum(daycount);
def avgbar23 = TotalSum(bar23volume) / TotalSum(daycount);
def avgbar24 = TotalSum(bar24volume) / TotalSum(daycount);
def avgbar25 = TotalSum(bar25volume) / TotalSum(daycount);
def avgbar26 = TotalSum(bar26volume) / TotalSum(daycount);
def avgbar27 = TotalSum(bar27volume) / TotalSum(daycount);
def avgbar28 = TotalSum(bar28volume) / TotalSum(daycount);
def avgbar29 = TotalSum(bar29volume) / TotalSum(daycount);
def avgbar30 = TotalSum(bar30volume) / TotalSum(daycount);
def avgbar31 = TotalSum(bar31volume) / TotalSum(daycount);
def avgbar32 = TotalSum(bar32volume) / TotalSum(daycount);
def avgbar33 = TotalSum(bar33volume) / TotalSum(daycount);
def avgbar34 = TotalSum(bar34volume) / TotalSum(daycount);
def avgbar35 = TotalSum(bar35volume) / TotalSum(daycount);
def avgbar36 = TotalSum(bar36volume) / TotalSum(daycount);
def avgbar37 = TotalSum(bar37volume) / TotalSum(daycount);
def avgbar38 = TotalSum(bar38volume) / TotalSum(daycount);
def avgbar39 = TotalSum(bar39volume) / TotalSum(daycount);
def avgbar40 = TotalSum(bar40volume) / TotalSum(daycount);
def avgbar41 = TotalSum(bar41volume) / TotalSum(daycount);
def avgbar42 = TotalSum(bar42volume) / TotalSum(daycount);
def avgbar43 = TotalSum(bar43volume) / TotalSum(daycount);
def avgbar44 = TotalSum(bar44volume) / TotalSum(daycount);
def avgbar45 = TotalSum(bar45volume) / TotalSum(daycount);
def avgbar46 = TotalSum(bar46volume) / TotalSum(daycount);
def avgbar47 = TotalSum(bar47volume) / TotalSum(daycount);
def avgbar48 = TotalSum(bar48volume) / TotalSum(daycount);
def avgbar49 = TotalSum(bar49volume) / TotalSum(daycount);
def avgbar50 = TotalSum(bar50volume) / TotalSum(daycount);
def avgbar51 = TotalSum(bar51volume) / TotalSum(daycount);
def avgbar52 = TotalSum(bar52volume) / TotalSum(daycount);
def avgbar53 = TotalSum(bar53volume) / TotalSum(daycount);
def avgbar54 = TotalSum(bar54volume) / TotalSum(daycount);
def avgbar55 = TotalSum(bar55volume) / TotalSum(daycount);
def avgbar56 = TotalSum(bar56volume) / TotalSum(daycount);
def avgbar57 = TotalSum(bar57volume) / TotalSum(daycount);
def avgbar58 = TotalSum(bar58volume) / TotalSum(daycount);
def avgbar59 = TotalSum(bar59volume) / TotalSum(daycount);
def avgbar60 = TotalSum(bar60volume) / TotalSum(daycount);
def avgbar61 = TotalSum(bar61volume) / TotalSum(daycount);
def avgbar62 = TotalSum(bar62volume) / TotalSum(daycount);
def avgbar63 = TotalSum(bar63volume) / TotalSum(daycount);
def avgbar64 = TotalSum(bar64volume) / TotalSum(daycount);
def avgbar65 = TotalSum(bar65volume) / TotalSum(daycount);
def avgbar66 = TotalSum(bar66volume) / TotalSum(daycount);
def avgbar67 = TotalSum(bar67volume) / TotalSum(daycount);
def avgbar68 = TotalSum(bar68volume) / TotalSum(daycount);
def avgbar69 = TotalSum(bar69volume) / TotalSum(daycount);
def avgbar70 = TotalSum(bar70volume) / TotalSum(daycount);
def avgbar71 = TotalSum(bar71volume) / TotalSum(daycount);
def avgbar72 = TotalSum(bar72volume) / TotalSum(daycount);
def avgbar73 = TotalSum(bar73volume) / TotalSum(daycount);
def avgbar74 = TotalSum(bar74volume) / TotalSum(daycount);
def avgbar75 = TotalSum(bar75volume) / TotalSum(daycount);
def avgbar76 = TotalSum(bar76volume) / TotalSum(daycount);
def avgbar77 = TotalSum(bar77volume) / TotalSum(daycount);
def avgbar78 = TotalSum(bar78volume) / TotalSum(daycount);
def avgbar79 = TotalSum(bar79volume) / TotalSum(daycount);
def avgbar80 = TotalSum(bar80volume) / TotalSum(daycount);
def avgbar81 = TotalSum(bar81volume) / TotalSum(daycount);
def avgbar82 = TotalSum(bar82volume) / TotalSum(daycount);
def avgbar83 = TotalSum(bar83volume) / TotalSum(daycount);
def avgbar84 = TotalSum(bar84volume) / TotalSum(daycount);
def avgbar85 = TotalSum(bar85volume) / TotalSum(daycount);
def avgbar86 = TotalSum(bar86volume) / TotalSum(daycount);
def avgbar87 = TotalSum(bar87volume) / TotalSum(daycount);
def avgbar88 = TotalSum(bar88volume) / TotalSum(daycount);
def avgbar89 = TotalSum(bar89volume) / TotalSum(daycount);
def avgbar90 = TotalSum(bar90volume) / TotalSum(daycount);
def avgbar91 = TotalSum(bar91volume) / TotalSum(daycount);
def avgbar92 = TotalSum(bar92volume) / TotalSum(daycount);
def avgbar93 = TotalSum(bar93volume) / TotalSum(daycount);
def avgbar94 = TotalSum(bar94volume) / TotalSum(daycount);
def avgbar95 = TotalSum(bar95volume) / TotalSum(daycount);
def avgbar96 = TotalSum(bar96volume) / TotalSum(daycount);
def avgbar97 = TotalSum(bar97volume) / TotalSum(daycount);
def avgbar98 = TotalSum(bar98volume) / TotalSum(daycount);
def avgbar99 = TotalSum(bar99volume) / TotalSum(daycount);
def avgbar100 = TotalSum(bar100volume) / TotalSum(daycount);
def avgbar101 = TotalSum(bar101volume) / TotalSum(daycount);
def avgbar102 = TotalSum(bar102volume) / TotalSum(daycount);
def avgbar103 = TotalSum(bar103volume) / TotalSum(daycount);
def avgbar104 = TotalSum(bar104volume) / TotalSum(daycount);
def avgbar105 = TotalSum(bar105volume) / TotalSum(daycount);
def avgbar106 = TotalSum(bar106volume) / TotalSum(daycount);
def avgbar107 = TotalSum(bar107volume) / TotalSum(daycount);
def avgbar108 = TotalSum(bar108volume) / TotalSum(daycount);
def avgbar109 = TotalSum(bar109volume) / TotalSum(daycount);
def avgbar110 = TotalSum(bar110volume) / TotalSum(daycount);
def avgbar111 = TotalSum(bar111volume) / TotalSum(daycount);
def avgbar112 = TotalSum(bar112volume) / TotalSum(daycount);
def avgbar113 = TotalSum(bar113volume) / TotalSum(daycount);
def avgbar114 = TotalSum(bar114volume) / TotalSum(daycount);
def avgbar115 = TotalSum(bar115volume) / TotalSum(daycount);
def avgbar116 = TotalSum(bar116volume) / TotalSum(daycount);
def avgbar117 = TotalSum(bar117volume) / TotalSum(daycount);
def avgbar118 = TotalSum(bar118volume) / TotalSum(daycount);
def avgbar119 = TotalSum(bar119volume) / TotalSum(daycount);
def avgbar120 = TotalSum(bar120volume) / TotalSum(daycount);
def avgbar121 = TotalSum(bar121volume) / TotalSum(daycount);
def avgbar122 = TotalSum(bar122volume) / TotalSum(daycount);
def avgbar123 = TotalSum(bar123volume) / TotalSum(daycount);
def avgbar124 = TotalSum(bar124volume) / TotalSum(daycount);
def avgbar125 = TotalSum(bar125volume) / TotalSum(daycount);
def avgbar126 = TotalSum(bar126volume) / TotalSum(daycount);
def avgbar127 = TotalSum(bar127volume) / TotalSum(daycount);
def avgbar128 = TotalSum(bar128volume) / TotalSum(daycount);
def avgbar129 = TotalSum(bar129volume) / TotalSum(daycount);
def avgbar130 = TotalSum(bar130volume) / TotalSum(daycount);
def avgbar131 = TotalSum(bar131volume) / TotalSum(daycount);
def avgbar132 = TotalSum(bar132volume) / TotalSum(daycount);
def avgbar133 = TotalSum(bar133volume) / TotalSum(daycount);
def avgbar134 = TotalSum(bar134volume) / TotalSum(daycount);
def avgbar135 = TotalSum(bar135volume) / TotalSum(daycount);
def avgbar136 = TotalSum(bar136volume) / TotalSum(daycount);
def avgbar137 = TotalSum(bar137volume) / TotalSum(daycount);
def avgbar138 = TotalSum(bar138volume) / TotalSum(daycount);
def avgbar139 = TotalSum(bar139volume) / TotalSum(daycount);
def avgbar140 = TotalSum(bar140volume) / TotalSum(daycount);
def avgbar141 = TotalSum(bar141volume) / TotalSum(daycount);
def avgbar142 = TotalSum(bar142volume) / TotalSum(daycount);
def avgbar143 = TotalSum(bar143volume) / TotalSum(daycount);
def avgbar144 = TotalSum(bar144volume) / TotalSum(daycount);
def avgbar145 = TotalSum(bar145volume) / TotalSum(daycount);
def avgbar146 = TotalSum(bar146volume) / TotalSum(daycount);
def avgbar147 = TotalSum(bar147volume) / TotalSum(daycount);
def avgbar148 = TotalSum(bar148volume) / TotalSum(daycount);
def avgbar149 = TotalSum(bar149volume) / TotalSum(daycount);
def avgbar150 = TotalSum(bar150volume) / TotalSum(daycount);
def avgbar151 = TotalSum(bar151volume) / TotalSum(daycount);
def avgbar152 = TotalSum(bar152volume) / TotalSum(daycount);
def avgbar153 = TotalSum(bar153volume) / TotalSum(daycount);
def avgbar154 = TotalSum(bar154volume) / TotalSum(daycount);
def avgbar155 = TotalSum(bar155volume) / TotalSum(daycount);
def avgbar156 = TotalSum(bar156volume) / TotalSum(daycount);
def avgbar157 = TotalSum(bar157volume) / TotalSum(daycount);
def avgbar158 = TotalSum(bar158volume) / TotalSum(daycount);
def avgbar159 = TotalSum(bar159volume) / TotalSum(daycount);
def avgbar160 = TotalSum(bar160volume) / TotalSum(daycount);
def avgbar161 = TotalSum(bar161volume) / TotalSum(daycount);
def avgbar162 = TotalSum(bar162volume) / TotalSum(daycount);
def avgbar163 = TotalSum(bar163volume) / TotalSum(daycount);
def avgbar164 = TotalSum(bar164volume) / TotalSum(daycount);
def avgbar165 = TotalSum(bar165volume) / TotalSum(daycount);
def avgbar166 = TotalSum(bar166volume) / TotalSum(daycount);
def avgbar167 = TotalSum(bar167volume) / TotalSum(daycount);
def avgbar168 = TotalSum(bar168volume) / TotalSum(daycount);
def avgbar169 = TotalSum(bar169volume) / TotalSum(daycount);
def avgbar170 = TotalSum(bar170volume) / TotalSum(daycount);
def avgbar171 = TotalSum(bar171volume) / TotalSum(daycount);
def avgbar172 = TotalSum(bar172volume) / TotalSum(daycount);
def avgbar173 = TotalSum(bar173volume) / TotalSum(daycount);
def avgbar174 = TotalSum(bar174volume) / TotalSum(daycount);
def avgbar175 = TotalSum(bar175volume) / TotalSum(daycount);
def avgbar176 = TotalSum(bar176volume) / TotalSum(daycount);
def avgbar177 = TotalSum(bar177volume) / TotalSum(daycount);
def avgbar178 = TotalSum(bar178volume) / TotalSum(daycount);
def avgbar179 = TotalSum(bar179volume) / TotalSum(daycount);
def avgbar180 = TotalSum(bar180volume) / TotalSum(daycount);
def avgbar181 = TotalSum(bar181volume) / TotalSum(daycount);
def avgbar182 = TotalSum(bar182volume) / TotalSum(daycount);
def avgbar183 = TotalSum(bar183volume) / TotalSum(daycount);
def avgbar184 = TotalSum(bar184volume) / TotalSum(daycount);
def avgbar185 = TotalSum(bar185volume) / TotalSum(daycount);
def avgbar186 = TotalSum(bar186volume) / TotalSum(daycount);
def avgbar187 = TotalSum(bar187volume) / TotalSum(daycount);
def avgbar188 = TotalSum(bar188volume) / TotalSum(daycount);
def avgbar189 = TotalSum(bar189volume) / TotalSum(daycount);
def avgbar190 = TotalSum(bar190volume) / TotalSum(daycount);
def avgbar191 = TotalSum(bar191volume) / TotalSum(daycount);
def avgbar192 = TotalSum(bar192volume) / TotalSum(daycount);
def avgbar193 = TotalSum(bar193volume) / TotalSum(daycount);
def avgbar194 = TotalSum(bar194volume) / TotalSum(daycount);
def avgbar195 = TotalSum(bar195volume) / TotalSum(daycount);
def avgbar196 = TotalSum(bar196volume) / TotalSum(daycount);
def avgbar197 = TotalSum(bar197volume) / TotalSum(daycount);
def avgbar198 = TotalSum(bar198volume) / TotalSum(daycount);
def avgbar199 = TotalSum(bar199volume) / TotalSum(daycount);
def avgbar200 = TotalSum(bar200volume) / TotalSum(daycount);
def avgbar201 = TotalSum(bar201volume) / TotalSum(daycount);
def avgbar202 = TotalSum(bar202volume) / TotalSum(daycount);
def avgbar203 = TotalSum(bar203volume) / TotalSum(daycount);
def avgbar204 = TotalSum(bar204volume) / TotalSum(daycount);
def avgbar205 = TotalSum(bar205volume) / TotalSum(daycount);
def avgbar206 = TotalSum(bar206volume) / TotalSum(daycount);
def avgbar207 = TotalSum(bar207volume) / TotalSum(daycount);
def avgbar208 = TotalSum(bar208volume) / TotalSum(daycount);
def avgbar209 = TotalSum(bar209volume) / TotalSum(daycount);
def avgbar210 = TotalSum(bar210volume) / TotalSum(daycount);
def avgbar211 = TotalSum(bar211volume) / TotalSum(daycount);
def avgbar212 = TotalSum(bar212volume) / TotalSum(daycount);
def avgbar213 = TotalSum(bar213volume) / TotalSum(daycount);
def avgbar214 = TotalSum(bar214volume) / TotalSum(daycount);
def avgbar215 = TotalSum(bar215volume) / TotalSum(daycount);
def avgbar216 = TotalSum(bar216volume) / TotalSum(daycount);
def avgbar217 = TotalSum(bar217volume) / TotalSum(daycount);
def avgbar218 = TotalSum(bar218volume) / TotalSum(daycount);
def avgbar219 = TotalSum(bar219volume) / TotalSum(daycount);
def avgbar220 = TotalSum(bar220volume) / TotalSum(daycount);
def avgbar221 = TotalSum(bar221volume) / TotalSum(daycount);
def avgbar222 = TotalSum(bar222volume) / TotalSum(daycount);
def avgbar223 = TotalSum(bar223volume) / TotalSum(daycount);
def avgbar224 = TotalSum(bar224volume) / TotalSum(daycount);
def avgbar225 = TotalSum(bar225volume) / TotalSum(daycount);
def avgbar226 = TotalSum(bar226volume) / TotalSum(daycount);
def avgbar227 = TotalSum(bar227volume) / TotalSum(daycount);
def avgbar228 = TotalSum(bar228volume) / TotalSum(daycount);
def avgbar229 = TotalSum(bar229volume) / TotalSum(daycount);
def avgbar230 = TotalSum(bar230volume) / TotalSum(daycount);
def avgbar231 = TotalSum(bar231volume) / TotalSum(daycount);
def avgbar232 = TotalSum(bar232volume) / TotalSum(daycount);
def avgbar233 = TotalSum(bar233volume) / TotalSum(daycount);
def avgbar234 = TotalSum(bar234volume) / TotalSum(daycount);
def avgbar235 = TotalSum(bar235volume) / TotalSum(daycount);
def avgbar236 = TotalSum(bar236volume) / TotalSum(daycount);
def avgbar237 = TotalSum(bar237volume) / TotalSum(daycount);
def avgbar238 = TotalSum(bar238volume) / TotalSum(daycount);
def avgbar239 = TotalSum(bar239volume) / TotalSum(daycount);
def avgbar240 = TotalSum(bar240volume) / TotalSum(daycount);
def avgbar241 = TotalSum(bar241volume) / TotalSum(daycount);
def avgbar242 = TotalSum(bar242volume) / TotalSum(daycount);
def avgbar243 = TotalSum(bar243volume) / TotalSum(daycount);
def avgbar244 = TotalSum(bar244volume) / TotalSum(daycount);
def avgbar245 = TotalSum(bar245volume) / TotalSum(daycount);
def avgbar246 = TotalSum(bar246volume) / TotalSum(daycount);
def avgbar247 = TotalSum(bar247volume) / TotalSum(daycount);
def avgbar248 = TotalSum(bar248volume) / TotalSum(daycount);
def avgbar249 = TotalSum(bar249volume) / TotalSum(daycount);
def avgbar250 = TotalSum(bar250volume) / TotalSum(daycount);
def avgbar251 = TotalSum(bar251volume) / TotalSum(daycount);
def avgbar252 = TotalSum(bar252volume) / TotalSum(daycount);
def avgbar253 = TotalSum(bar253volume) / TotalSum(daycount);
def avgbar254 = TotalSum(bar254volume) / TotalSum(daycount);
def avgbar255 = TotalSum(bar255volume) / TotalSum(daycount);
def avgbar256 = TotalSum(bar256volume) / TotalSum(daycount);
def avgbar257 = TotalSum(bar257volume) / TotalSum(daycount);
def avgbar258 = TotalSum(bar258volume) / TotalSum(daycount);
def avgbar259 = TotalSum(bar259volume) / TotalSum(daycount);
def avgbar260 = TotalSum(bar260volume) / TotalSum(daycount);
def avgbar261 = TotalSum(bar261volume) / TotalSum(daycount);
def avgbar262 = TotalSum(bar262volume) / TotalSum(daycount);
def avgbar263 = TotalSum(bar263volume) / TotalSum(daycount);
def avgbar264 = TotalSum(bar264volume) / TotalSum(daycount);
def avgbar265 = TotalSum(bar265volume) / TotalSum(daycount);
def avgbar266 = TotalSum(bar266volume) / TotalSum(daycount);
def avgbar267 = TotalSum(bar267volume) / TotalSum(daycount);
def avgbar268 = TotalSum(bar268volume) / TotalSum(daycount);
def avgbar269 = TotalSum(bar269volume) / TotalSum(daycount);
def avgbar270 = TotalSum(bar270volume) / TotalSum(daycount);
def avgbar271 = TotalSum(bar271volume) / TotalSum(daycount);
def avgbar272 = TotalSum(bar272volume) / TotalSum(daycount);
def avgbar273 = TotalSum(bar273volume) / TotalSum(daycount);
def avgbar274 = TotalSum(bar274volume) / TotalSum(daycount);
def avgbar275 = TotalSum(bar275volume) / TotalSum(daycount);
def avgbar276 = TotalSum(bar276volume) / TotalSum(daycount);
def avgbar277 = TotalSum(bar277volume) / TotalSum(daycount);
def avgbar278 = TotalSum(bar278volume) / TotalSum(daycount);
def avgbar279 = TotalSum(bar279volume) / TotalSum(daycount);
def avgbar280 = TotalSum(bar280volume) / TotalSum(daycount);
def avgbar281 = TotalSum(bar281volume) / TotalSum(daycount);
def avgbar282 = TotalSum(bar282volume) / TotalSum(daycount);
def avgbar283 = TotalSum(bar283volume) / TotalSum(daycount);
def avgbar284 = TotalSum(bar284volume) / TotalSum(daycount);
def avgbar285 = TotalSum(bar285volume) / TotalSum(daycount);
def avgbar286 = TotalSum(bar286volume) / TotalSum(daycount);
def avgbar287 = TotalSum(bar287volume) / TotalSum(daycount);
def avgbar288 = TotalSum(bar288volume) / TotalSum(daycount);
def avgbar289 = TotalSum(bar289volume) / TotalSum(daycount);
def avgbar290 = TotalSum(bar290volume) / TotalSum(daycount);
def avgbar291 = TotalSum(bar291volume) / TotalSum(daycount);
def avgbar292 = TotalSum(bar292volume) / TotalSum(daycount);
def avgbar293 = TotalSum(bar293volume) / TotalSum(daycount);
def avgbar294 = TotalSum(bar294volume) / TotalSum(daycount);
def avgbar295 = TotalSum(bar295volume) / TotalSum(daycount);
def avgbar296 = TotalSum(bar296volume) / TotalSum(daycount);
def avgbar297 = TotalSum(bar297volume) / TotalSum(daycount);
def avgbar298 = TotalSum(bar298volume) / TotalSum(daycount);
def avgbar299 = TotalSum(bar299volume) / TotalSum(daycount);
def avgbar300 = TotalSum(bar300volume) / TotalSum(daycount);
def avgbar301 = TotalSum(bar301volume) / TotalSum(daycount);
def avgbar302 = TotalSum(bar302volume) / TotalSum(daycount);
def avgbar303 = TotalSum(bar303volume) / TotalSum(daycount);
def avgbar304 = TotalSum(bar304volume) / TotalSum(daycount);
def avgbar305 = TotalSum(bar305volume) / TotalSum(daycount);
def avgbar306 = TotalSum(bar306volume) / TotalSum(daycount);
def avgbar307 = TotalSum(bar307volume) / TotalSum(daycount);
def avgbar308 = TotalSum(bar308volume) / TotalSum(daycount);
def avgbar309 = TotalSum(bar309volume) / TotalSum(daycount);
def avgbar310 = TotalSum(bar310volume) / TotalSum(daycount);
def avgbar311 = TotalSum(bar311volume) / TotalSum(daycount);
def avgbar312 = TotalSum(bar312volume) / TotalSum(daycount);
def avgbar313 = TotalSum(bar313volume) / TotalSum(daycount);
def avgbar314 = TotalSum(bar314volume) / TotalSum(daycount);
def avgbar315 = TotalSum(bar315volume) / TotalSum(daycount);
def avgbar316 = TotalSum(bar316volume) / TotalSum(daycount);
def avgbar317 = TotalSum(bar317volume) / TotalSum(daycount);
def avgbar318 = TotalSum(bar318volume) / TotalSum(daycount);
def avgbar319 = TotalSum(bar319volume) / TotalSum(daycount);
def avgbar320 = TotalSum(bar320volume) / TotalSum(daycount);
def avgbar321 = TotalSum(bar321volume) / TotalSum(daycount);
def avgbar322 = TotalSum(bar322volume) / TotalSum(daycount);
def avgbar323 = TotalSum(bar323volume) / TotalSum(daycount);
def avgbar324 = TotalSum(bar324volume) / TotalSum(daycount);
def avgbar325 = TotalSum(bar325volume) / TotalSum(daycount);
def avgbar326 = TotalSum(bar326volume) / TotalSum(daycount);
def avgbar327 = TotalSum(bar327volume) / TotalSum(daycount);
def avgbar328 = TotalSum(bar328volume) / TotalSum(daycount);
def avgbar329 = TotalSum(bar329volume) / TotalSum(daycount);
def avgbar330 = TotalSum(bar330volume) / TotalSum(daycount);
def avgbar331 = TotalSum(bar331volume) / TotalSum(daycount);
def avgbar332 = TotalSum(bar332volume) / TotalSum(daycount);
def avgbar333 = TotalSum(bar333volume) / TotalSum(daycount);
def avgbar334 = TotalSum(bar334volume) / TotalSum(daycount);
def avgbar335 = TotalSum(bar335volume) / TotalSum(daycount);
def avgbar336 = TotalSum(bar336volume) / TotalSum(daycount);
def avgbar337 = TotalSum(bar337volume) / TotalSum(daycount);
def avgbar338 = TotalSum(bar338volume) / TotalSum(daycount);
def avgbar339 = TotalSum(bar339volume) / TotalSum(daycount);
def avgbar340 = TotalSum(bar340volume) / TotalSum(daycount);
def avgbar341 = TotalSum(bar341volume) / TotalSum(daycount);
def avgbar342 = TotalSum(bar342volume) / TotalSum(daycount);
def avgbar343 = TotalSum(bar343volume) / TotalSum(daycount);
def avgbar344 = TotalSum(bar344volume) / TotalSum(daycount);
def avgbar345 = TotalSum(bar345volume) / TotalSum(daycount);
def avgbar346 = TotalSum(bar346volume) / TotalSum(daycount);
def avgbar347 = TotalSum(bar347volume) / TotalSum(daycount);
def avgbar348 = TotalSum(bar348volume) / TotalSum(daycount);
def avgbar349 = TotalSum(bar349volume) / TotalSum(daycount);
def avgbar350 = TotalSum(bar350volume) / TotalSum(daycount);
def avgbar351 = TotalSum(bar351volume) / TotalSum(daycount);
def avgbar352 = TotalSum(bar352volume) / TotalSum(daycount);
def avgbar353 = TotalSum(bar353volume) / TotalSum(daycount);
def avgbar354 = TotalSum(bar354volume) / TotalSum(daycount);
def avgbar355 = TotalSum(bar355volume) / TotalSum(daycount);
def avgbar356 = TotalSum(bar356volume) / TotalSum(daycount);
def avgbar357 = TotalSum(bar357volume) / TotalSum(daycount);
def avgbar358 = TotalSum(bar358volume) / TotalSum(daycount);
def avgbar359 = TotalSum(bar359volume) / TotalSum(daycount);
def avgbar360 = TotalSum(bar360volume) / TotalSum(daycount);
def avgbar361 = TotalSum(bar361volume) / TotalSum(daycount);
def avgbar362 = TotalSum(bar362volume) / TotalSum(daycount);
def avgbar363 = TotalSum(bar363volume) / TotalSum(daycount);
def avgbar364 = TotalSum(bar364volume) / TotalSum(daycount);
def avgbar365 = TotalSum(bar365volume) / TotalSum(daycount);
def avgbar366 = TotalSum(bar366volume) / TotalSum(daycount);
def avgbar367 = TotalSum(bar367volume) / TotalSum(daycount);
def avgbar368 = TotalSum(bar368volume) / TotalSum(daycount);
def avgbar369 = TotalSum(bar369volume) / TotalSum(daycount);
def avgbar370 = TotalSum(bar370volume) / TotalSum(daycount);
def avgbar371 = TotalSum(bar371volume) / TotalSum(daycount);
def avgbar372 = TotalSum(bar372volume) / TotalSum(daycount);
def avgbar373 = TotalSum(bar373volume) / TotalSum(daycount);
def avgbar374 = TotalSum(bar374volume) / TotalSum(daycount);
def avgbar375 = TotalSum(bar375volume) / TotalSum(daycount);
def avgbar376 = TotalSum(bar376volume) / TotalSum(daycount);
def avgbar377 = TotalSum(bar377volume) / TotalSum(daycount);
def avgbar378 = TotalSum(bar378volume) / TotalSum(daycount);
def avgbar379 = TotalSum(bar379volume) / TotalSum(daycount);
def avgbar380 = TotalSum(bar380volume) / TotalSum(daycount);
def avgbar381 = TotalSum(bar381volume) / TotalSum(daycount);
def avgbar382 = TotalSum(bar382volume) / TotalSum(daycount);
def avgbar383 = TotalSum(bar383volume) / TotalSum(daycount);
def avgbar384 = TotalSum(bar384volume) / TotalSum(daycount);
def avgbar385 = TotalSum(bar385volume) / TotalSum(daycount);
def avgbar386 = TotalSum(bar386volume) / TotalSum(daycount);
def avgbar387 = TotalSum(bar387volume) / TotalSum(daycount);
def avgbar388 = TotalSum(bar388volume) / TotalSum(daycount);
def avgbar389 = TotalSum(bar389volume) / TotalSum(daycount);
def avgbar390 = TotalSum(bar390volume) / TotalSum(daycount);

plot AvgRelVol =   if GetDay() != GetlastDay() then na
else if barcounter == 1 then avgbar1
else if barcounter == 2 then avgbar2
else if barcounter == 3 then avgbar3
else if barcounter == 4 then avgbar4
else if barcounter == 5 then avgbar5
else if barcounter == 6 then avgbar6
else if barcounter == 7 then avgbar7
else if barcounter == 8 then avgbar8
else if barcounter == 9 then avgbar9
else if barcounter == 10 then avgbar10
else if barcounter == 11 then avgbar11
else if barcounter == 12 then avgbar12
else if barcounter == 13 then avgbar13
else if barcounter == 14 then avgbar14
else if barcounter == 15 then avgbar15
else if barcounter == 16 then avgbar16
else if barcounter == 17 then avgbar17
else if barcounter == 18 then avgbar18
else if barcounter == 19 then avgbar19
else if barcounter == 20 then avgbar20
else if barcounter == 21 then avgbar21
else if barcounter == 22 then avgbar22
else if barcounter == 23 then avgbar23
else if barcounter == 24 then avgbar24
else if barcounter == 25 then avgbar25
else if barcounter == 26 then avgbar26
else if barcounter == 27 then avgbar27
else if barcounter == 28 then avgbar28
else if barcounter == 29 then avgbar29
else if barcounter == 30 then avgbar30
else if barcounter == 31 then avgbar31
else if barcounter == 32 then avgbar32
else if barcounter == 33 then avgbar33
else if barcounter == 34 then avgbar34
else if barcounter == 35 then avgbar35
else if barcounter == 36 then avgbar36
else if barcounter == 37 then avgbar37
else if barcounter == 38 then avgbar38
else if barcounter == 39 then avgbar39
else if barcounter == 40 then avgbar40
else if barcounter == 41 then avgbar41
else if barcounter == 42 then avgbar42
else if barcounter == 43 then avgbar43
else if barcounter == 44 then avgbar44
else if barcounter == 45 then avgbar45
else if barcounter == 46 then avgbar46
else if barcounter == 47 then avgbar47
else if barcounter == 48 then avgbar48
else if barcounter == 49 then avgbar49
else if barcounter == 50 then avgbar50
else if barcounter == 51 then avgbar51
else if barcounter == 52 then avgbar52
else if barcounter == 53 then avgbar53
else if barcounter == 54 then avgbar54
else if barcounter == 55 then avgbar55
else if barcounter == 56 then avgbar56
else if barcounter == 57 then avgbar57
else if barcounter == 58 then avgbar58
else if barcounter == 59 then avgbar59
else if barcounter == 60 then avgbar60
else if barcounter == 61 then avgbar61
else if barcounter == 62 then avgbar62
else if barcounter == 63 then avgbar63
else if barcounter == 64 then avgbar64
else if barcounter == 65 then avgbar65
else if barcounter == 66 then avgbar66
else if barcounter == 67 then avgbar67
else if barcounter == 68 then avgbar68
else if barcounter == 69 then avgbar69
else if barcounter == 70 then avgbar70
else if barcounter == 71 then avgbar71
else if barcounter == 72 then avgbar72
else if barcounter == 73 then avgbar73
else if barcounter == 74 then avgbar74
else if barcounter == 75 then avgbar75
else if barcounter == 76 then avgbar76
else if barcounter == 77 then avgbar77
else if barcounter == 78 then avgbar78
else if barcounter == 79 then avgbar79
else if barcounter == 80 then avgbar80
else if barcounter == 81 then avgbar81
else if barcounter == 82 then avgbar82
else if barcounter == 83 then avgbar83
else if barcounter == 84 then avgbar84
else if barcounter == 85 then avgbar85
else if barcounter == 86 then avgbar86
else if barcounter == 87 then avgbar87
else if barcounter == 88 then avgbar88
else if barcounter == 89 then avgbar89
else if barcounter == 90 then avgbar90
else if barcounter == 91 then avgbar91
else if barcounter == 92 then avgbar92
else if barcounter == 93 then avgbar93
else if barcounter == 94 then avgbar94
else if barcounter == 95 then avgbar95
else if barcounter == 96 then avgbar96
else if barcounter == 97 then avgbar97
else if barcounter == 98 then avgbar98
else if barcounter == 99 then avgbar99
else if barcounter == 100 then avgbar100
else if barcounter == 101 then avgbar101
else if barcounter == 102 then avgbar102
else if barcounter == 103 then avgbar103
else if barcounter == 104 then avgbar104
else if barcounter == 105 then avgbar105
else if barcounter == 106 then avgbar106
else if barcounter == 107 then avgbar107
else if barcounter == 108 then avgbar108
else if barcounter == 109 then avgbar109
else if barcounter == 110 then avgbar110
else if barcounter == 111 then avgbar111
else if barcounter == 112 then avgbar112
else if barcounter == 113 then avgbar113
else if barcounter == 114 then avgbar114
else if barcounter == 115 then avgbar115
else if barcounter == 116 then avgbar116
else if barcounter == 117 then avgbar117
else if barcounter == 118 then avgbar118
else if barcounter == 119 then avgbar119
else if barcounter == 120 then avgbar120
else if barcounter == 121 then avgbar121
else if barcounter == 122 then avgbar122
else if barcounter == 123 then avgbar123
else if barcounter == 124 then avgbar124
else if barcounter == 125 then avgbar125
else if barcounter == 126 then avgbar126
else if barcounter == 127 then avgbar127
else if barcounter == 128 then avgbar128
else if barcounter == 129 then avgbar129
else if barcounter == 130 then avgbar100
else if barcounter == 131 then avgbar131
else if barcounter == 132 then avgbar132
else if barcounter == 133 then avgbar133
else if barcounter == 134 then avgbar134
else if barcounter == 135 then avgbar105
else if barcounter == 136 then avgbar136
else if barcounter == 137 then avgbar137
else if barcounter == 138 then avgbar138
else if barcounter == 139 then avgbar139
else if barcounter == 140 then avgbar140
else if barcounter == 141 then avgbar141
else if barcounter == 142 then avgbar142
else if barcounter == 143 then avgbar143
else if barcounter == 144 then avgbar144
else if barcounter == 145 then avgbar145
else if barcounter == 146 then avgbar146
else if barcounter == 147 then avgbar147
else if barcounter == 148 then avgbar148
else if barcounter == 149 then avgbar149
else if barcounter == 150 then avgbar120
else if barcounter == 151 then avgbar151
else if barcounter == 152 then avgbar152
else if barcounter == 153 then avgbar153
else if barcounter == 154 then avgbar154
else if barcounter == 155 then avgbar155
else if barcounter == 156 then avgbar156
else if barcounter == 157 then avgbar157
else if barcounter == 158 then avgbar158
else if barcounter == 159 then avgbar159
else if barcounter == 160 then avgbar160
else if barcounter == 161 then avgbar161
else if barcounter == 162 then avgbar162
else if barcounter == 163 then avgbar163
else if barcounter == 164 then avgbar164
else if barcounter == 165 then avgbar165
else if barcounter == 166 then avgbar166
else if barcounter == 167 then avgbar167
else if barcounter == 168 then avgbar168
else if barcounter == 169 then avgbar169
else if barcounter == 170 then avgbar170
else if barcounter == 171 then avgbar171
else if barcounter == 172 then avgbar172
else if barcounter == 173 then avgbar173
else if barcounter == 174 then avgbar174
else if barcounter == 175 then avgbar175
else if barcounter == 176 then avgbar176
else if barcounter == 177 then avgbar177
else if barcounter == 178 then avgbar178
else if barcounter == 179 then avgbar179
else if barcounter == 180 then avgbar180
else if barcounter == 181 then avgbar181
else if barcounter == 182 then avgbar182
else if barcounter == 183 then avgbar183
else if barcounter == 184 then avgbar184
else if barcounter == 185 then avgbar185
else if barcounter == 186 then avgbar186
else if barcounter == 187 then avgbar187
else if barcounter == 188 then avgbar188
else if barcounter == 189 then avgbar189
else if barcounter == 190 then avgbar190
else if barcounter == 191 then avgbar191
else if barcounter == 192 then avgbar192
else if barcounter == 193 then avgbar193
else if barcounter == 194 then avgbar194
else if barcounter == 195 then avgbar195
else if barcounter == 196 then avgbar196
else if barcounter == 197 then avgbar197
else if barcounter == 198 then avgbar198
else if barcounter == 199 then avgbar199
else if barcounter == 200 then avgbar200
else if barcounter == 201 then avgbar201
else if barcounter == 202 then avgbar202
else if barcounter == 203 then avgbar203
else if barcounter == 204 then avgbar204
else if barcounter == 205 then avgbar205
else if barcounter == 206 then avgbar206
else if barcounter == 207 then avgbar207
else if barcounter == 208 then avgbar208
else if barcounter == 209 then avgbar209
else if barcounter == 210 then avgbar210
else if barcounter == 211 then avgbar211
else if barcounter == 212 then avgbar212
else if barcounter == 213 then avgbar213
else if barcounter == 214 then avgbar214
else if barcounter == 215 then avgbar215
else if barcounter == 216 then avgbar216
else if barcounter == 217 then avgbar217
else if barcounter == 218 then avgbar218
else if barcounter == 219 then avgbar219
else if barcounter == 220 then avgbar220
else if barcounter == 221 then avgbar221
else if barcounter == 222 then avgbar222
else if barcounter == 223 then avgbar223
else if barcounter == 224 then avgbar224
else if barcounter == 225 then avgbar225
else if barcounter == 226 then avgbar226
else if barcounter == 227 then avgbar227
else if barcounter == 228 then avgbar228
else if barcounter == 229 then avgbar229
else if barcounter == 230 then avgbar230
else if barcounter == 231 then avgbar231
else if barcounter == 232 then avgbar232
else if barcounter == 233 then avgbar233
else if barcounter == 234 then avgbar234
else if barcounter == 235 then avgbar235
else if barcounter == 236 then avgbar236
else if barcounter == 237 then avgbar237
else if barcounter == 238 then avgbar238
else if barcounter == 239 then avgbar239
else if barcounter == 240 then avgbar240
else if barcounter == 241 then avgbar241
else if barcounter == 242 then avgbar242
else if barcounter == 243 then avgbar243
else if barcounter == 244 then avgbar244
else if barcounter == 245 then avgbar245
else if barcounter == 246 then avgbar246
else if barcounter == 247 then avgbar247
else if barcounter == 248 then avgbar248
else if barcounter == 249 then avgbar249
else if barcounter == 250 then avgbar220
else if barcounter == 251 then avgbar251
else if barcounter == 252 then avgbar252
else if barcounter == 253 then avgbar253
else if barcounter == 254 then avgbar254
else if barcounter == 255 then avgbar255
else if barcounter == 256 then avgbar256
else if barcounter == 257 then avgbar257
else if barcounter == 258 then avgbar258
else if barcounter == 259 then avgbar259
else if barcounter == 260 then avgbar260
else if barcounter == 261 then avgbar261
else if barcounter == 262 then avgbar262
else if barcounter == 263 then avgbar263
else if barcounter == 264 then avgbar264
else if barcounter == 265 then avgbar265
else if barcounter == 266 then avgbar266
else if barcounter == 267 then avgbar267
else if barcounter == 268 then avgbar268
else if barcounter == 269 then avgbar269
else if barcounter == 270 then avgbar270
else if barcounter == 271 then avgbar271
else if barcounter == 272 then avgbar272
else if barcounter == 273 then avgbar273
else if barcounter == 274 then avgbar274
else if barcounter == 275 then avgbar275
else if barcounter == 276 then avgbar276
else if barcounter == 277 then avgbar277
else if barcounter == 278 then avgbar278
else if barcounter == 279 then avgbar279
else if barcounter == 280 then avgbar280
else if barcounter == 281 then avgbar281
else if barcounter == 282 then avgbar282
else if barcounter == 283 then avgbar283
else if barcounter == 284 then avgbar284
else if barcounter == 285 then avgbar285
else if barcounter == 286 then avgbar286
else if barcounter == 287 then avgbar287
else if barcounter == 288 then avgbar288
else if barcounter == 289 then avgbar289
else if barcounter == 290 then avgbar290
else if barcounter == 291 then avgbar291
else if barcounter == 292 then avgbar292
else if barcounter == 293 then avgbar293
else if barcounter == 294 then avgbar294
else if barcounter == 295 then avgbar295
else if barcounter == 296 then avgbar296
else if barcounter == 297 then avgbar297
else if barcounter == 298 then avgbar298
else if barcounter == 299 then avgbar299
else if barcounter == 300 then avgbar300
else if barcounter == 301 then avgbar301
else if barcounter == 302 then avgbar302
else if barcounter == 303 then avgbar303
else if barcounter == 304 then avgbar304
else if barcounter == 305 then avgbar305
else if barcounter == 306 then avgbar306
else if barcounter == 307 then avgbar307
else if barcounter == 308 then avgbar308
else if barcounter == 309 then avgbar309
else if barcounter == 310 then avgbar310
else if barcounter == 311 then avgbar311
else if barcounter == 312 then avgbar312
else if barcounter == 313 then avgbar313
else if barcounter == 314 then avgbar314
else if barcounter == 315 then avgbar315
else if barcounter == 316 then avgbar316
else if barcounter == 317 then avgbar317
else if barcounter == 318 then avgbar318
else if barcounter == 319 then avgbar319
else if barcounter == 320 then avgbar320
else if barcounter == 321 then avgbar321
else if barcounter == 322 then avgbar322
else if barcounter == 323 then avgbar323
else if barcounter == 324 then avgbar324
else if barcounter == 325 then avgbar325
else if barcounter == 326 then avgbar326
else if barcounter == 327 then avgbar327
else if barcounter == 328 then avgbar328
else if barcounter == 329 then avgbar329
else if barcounter == 330 then avgbar330
else if barcounter == 331 then avgbar331
else if barcounter == 332 then avgbar332
else if barcounter == 333 then avgbar333
else if barcounter == 334 then avgbar334
else if barcounter == 335 then avgbar335
else if barcounter == 336 then avgbar336
else if barcounter == 337 then avgbar337
else if barcounter == 338 then avgbar338
else if barcounter == 339 then avgbar339
else if barcounter == 340 then avgbar340
else if barcounter == 341 then avgbar341
else if barcounter == 342 then avgbar342
else if barcounter == 343 then avgbar343
else if barcounter == 344 then avgbar344
else if barcounter == 345 then avgbar345
else if barcounter == 346 then avgbar346
else if barcounter == 347 then avgbar347
else if barcounter == 348 then avgbar348
else if barcounter == 349 then avgbar349
else if barcounter == 350 then avgbar320
else if barcounter == 351 then avgbar351
else if barcounter == 352 then avgbar352
else if barcounter == 353 then avgbar353
else if barcounter == 354 then avgbar354
else if barcounter == 355 then avgbar355
else if barcounter == 356 then avgbar356
else if barcounter == 357 then avgbar357
else if barcounter == 358 then avgbar358
else if barcounter == 359 then avgbar359
else if barcounter == 360 then avgbar360
else if barcounter == 361 then avgbar361
else if barcounter == 362 then avgbar362
else if barcounter == 363 then avgbar363
else if barcounter == 364 then avgbar364
else if barcounter == 365 then avgbar365
else if barcounter == 366 then avgbar366
else if barcounter == 367 then avgbar367
else if barcounter == 368 then avgbar368
else if barcounter == 369 then avgbar369
else if barcounter == 370 then avgbar370
else if barcounter == 371 then avgbar371
else if barcounter == 372 then avgbar372
else if barcounter == 373 then avgbar373
else if barcounter == 374 then avgbar374
else if barcounter == 375 then avgbar375
else if barcounter == 376 then avgbar376
else if barcounter == 377 then avgbar377
else if barcounter == 378 then avgbar378
else if barcounter == 379 then avgbar379
else if barcounter == 380 then avgbar380
else if barcounter == 381 then avgbar381
else if barcounter == 382 then avgbar382
else if barcounter == 383 then avgbar383
else if barcounter == 384 then avgbar384
else if barcounter == 385 then avgbar385
else if barcounter == 386 then avgbar386
else if barcounter == 387 then avgbar387
else if barcounter == 388 then avgbar388
else if barcounter == 389 then avgbar389
else if barcounter == 390 then avgbar390
else na;

AvgRelVol.SetDefaultColor(Color.DARK_GRAY);
#avgvol.setstyle(curve.points);
AvgRelVol.SetLineWeight(1);
plot zero = 0;
AddCloud(AvgRelVol, zero, Color.GRAY);

plot vol = volume;
vol.SetLineWeight(3);
vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
vol.AssignValueColor(if !istoday then Color.CYAN else if volume > AvgRelVol then Color.YELLOW else Color.GRAY);

I would like to be able to see the past days relative volume cloud instead of only the current day. Is there an easy solution to this? I was messing around with the " if GetDay() != GetlastDay() then na" after the plot for avgrelvol and I was able to see some past days but it would mess up the averaging.

LM59cvt.png
 
I am looking for a lower study that will plot the relative volume of a stock. I would like for this to work on all timeframes. Does anybody have anything like this, or could it be created?

Thank you for your time!
 
I've spent a few hours searching the forums, but couldn't find what I was looking for.

And no, I'm not the greatest thread searcher. ;)

I'm looking for a relative volume by time indicator that will tell me what the volume for a given bar is relative to that same bar in previous sessions.

For example, what is the volume of the 1st 15 minute bar of the day relative to the average of the last 10 days first 15 minute bars.

Edit: Never mind, I found it. Thanks.
 
Last edited:
Hi, I would like to ask if there is any study for relative volume on intraday time frames, actual volume done by that time of the day compared to average volume done by that time of day?
Yea, here's what I got. Will show Avg Bar Vol and Current Bar Vol ( will adjust for candles over any TF.) You get the stock's Daily Vol Avg (30 Days), Today's Volume (Starts Counting from the Bell), and then hen there is a small percentage badge, it shows over any time frame the percentage of the Avg Daily Vol Avg Done so far. ( Stock's Daily Avg is say 1Mil and by 10am it's done 8Mil to badge will show 800%, think that's what you want) Just keeps a running total. The bars turn colors, I changed mine to White, anywhere there is a color in the code, change it to white (if your not feeling the changing color thing.)

The Second Label study is an RVOL label/badge whatever you call it. Anyway, it's looking at current or previous bar vs

Code:
declare on_volume;


input Show30DayAvg = yes;
input ShowTodayVolume =  yes;
input ShowPercentOf30DayAvg = yes;
input UnusualVolumePercent = 200;
input Show30BarAvg = yes;
input ShowCurrentBar = yes;


#Volume Data
def volLast30DayAvg = (volume(period = "DAY")[1] + volume(period = "DAY")[2] + volume(period = "DAY")[3] + volume(period = "DAY")[4] + volume(period = "DAY")[5] + volume(period = "DAY")[6] + volume(period = "DAY")[7] + volume(period = "DAY")[8] + volume(period = "DAY")[9] + volume(period = "DAY")[10] + volume(period = "DAY")[11] + volume(period = "DAY")[12] + volume(period = "DAY")[13] + volume(period = "DAY")[14] + volume(period = "DAY")[15] + volume(period = "DAY")[16] + volume(period = "DAY")[17] + volume(period = "DAY")[18] + volume(period = "DAY")[19] + volume(period = "DAY")[20] + volume(period = "DAY")[21] + volume(period = "DAY")[22] + volume(period = "DAY")[23] + volume(period = "DAY")[24] + volume(period = "DAY")[25] + volume(period = "DAY")[26] + volume(period = "DAY")[27] + volume(period = "DAY")[28] + volume(period = "DAY")[29] + volume(period = "DAY")[30]) / 30;
def today = volume(period = "DAY");
def percentOf30Day = Round((today / volLast30DayAvg) * 100, 0);
#def avg30Bars = VolumeAvg(30).VolAvg;
def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
def curVolume = volume;


# Labels
AddLabel(Show30DayAvg, "Daily Avg: " + Round(volLast30DayAvg, 0), Color.WHITE);
AddLabel(ShowTodayVolume, "Today: " + today, (if percentOf30Day >= UnusualVolumePercent then Color.RED else if percentOf30Day >= 100 then Color.red else Color.LIGHT_GRAY));
AddLabel(ShowPercentOf30DayAvg, percentOf30Day + "%", (if percentOf30Day >= UnusualVolumePercent then Color.blue else if percentOf30Day >= 100 then Color.blue else Color.WHITE) );
AddLabel(Show30BarAvg, "Avg Bar: " + Round(avg30Bars, 0), Color.LIGHT_GRAY);
AddLabel(ShowCurrentBar, "Cur Bar: " + curVolume, (if curVolume >= avg30Bars then Color.red else Color.Light_Gray));


Study # 2 RVOL_BADGE

input length = 21;
input offset = 1;

def ADV = Average(volume, length)[offset];
def rVol = volume /ADV;

# remove "#" infront of Addlabels to select prefer choice

AddLabel(yes, round(rVol,2));
#AddLabel(yes, asPercent(rVol));
 
Somewhere in that thread is possibly what you are looking for, there are a few codes in there, maybe one of them is what you are looking for https://usethinkscript.com/threads/after-hours-relative-volume-indicator-for-thinkorswim.2520/
@XeoNoX @markos I am looking for a study by Mobius, he named it as Relative Volume Range. "It simply looks for volume decreasing when the trend is rising indicating the trend is running out of gas and a trend polarity change may be close and it looks for sudden volume rising when the trend is down indicating capitulation. It's a leading indicator." Thank you. @J007RMC @Slippage
 
@Jonas99
I found this on OneNote. Any chance this is the script that you are seeking:
Ruby:
# Volume Scaled to Price Chart Range
# Mobius
# V01.01.2015
# A different way to look at price averages and volume averages. If volume average jumps above price average at the beginning of a trend volume is confirming the new trend.
# How it's Done: Through a continuous function volume is scaled to the same range of price. The Highest and Lowest of the price series for n bars form the Maximum Highest and Minimum Lowest boundaries for the volume range. 

input n = 10;
input AvgType = AverageType.Hull;

def c = close;
def v = volume;
script ScaledPlot {
    input data = 0;
    input n = 0;
    def Min = lowest(close, n);
    def Max = highest(close, n);
    def hh = Highest(data, n);
    def ll = Lowest(data, n);
    plot Range = (((Max - Min) * (data - ll)) /  (hh - ll)) + Min;
}
plot ScaledVolume = MovingAverage(AvgType, scaledPlot(v, n), n);
     ScaledVolume.SetLineWeight(3);
plot avgPrice = MovingAverage(AvgType, c, n);
     avgPrice.SetLineWeight(2);
     ScaledVolume.AssignValueColor(if avgPrice > avgPrice[1] and
                                      ScaledVolume > ScaledVolume[1]
                                   then color.dark_green
                                   else if avgPrice < AvgPrice[1] and
                                           ScaledVolume < ScaledVolume[1]
                                   then color.dark_red
                                   else color.gray);
     avgPrice.AssignValueColor(if avgPrice > avgPrice[1] and
                                      ScaledVolume > ScaledVolume[1]
                                   then color.green
                                   else if avgPrice < AvgPrice[1] and
                                           ScaledVolume < ScaledVolume[1]
                                   then color.red
                                   else color.cyan);;
# End Code Scaled Volume
a1.png
 
@Jonas99
I found this on OneNote. Any chance this is the script that you are seeking:
Ruby:
# Volume Scaled to Price Chart Range
# Mobius
# V01.01.2015
# A different way to look at price averages and volume averages. If volume average jumps above price average at the beginning of a trend volume is confirming the new trend.
# How it's Done: Through a continuous function volume is scaled to the same range of price. The Highest and Lowest of the price series for n bars form the Maximum Highest and Minimum Lowest boundaries for the volume range.

input n = 10;
input AvgType = AverageType.Hull;

def c = close;
def v = volume;
script ScaledPlot {
    input data = 0;
    input n = 0;
    def Min = lowest(close, n);
    def Max = highest(close, n);
    def hh = Highest(data, n);
    def ll = Lowest(data, n);
    plot Range = (((Max - Min) * (data - ll)) /  (hh - ll)) + Min;
}
plot ScaledVolume = MovingAverage(AvgType, scaledPlot(v, n), n);
     ScaledVolume.SetLineWeight(3);
plot avgPrice = MovingAverage(AvgType, c, n);
     avgPrice.SetLineWeight(2);
     ScaledVolume.AssignValueColor(if avgPrice > avgPrice[1] and
                                      ScaledVolume > ScaledVolume[1]
                                   then color.dark_green
                                   else if avgPrice < AvgPrice[1] and
                                           ScaledVolume < ScaledVolume[1]
                                   then color.dark_red
                                   else color.gray);
     avgPrice.AssignValueColor(if avgPrice > avgPrice[1] and
                                      ScaledVolume > ScaledVolume[1]
                                   then color.green
                                   else if avgPrice < AvgPrice[1] and
                                           ScaledVolume < ScaledVolume[1]
                                   then color.red
                                   else color.cyan);;
# End Code Scaled Volume
View attachment 970
Thanks @MerryDay ! I decided on this one RelativeVolumeStDev
 
Last edited by a moderator:
Hello!

I'd like to have an indicator that draws support and resistance lines each time the relative volume goes above it's standard deviation.

Here's an example of what I'm looking for:
Here's what I have so far....

#declare lower;
#declare zerobase;

input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
plot StDevLevel = numDev;

RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RelVol.SetLineWeight(3);
RelVol.DefineColor("Above", GetColor(0));
RelVol.DefineColor("Below", GetColor(2));
RelVol.AssignValueColor(if RelVol >= numDev then RelVol.Color("Above") else RelVol.Color("Below"));
StDevLevel.SetDefaultColor(GetColor(7));
StDevLevel.SetStyle(Curve.SHORT_DASH);

###############################################################################
###############################################################################
Def Red_Candle = RelVol > StDevLevel && close < open;
Def Green_Candle = RelVol > StDevLevel && close > open;

Plot High_Red_Line = if Red_Candle is true then High else double.nan;
High_Red_Line.SetPaintingStrategy(PaintingStrategy.HorIZONTAL);

Plot Open_Red_Line = if Red_Candle is true then Open else double.nan;
Open_Red_Line.SetPaintingStrategy(PaintingStrategy.HorIZONTAL);

Plot Low_Green_Line = if Green_Candle is true then Low else double.nan;
Low_Green_Line.SetPaintingStrategy(PaintingStrategy.HorIZONTAL);

Plot Open_Green_Line = if Green_Candle is true then Open else double.nan;
Open_Green_Line.SetPaintingStrategy(PaintingStrategy.HorIZONTAL);

###############################################################################
###############################################################################
 
Last edited:
@SJP07
Nhc8Ywk.png

Ruby:
input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
def RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
def StDevLevel = numDev;

###############################################################################
###############################################################################
def today = GetDay() == GetLastDay();

Def Red_Candle = RelVol > StDevLevel && close < open;
Def Green_Candle = RelVol > StDevLevel && close > open;

def HRL = if !today then Double.NaN else if Red_Candle then high else HRL[1];
Plot High_Red_Line = HRL;
High_Red_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
High_Red_Line.AssignValueColor(Color.RED);
#High_Red_Line.Hide();

def ORL = if !today then Double.NaN else if Red_Candle then open else ORL[1];
Plot Open_Red_Line = ORL;
Open_Red_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Open_Red_Line.AssignValueColor(Color.RED);
#Open_Red_Line.Hide();

def LGL = if !today then Double.NaN else if Green_Candle then low else LGL[1];
Plot Low_Green_Line = LGL;
Low_Green_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Low_Green_Line.AssignValueColor(Color.GREEN);
#Low_Green_Line.Hide();

def OGL = if !today then Double.NaN else if Green_Candle then open else OGL[1];
Plot Open_Green_Line = OGL;
Open_Green_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Open_Green_Line.AssignValueColor(Color.GREEN);
#Open_Green_Line.Hide();

AddCloud(if Red_Candle then Double.NEGATIVE_INFINITY else High_Red_Line,if Red_Candle then Double.NEGATIVE_INFINITY else Open_Red_Line,color.RED);
AddCloud(if Green_Candle then Double.NEGATIVE_INFINITY else Open_Green_Line,if Green_Candle then Double.NEGATIVE_INFINITY else Low_Green_Line,color.GREEN);

###############################################################################
###############################################################################
 
Could this code be modified to only show the last one or two times that the volume was higher than the standard deviation? Thanks in advance!
 
@SJP07 I probably made this too complicated, but this show only the last two sets of green lines and last two sets of red lines.

7gEExsl.png

Ruby:
input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
def RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
def StDevLevel = numDev;

###############################################################################
###############################################################################

Def Red_Candle = RelVol > StDevLevel && close < open;
Def Green_Candle = RelVol > StDevLevel && close > open;

def HRL = if Red_Candle then high else HRL[1];
def ORL = if Red_Candle then open else ORL[1];

def BarNum = if !IsNaN(close) and BarNumber() > 0 then BarNumber() else BarNum[1];
def VBar = HighestAll(BarNum);

def BSHRL = fold a = 0 to AbsValue(VBar) while !IsNaN(GetValue(close, -a)) do GetValue(HRL, -a);
def SECRC = if HRL <> BSHRL then 2 else 1;
def SECHRL = if SECRC == 2 then HRL else SECHRL[1];
def BSSECHRL =  fold b = 0 to AbsValue(VBar) while !IsNaN(GetValue(close, -b)) do GetValue(SECHRL, -b);
def THRHRL = if HRL <> BSSECHRL then 3 else 2;

Plot High_Red_Line = if SECRC == 1 or THRHRL == 2 then HRL else double.nan;
High_Red_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
High_Red_Line.AssignValueColor(Color.RED);
#High_Red_Line.Hide();

Plot Open_Red_Line = if SECRC == 1 or THRHRL == 2 then ORL else double.nan;
Open_Red_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Open_Red_Line.AssignValueColor(Color.RED);
#Open_Red_Line.Hide();

def LGL = if Green_Candle then low else LGL[1];
def OGL = if Green_Candle then open else OGL[1];

def BSLGL = fold c = 0 to AbsValue(VBar) while !IsNaN(GetValue(close, -c)) do GetValue(LGL, -c);
def SECGC = if LGL <> BSLGL then 2 else 1;
def SECLGL = if SECGC == 2 then LGL else SECLGL[1];
def BSSECLGL =  fold d = 0 to AbsValue(VBar) while !IsNaN(GetValue(close, -d)) do GetValue(SECLGL, -d);
def THRLGL = if LGL <> BSSECLGL then 3 else 2;

Plot Low_Green_Line = if SECGC == 1 or THRLGL == 2 then LGL else double.nan;
Low_Green_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Low_Green_Line.AssignValueColor(Color.GREEN);
#Low_Green_Line.Hide();

Plot Open_Green_Line = if SECGC == 1 or THRLGL == 2 then OGL else double.nan;
Open_Green_Line.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Open_Green_Line.AssignValueColor(Color.GREEN);
#Open_Green_Line.Hide();

AddCloud(if Red_Candle then Double.NEGATIVE_INFINITY else High_Red_Line,if Red_Candle then Double.NEGATIVE_INFINITY else Open_Red_Line,color.RED);
AddCloud(if Green_Candle then Double.NEGATIVE_INFINITY else Open_Green_Line,if Green_Candle then Double.NEGATIVE_INFINITY else Low_Green_Line,color.GREEN);

###############################################################################
###############################################################################
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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