@halcyonguy
Thank you for the code,
I have updated the code further as commented, i am getting error, please review and let me know is there anything i can work on that, here i can do only copy and paste with number update, i do not know any strategy in coding, so please check the below updated code and guide us if anythind i can do further.
####################################################################################################
# Poorman_volume_profile_01
# not complete
# data for 5 of 40 rows , 0 to 3 , 39
# 35 sets of formulas need to be created, in 7 sections
# look for these lines and add code
# add codes for 4 to 38 ////////////////////////////
#
https://usethinkscript.com/threads/convert-tradingview-poor-mans-volume-profile.14460/
#Tradingview Convert Tradingview Poor man's volume profile
#Rrm411 2/12
#Could anyone help us to get this indicator in TOS, I found this indicator is very useful for day trade.
#@samer800
@BenTen Please help us to get this Indicator in TOS, Thanks in advance.
#Poor man's volume profile
#
https://www.tradingview.com/script/IWdpl712-Poor-man-s-volume-profile/
#1100 lines
#// © Ildar Akhmetgaleev (AkhIL)
#// See
https://github.com/akhilman/vol-poorofile
#// vim: shiftwidth=2 tabstop=2
#study("Poor man's volume profile", "PMVolProf", overlay=true, max_bars_back=500)
def na = double.nan;
def bn = barnumber();
def lastbn = HighestAll(If(IsNaN(close), 0, bn));
def lastbar = if (bn == lastbn) then 1 else 0;
#def lastbar = !isnan(close[0]) and isnan(close[-1]);
def minb = 10;
def maxb = 500;
input block_size2 = 200;
def block_size = if block_size2 < minb then minb else if block_size2 > maxb then maxb else block_size2;
input visual_row_width = 50;
input show_peaks = yes;
addlabel(1, "look " + block_size + " bars back", color.yellow);
input show_vert_line_range_start = yes;
def first = (!isnan(close[-block_size]) and isnan(close[-(block_size+1)]));
addverticalline(show_vert_line_range_start and first, "-", color.cyan);
#// Calculate profile
def block_high = highest(high, block_size);
def block_low = lowest(low, block_size);
def highest_row_value = 0;
# data to collect
# count bars in a range
#def data = 1;
# convert volume to millions
#def data = volume/1000000;
# convert volume to 1000s
def data = volume/1000;
# do stuff on last bar
def row_qty = 40;
def block_height = block_high - block_low;
def row_height = block_height / row_qty;
# chg first values to 1, so no divide by 0 err
def k = 1;
def r00lo = if bn == 1 then k else if lastbar then (block_low + row_height * 0) else r00lo[1];
def r00hi = if bn == 1 then k else if lastbar then (block_low + row_height * 1) else r00hi[1];
def r01lo = if bn == 1 then k else if lastbar then (block_low + row_height * 1) else r01lo[1];
def r01hi = if bn == 1 then k else if lastbar then (block_low + row_height * 2) else r01hi[1];
def r02lo = if bn == 1 then k else if lastbar then (block_low + row_height * 2) else r02lo[1];
def r02hi = if bn == 1 then k else if lastbar then (block_low + row_height * 3) else r02hi[1];
def r03lo = if bn == 1 then k else if lastbar then (block_low + row_height * 3) else r03lo[1];
def r03hi = if bn == 1 then k else if lastbar then (block_low + row_height * 4) else r03hi[1];
def r04lo = if bn == 1 then k else if lastbar then (block_low + row_height * 4) else r04lo[1];
def r04hi = if bn == 1 then k else if lastbar then (block_low + row_height * 5) else r04hi[1];
def r05lo = if bn == 1 then k else if lastbar then (block_low + row_height * 5) else r05lo[1];
def r05hi = if bn == 1 then k else if lastbar then (block_low + row_height * 6) else r05hi[1];
def r06lo = if bn == 1 then k else if lastbar then (block_low + row_height * 6) else r06lo[1];
def r06hi = if bn == 1 then k else if lastbar then (block_low + row_height * 7) else r06hi[1];
def r07lo = if bn == 1 then k else if lastbar then (block_low + row_height * 7) else r07lo[1];
def r07hi = if bn == 1 then k else if lastbar then (block_low + row_height * 8) else r07hi[1];
def r08lo = if bn == 1 then k else if lastbar then (block_low + row_height * 8) else r08lo[1];
def r08hi = if bn == 1 then k else if lastbar then (block_low + row_height * 9) else r08hi[1];
def r09lo = if bn == 1 then k else if lastbar then (block_low + row_height * 9) else r09lo[1];
def r09hi = if bn == 1 then k else if lastbar then (block_low + row_height * 10) else r09hi[1];
def r10lo = if bn == 1 then k else if lastbar then (block_low + row_height * 10) else r10lo[1];
def r10hi = if bn == 1 then k else if lastbar then (block_low + row_height * 11) else r10hi[1];
def r11lo = if bn == 1 then k else if lastbar then (block_low + row_height * 11) else r11lo[1];
def r11hi = if bn == 1 then k else if lastbar then (block_low + row_height * 12) else r11hi[1];
def r12lo = if bn == 1 then k else if lastbar then (block_low + row_height * 12) else r12lo[1];
def r12hi = if bn == 1 then k else if lastbar then (block_low + row_height * 13) else r12hi[1];
def r13lo = if bn == 1 then k else if lastbar then (block_low + row_height * 13) else r13lo[1];
def r13hi = if bn == 1 then k else if lastbar then (block_low + row_height * 14) else r13hi[1];
def r14lo = if bn == 1 then k else if lastbar then (block_low + row_height * 14) else r14lo[1];
def r14hi = if bn == 1 then k else if lastbar then (block_low + row_height * 15) else r14hi[1];
def r15lo = if bn == 1 then k else if lastbar then (block_low + row_height * 15) else r15lo[1];
def r15hi = if bn == 1 then k else if lastbar then (block_low + row_height * 16) else r15hi[1];
def r16lo = if bn == 1 then k else if lastbar then (block_low + row_height * 16) else r16lo[1];
def r16hi = if bn == 1 then k else if lastbar then (block_low + row_height * 17) else r16hi[1];
def r17lo = if bn == 1 then k else if lastbar then (block_low + row_height * 17) else r17lo[1];
def r17hi = if bn == 1 then k else if lastbar then (block_low + row_height * 18) else r17hi[1];
def r18lo = if bn == 1 then k else if lastbar then (block_low + row_height * 18) else r18lo[1];
def r18hi = if bn == 1 then k else if lastbar then (block_low + row_height * 19) else r18hi[1];
def r19lo = if bn == 1 then k else if lastbar then (block_low + row_height * 19) else r19lo[1];
def r19hi = if bn == 1 then k else if lastbar then (block_low + row_height * 20) else r19hi[1];
def r20lo = if bn == 1 then k else if lastbar then (block_low + row_height * 20) else r20lo[1];
def r20hi = if bn == 1 then k else if lastbar then (block_low + row_height * 21) else r20hi[1];
def r21lo = if bn == 1 then k else if lastbar then (block_low + row_height * 21) else r21lo[1];
def r21hi = if bn == 1 then k else if lastbar then (block_low + row_height * 22) else r21hi[1];
def r22lo = if bn == 1 then k else if lastbar then (block_low + row_height * 22) else r22lo[1];
def r22hi = if bn == 1 then k else if lastbar then (block_low + row_height * 23) else r22hi[1];
def r23lo = if bn == 1 then k else if lastbar then (block_low + row_height * 23) else r23lo[1];
def r23hi = if bn == 1 then k else if lastbar then (block_low + row_height * 24) else r23hi[1];
def r24lo = if bn == 1 then k else if lastbar then (block_low + row_height * 24) else r24lo[1];
def r24hi = if bn == 1 then k else if lastbar then (block_low + row_height * 25) else r24hi[1];
def r25lo = if bn == 1 then k else if lastbar then (block_low + row_height * 25) else r25lo[1];
def r25hi = if bn == 1 then k else if lastbar then (block_low + row_height * 26) else r25hi[1];
def r26lo = if bn == 1 then k else if lastbar then (block_low + row_height * 26) else r26lo[1];
def r26hi = if bn == 1 then k else if lastbar then (block_low + row_height * 27) else r26hi[1];
def r27lo = if bn == 1 then k else if lastbar then (block_low + row_height * 27) else r27lo[1];
def r27hi = if bn == 1 then k else if lastbar then (block_low + row_height * 28) else r27hi[1];
def r28lo = if bn == 1 then k else if lastbar then (block_low + row_height * 28) else r28lo[1];
def r28hi = if bn == 1 then k else if lastbar then (block_low + row_height * 29) else r28hi[1];
def r29lo = if bn == 1 then k else if lastbar then (block_low + row_height * 29) else r29lo[1];
def r29hi = if bn == 1 then k else if lastbar then (block_low + row_height * 30) else r29hi[1];
def r30lo = if bn == 1 then k else if lastbar then (block_low + row_height * 30) else r30lo[1];
def r30hi = if bn == 1 then k else if lastbar then (block_low + row_height * 31) else r30hi[1];
def r31lo = if bn == 1 then k else if lastbar then (block_low + row_height * 31) else r31lo[1];
def r31hi = if bn == 1 then k else if lastbar then (block_low + row_height * 32) else r31hi[1];
def r32lo = if bn == 1 then k else if lastbar then (block_low + row_height * 32) else r32lo[1];
def r32hi = if bn == 1 then k else if lastbar then (block_low + row_height * 33) else r32hi[1];
def r33lo = if bn == 1 then k else if lastbar then (block_low + row_height * 33) else r33lo[1];
def r33hi = if bn == 1 then k else if lastbar then (block_low + row_height * 34) else r33hi[1];
def r34lo = if bn == 1 then k else if lastbar then (block_low + row_height * 34) else r34lo[1];
def r34hi = if bn == 1 then k else if lastbar then (block_low + row_height * 35) else r34hi[1];
def r35lo = if bn == 1 then k else if lastbar then (block_low + row_height * 35) else r35lo[1];
def r35hi = if bn == 1 then k else if lastbar then (block_low + row_height * 36) else r35hi[1];
def r36lo = if bn == 1 then k else if lastbar then (block_low + row_height * 36) else r36lo[1];
def r36hi = if bn == 1 then k else if lastbar then (block_low + row_height * 37) else r36hi[1];
def r37lo = if bn == 1 then k else if lastbar then (block_low + row_height * 37) else r37lo[1];
def r37hi = if bn == 1 then k else if lastbar then (block_low + row_height * 38) else r37hi[1];
def r38lo = if bn == 1 then k else if lastbar then (block_low + row_height * 38) else r38lo[1];
def r38hi = if bn == 1 then k else if lastbar then (block_low + row_height * 39) else r38hi[1];
def r39lo = if bn == 1 then k else if lastbar then (block_low + row_height * 39) else r39lo[1];
def r39hi = if bn == 1 then k else if lastbar then (block_low + row_height * 40) else r39hi[1];
def r00mid = (r00hi + r00lo)/2;
def r01mid = (r01hi + r01lo)/2;
def r02mid = (r02hi + r02lo)/2;
def r03mid = (r03hi + r03lo)/2;
def r04mid = (r04hi + r04lo)/2;
def r05mid = (r05hi + r05lo)/2;
def r06mid = (r06hi + r06lo)/2;
def r07mid = (r07hi + r07lo)/2;
def r08mid = (r08hi + r08lo)/2;
def r09mid = (r09hi + r09lo)/2;
def r10mid = (r10hi + r10lo)/2;
def r11mid = (r11hi + r11lo)/2;
def r12mid = (r12hi + r12lo)/2;
def r13mid = (r13hi + r13lo)/2;
def r14mid = (r14hi + r14lo)/2;
def r15mid = (r15hi + r15lo)/2;
def r16mid = (r16hi + r16lo)/2;
def r17mid = (r17hi + r17lo)/2;
def r18mid = (r18hi + r18lo)/2;
def r19mid = (r19hi + r19lo)/2;
def r20mid = (r20hi + r20lo)/2;
def r21mid = (r21hi + r21lo)/2;
def r22mid = (r22hi + r22lo)/2;
def r23mid = (r23hi + r23lo)/2;
def r24mid = (r24hi + r24lo)/2;
def r25mid = (r25hi + r25lo)/2;
def r26mid = (r26hi + r26lo)/2;
def r27mid = (r27hi + r27lo)/2;
def r28mid = (r28hi + r28lo)/2;
def r29mid = (r29hi + r29lo)/2;
def r30mid = (r30hi + r30lo)/2;
def r31mid = (r31hi + r31lo)/2;
def r32mid = (r32hi + r32lo)/2;
def r33mid = (r33hi + r33lo)/2;
def r34mid = (r34hi + r34lo)/2;
def r35mid = (r35hi + r35lo)/2;
def r36mid = (r36hi + r36lo)/2;
def r37mid = (r37hi + r37lo)/2;
def r38mid = (r38hi + r38lo)/2;
def r39mid = (r39hi + r39lo)/2;
# on last bar,
# look back at prev bars, to see if part of them were within a price row range,
# if so, then add the data from that bar , volume
def m = 1;
def r00cnt = if bn == 1 then m else if lastbar then fold i0 = 0 to block_size
with p0
do p0 + (if getvalue(low, i0) < r00hi and getvalue(high,i0) > r00lo then getvalue(data,i0) else 0)
else r00cnt[1];
def r01cnt = if bn == 1 then m else if lastbar then fold i1 = 0 to block_size
with p1
do p1 + (if getvalue(low, i1) < r01hi and getvalue(high,i1) > r01lo then getvalue(data,i1) else 0)
else r01cnt[1];
def r02cnt = if bn == 1 then m else if lastbar then fold i2 = 0 to block_size
with p2
do p2 + (if getvalue(low, i2) < r02hi and getvalue(high,i2) > r02lo then getvalue(data,i2) else 0)
else r02cnt[1];
def r03cnt = if bn == 1 then m else if lastbar then fold i3 = 0 to block_size
with p3
do p3 + (if getvalue(low, i3) < r03hi and getvalue(high,i3) > r03lo then getvalue(data,i3) else 0)
else r03cnt[1];
def r04cnt = if bn == 1 then m else if lastbar then fold i4 = 0 to block_size
with p4
do p4 + (if getvalue(low, i4) < r04hi and getvalue(high,i4) > r04lo then getvalue(data,i4) else 0)
else r04cnt[1];
def r05cnt = if bn == 1 then m else if lastbar then fold i5 = 0 to block_size
with p5
do p5 + (if getvalue(low, i5) < r05hi and getvalue(high,i5) > r05lo then getvalue(data,i5) else 0)
else r05cnt[1];
def r06cnt = if bn == 1 then m else if lastbar then fold i6 = 0 to block_size
with p6
do p6 + (if getvalue(low, i6) < r06hi and getvalue(high,i6) > r06lo then getvalue(data,i6) else 0)
else r06cnt[1];
def r07cnt = if bn == 1 then m else if lastbar then fold i7 = 0 to block_size
with p7
do p7 + (if getvalue(low, i7) < r07hi and getvalue(high,i7) > r07lo then getvalue(data,i7) else 0)
else r07cnt[1];
def r08cnt = if bn == 1 then m else if lastbar then fold i8 = 0 to block_size
with p8
do p8 + (if getvalue(low, i8) < r08hi and getvalue(high,i8) > r08lo then getvalue(data,i8) else 0)
else r08cnt[1];
def r09cnt = if bn == 1 then m else if lastbar then fold i9 = 0 to block_size
with p9
do p9 + (if getvalue(low, i9) < r09hi and getvalue(high,i9) > r09lo then getvalue(data,i9) else 0)
else r09cnt[1];
def r10cnt = if bn == 1 then m else if lastbar then fold i10 = 0 to block_size
with p10
do p10 + (if getvalue(low, i10) < r10hi and getvalue(high,i10) > r10lo then getvalue(data,i10) else 0)
else r10cnt[1];
def r11cnt = if bn == 1 then m else if lastbar then fold i11 = 0 to block_size
with p11
do p11 + (if getvalue(low, i11) < r11hi and getvalue(high,i11) > r11lo then getvalue(data,i11) else 0)
else r11cnt[1];
def r12cnt = if bn == 1 then m else if lastbar then fold i12 = 0 to block_size
with p12
do p12 + (if getvalue(low, i12) < r12hi and getvalue(high,i12) > r12lo then getvalue(data,i12) else 0)
else r12cnt[1];
def r13cnt = if bn == 1 then m else if lastbar then fold i13 = 0 to block_size
with p13
do p13 + (if getvalue(low, i13) < r13hi and getvalue(high,i13) > r13lo then getvalue(data,i13) else 0)
else r13cnt[1];
def r14cnt = if bn == 1 then m else if lastbar then fold i14 = 0 to block_size
with p14
do p14 + (if getvalue(low, i14) < r14hi and getvalue(high,i14) > r14lo then getvalue(data,i14) else 0)
else r14cnt[1];
def r15cnt = if bn == 1 then m else if lastbar then fold i15 = 0 to block_size
with p15
do p15 + (if getvalue(low, i15) < r15hi and getvalue(high,i15) > r15lo then getvalue(data,i15) else 0)
else r15cnt[1];
def r16cnt = if bn == 1 then m else if lastbar then fold i16 = 0 to block_size
with p16
do p16 + (if getvalue(low, i16) < r16hi and getvalue(high,i16) > r16lo then getvalue(data,i16) else 0)
else r16cnt[1];
def r17cnt = if bn == 1 then m else if lastbar then fold i17 = 0 to block_size
with p17
do p17 + (if getvalue(low, i17) < r17hi and getvalue(high,i17) > r17lo then getvalue(data,i17) else 0)
else r17cnt[1];
def r18cnt = if bn == 1 then m else if lastbar then fold i18 = 0 to block_size
with p18
do p18 + (if getvalue(low, i18) < r18hi and getvalue(high,i18) > r18lo then getvalue(data,i18) else 0)
else r18cnt[1];
def r19cnt = if bn == 1 then m else if lastbar then fold i19 = 0 to block_size
with p19
do p19 + (if getvalue(low, i19) < r19hi and getvalue(high,i19) > r19lo then getvalue(data,i19) else 0)
else r19cnt[1];
def r20cnt = if bn == 1 then m else if lastbar then fold i20 = 0 to block_size
with p20
do p20 + (if getvalue(low, i20) < r20hi and getvalue(high,i20) > r20lo then getvalue(data,i20) else 0)
else r20cnt[1];
def r21cnt = if bn == 1 then m else if lastbar then fold i21 = 0 to block_size
with p21
do p21 + (if getvalue(low, i21) < r21hi and getvalue(high,i21) > r21lo then getvalue(data,i21) else 0)
else r21cnt[1];
def r22cnt = if bn == 1 then m else if lastbar then fold i22 = 0 to block_size
with p22
do p22 + (if getvalue(low, i22) < r22hi and getvalue(high,i22) > r22lo then getvalue(data,i22) else 0)
else r22cnt[1];
def r23cnt = if bn == 1 then m else if lastbar then fold i23 = 0 to block_size
with p23
do p23 + (if getvalue(low, i23) < r23hi and getvalue(high,i23) > r23lo then getvalue(data,i23) else 0)
else r23cnt[1];
def r24cnt = if bn == 1 then m else if lastbar then fold i24 = 0 to block_size
with p24
do p24 + (if getvalue(low, i24) < r24hi and getvalue(high,i24) > r24lo then getvalue(data,i24) else 0)
else r24cnt[1];
def r25cnt = if bn == 1 then m else if lastbar then fold i25 = 0 to block_size
with p25
do p25 + (if getvalue(low, i25) < r25hi and getvalue(high,i25) > r25lo then getvalue(data,i25) else 0)
else r25cnt[1];
def r26cnt = if bn == 1 then m else if lastbar then fold i26 = 0 to block_size
with p26
do p26 + (if getvalue(low, i26) < r26hi and getvalue(high,i26) > r26lo then getvalue(data,i26) else 0)
else r26cnt[1];
def r27cnt = if bn == 1 then m else if lastbar then fold i27 = 0 to block_size
with p27
do p27 + (if getvalue(low, i27) < r27hi and getvalue(high,i27) > r27lo then getvalue(data,i27) else 0)
else r27cnt[1];
def r28cnt = if bn == 1 then m else if lastbar then fold i28 = 0 to block_size
with p28
do p28 + (if getvalue(low, i28) < r28hi and getvalue(high,i28) > r28lo then getvalue(data,i28) else 0)
else r28cnt[1];
def r29cnt = if bn == 1 then m else if lastbar then fold i29 = 0 to block_size
with p29
do p29 + (if getvalue(low, i29) < r29hi and getvalue(high,i29) > r29lo then getvalue(data,i29) else 0)
else r29cnt[1];
def r30cnt = if bn == 1 then m else if lastbar then fold i30 = 0 to block_size
with p30
do p30 + (if getvalue(low, i30) < r30hi and getvalue(high,i30) > r30lo then getvalue(data,i30) else 0)
else r30cnt[1];
def r31cnt = if bn == 1 then m else if lastbar then fold i31 = 0 to block_size
with p31
do p31 + (if getvalue(low, i31) < r31hi and getvalue(high,i31) > r31lo then getvalue(data,i31) else 0)
else r31cnt[1];
def r32cnt = if bn == 1 then m else if lastbar then fold i32 = 0 to block_size
with p32
do p32 + (if getvalue(low, i32) < r32hi and getvalue(high,i32) > r32lo then getvalue(data,i32) else 0)
else r32cnt[1];
def r33cnt = if bn == 1 then m else if lastbar then fold i33 = 0 to block_size
with p33
do p33 + (if getvalue(low, i33) < r33hi and getvalue(high,i33) > r33lo then getvalue(data,i33) else 0)
else r33cnt[1];
def r34cnt = if bn == 1 then m else if lastbar then fold i34 = 0 to block_size
with p34
do p34 + (if getvalue(low, i34) < r34hi and getvalue(high,i34) > r34lo then getvalue(data,i34) else 0)
else r34cnt[1];
def r35cnt = if bn == 1 then m else if lastbar then fold i35 = 0 to block_size
with p35
do p35 + (if getvalue(low, i35) < r35hi and getvalue(high,i35) > r35lo then getvalue(data,i35) else 0)
else r35cnt[1];
def r36cnt = if bn == 1 then m else if lastbar then fold i36 = 0 to block_size
with p36
do p36 + (if getvalue(low, i36) < r36hi and getvalue(high,i36) > r36lo then getvalue(data,i36) else 0)
else r36cnt[1];
def r37cnt = if bn == 1 then m else if lastbar then fold i37 = 0 to block_size
with p37
do p37 + (if getvalue(low, i37) < r37hi and getvalue(high,i37) > r37lo then getvalue(data,i37) else 0)
else r37cnt[1];
def r38cnt = if bn == 1 then m else if lastbar then fold i38 = 0 to block_size
with p38
do p38 + (if getvalue(low, i38) < r38hi and getvalue(high,i38) > r38lo then getvalue(data,i38) else 0)
else r38cnt[1];
def r39cnt = if bn == 1 then m else if lastbar then fold i39 = 0 to block_size
with p39
do p39 + (if getvalue(low, i39) < r39hi and getvalue(high,i39) > r39lo then getvalue(data,i39) else 0)
else r39cnt[1];
# find max data sum
def maxdata = max(r00cnt, max(r01cnt, max(r02cnt, max(r03cnt, max(r04cnt, max(r05cnt, max(r06cnt, max(r07cnt, max(r08cnt, max(r09cnt, max(r10cnt, max(r11cnt, max(r12cnt, max(r13cnt, max(r14cnt, max(r15cnt, max(r16cnt, max(r17cnt, max(r18cnt, max(r19cnt, max(r20cnt, max(r21cnt, max(r22cnt, max(r23cnt, max(r24cnt, max(r25cnt, max(r26cnt, max(r27cnt, max(r28cnt, max(r29cnt, max(r30cnt, max(r31cnt, max(r32cnt, max(r33cnt, max(r34cnt, max(r35cnt, max(r36cnt, max(r37cnt, max(r38cnt, r39cnt)))))))))))))))))))))))))))))))))))))));
# calc ratio of cnt to highest cnt , a bar cnt , for the horz length of each row
def r00r = floor(visual_row_width * r00cnt / maxdata);
def r01r = floor(visual_row_width * r01cnt / maxdata);
def r02r = floor(visual_row_width * r02cnt / maxdata);
def r03r = floor(visual_row_width * r03cnt / maxdata);
def r04r = floor(visual_row_width * r04cnt / maxdata);
def r05r = floor(visual_row_width * r05cnt / maxdata);
def r06r = floor(visual_row_width * r06cnt / maxdata);
def r07r = floor(visual_row_width * r07cnt / maxdata);
def r08r = floor(visual_row_width * r08cnt / maxdata);
def r09r = floor(visual_row_width * r09cnt / maxdata);
def r10r = floor(visual_row_width * r10cnt / maxdata);
def r11r = floor(visual_row_width * r11cnt / maxdata);
def r12r = floor(visual_row_width * r12cnt / maxdata);
def r13r = floor(visual_row_width * r13cnt / maxdata);
def r14r = floor(visual_row_width * r14cnt / maxdata);
def r15r = floor(visual_row_width * r15cnt / maxdata);
def r16r = floor(visual_row_width * r16cnt / maxdata);
def r17r = floor(visual_row_width * r17cnt / maxdata);
def r18r = floor(visual_row_width * r18cnt / maxdata);
def r19r = floor(visual_row_width * r19cnt / maxdata);
def r20r = floor(visual_row_width * r20cnt / maxdata);
def r21r = floor(visual_row_width * r21cnt / maxdata);
def r22r = floor(visual_row_width * r22cnt / maxdata);
def r23r = floor(visual_row_width * r23cnt / maxdata);
def r24r = floor(visual_row_width * r24cnt / maxdata);
def r25r = floor(visual_row_width * r25cnt / maxdata);
def r26r = floor(visual_row_width * r26cnt / maxdata);
def r27r = floor(visual_row_width * r27cnt / maxdata);
def r28r = floor(visual_row_width * r28cnt / maxdata);
def r29r = floor(visual_row_width * r29cnt / maxdata);
def r30r = floor(visual_row_width * r30cnt / maxdata);
def r31r = floor(visual_row_width * r31cnt / maxdata);
def r32r = floor(visual_row_width * r32cnt / maxdata);
def r33r = floor(visual_row_width * r33cnt / maxdata);
def r34r = floor(visual_row_width * r34cnt / maxdata);
def r35r = floor(visual_row_width * r35cnt / maxdata);
def r36r = floor(visual_row_width * r36cnt / maxdata);
def r37r = floor(visual_row_width * r37cnt / maxdata);
def r38r = floor(visual_row_width * r38cnt / maxdata);
def r39r = floor(visual_row_width * r39cnt / maxdata);
#// Draw profile
# draw rows on bars after the last bar
# mark bars after lastbar as true, if the ratio cnt of bars .....
def x0 = (bn > lastbn and bn <= (lastbn + r00r));
def x1 = (bn > lastbn and bn <= (lastbn + r01r));
def x2 = (bn > lastbn and bn <= (lastbn + r02r));
def x3 = (bn > lastbn and bn <= (lastbn + r03r));
def x4 = (bn > lastbn and bn <= (lastbn + r04r));
def x5 = (bn > lastbn and bn <= (lastbn + r05r));
def x6 = (bn > lastbn and bn <= (lastbn + r06r));
def x7 = (bn > lastbn and bn <= (lastbn + r07r));
def x8 = (bn > lastbn and bn <= (lastbn + r08r));
def x9 = (bn > lastbn and bn <= (lastbn + r09r));
def x10 = (bn > lastbn and bn <= (lastbn + r010r));
def x11 = (bn > lastbn and bn <= (lastbn + r011r));
def x12 = (bn > lastbn and bn <= (lastbn + r012r));
def x13 = (bn > lastbn and bn <= (lastbn + r013r));
def x14 = (bn > lastbn and bn <= (lastbn + r014r));
def x15 = (bn > lastbn and bn <= (lastbn + r015r));
def x16 = (bn > lastbn and bn <= (lastbn + r016r));
def x17 = (bn > lastbn and bn <= (lastbn + r017r));
def x18 = (bn > lastbn and bn <= (lastbn + r018r));
def x19 = (bn > lastbn and bn <= (lastbn + r019r));
def x20 = (bn > lastbn and bn <= (lastbn + r020r));
def x21 = (bn > lastbn and bn <= (lastbn + r021r));
def x22 = (bn > lastbn and bn <= (lastbn + r022r));
def x23 = (bn > lastbn and bn <= (lastbn + r023r));
def x24 = (bn > lastbn and bn <= (lastbn + r024r));
def x25 = (bn > lastbn and bn <= (lastbn + r025r));
def x26 = (bn > lastbn and bn <= (lastbn + r026r));
def x27 = (bn > lastbn and bn <= (lastbn + r027r));
def x28 = (bn > lastbn and bn <= (lastbn + r028r));
def x29 = (bn > lastbn and bn <= (lastbn + r029r));
def x30 = (bn > lastbn and bn <= (lastbn + r030r));
def x31 = (bn > lastbn and bn <= (lastbn + r031r));
def x32 = (bn > lastbn and bn <= (lastbn + r032r));
def x33 = (bn > lastbn and bn <= (lastbn + r033r));
def x34 = (bn > lastbn and bn <= (lastbn + r034r));
def x35 = (bn > lastbn and bn <= (lastbn + r035r));
def x36 = (bn > lastbn and bn <= (lastbn + r036r));
def x37 = (bn > lastbn and bn <= (lastbn + r037r));
def x38 = (bn > lastbn and bn <= (lastbn + r038r));
def x39 = (bn > lastbn and bn <= (lastbn + r39r));
input line_thick = 2;
input show_lines_wsquares = yes;
plot z0 = if show_lines_wsquares and x0 then r00mid else na;
z0.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z0.SetDefaultColor(Color.gray);
z0.setlineweight(line_thick);
z0.hidebubble();
plot z1 = if show_lines_wsquares and x1 then r01mid else na;
z1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z1.SetDefaultColor(Color.gray);
z1.setlineweight(line_thick);
z1.hidebubble();
plot z2 = if show_lines_wsquares and x2 then r02mid else na;
z2.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z2.SetDefaultColor(Color.gray);
z2.setlineweight(line_thick);
z2.hidebubble();
plot z3 = if show_lines_wsquares and x3 then r03mid else na;
z3.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z3.SetDefaultColor(Color.gray);
z3.setlineweight(line_thick);
z3.hidebubble();
plot z4 = if show_lines_wsquares and x4 then r04mid else na;
z4.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z4.SetDefaultColor(Color.gray);
z4.setlineweight(line_thick);
z4.hidebubble();
plot z5 = if show_lines_wsquares and x5 then r05mid else na;
z5.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z5.SetDefaultColor(Color.gray);
z5.setlineweight(line_thick);
z5.hidebubble();
plot z6 = if show_lines_wsquares and x6 then r06mid else na;
z6.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z6.SetDefaultColor(Color.gray);
z6.setlineweight(line_thick);
z6.hidebubble();
plot z7 = if show_lines_wsquares and x7 then r07mid else na;
z7.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z7.SetDefaultColor(Color.gray);
z7.setlineweight(line_thick);
z7.hidebubble();
plot z8 = if show_lines_wsquares and x8 then r08mid else na;
z8.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z8.SetDefaultColor(Color.gray);
z8.setlineweight(line_thick);
z8.hidebubble();
plot z9 = if show_lines_wsquares and x9 then r09mid else na;
z9.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z9.SetDefaultColor(Color.gray);
z9.setlineweight(line_thick);
z9.hidebubble();
plot z10 = if show_lines_wsquares and x10 then r010mid else na;
z10.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z10.SetDefaultColor(Color.gray);
z10.setlineweight(line_thick);
z10.hidebubble();
plot z11 = if show_lines_wsquares and x11 then r011mid else na;
z11.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z11.SetDefaultColor(Color.gray);
z11.setlineweight(line_thick);
z11.hidebubble();
plot z12 = if show_lines_wsquares and x12 then r012mid else na;
z12.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z12.SetDefaultColor(Color.gray);
z12.setlineweight(line_thick);
z12.hidebubble();
plot z13 = if show_lines_wsquares and x13 then r013mid else na;
z13.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z13.SetDefaultColor(Color.gray);
z13.setlineweight(line_thick);
z13.hidebubble();
plot z14 = if show_lines_wsquares and x14 then r014mid else na;
z14.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z14.SetDefaultColor(Color.gray);
z14.setlineweight(line_thick);
z14.hidebubble();
plot z15 = if show_lines_wsquares and x15 then r015mid else na;
z15.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z15.SetDefaultColor(Color.gray);
z15.setlineweight(line_thick);
z15.hidebubble();
plot z16 = if show_lines_wsquares and x16 then r016mid else na;
z16.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z16.SetDefaultColor(Color.gray);
z16.setlineweight(line_thick);
z16.hidebubble();
plot z17 = if show_lines_wsquares and x17 then r017mid else na;
z17.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z17.SetDefaultColor(Color.gray);
z17.setlineweight(line_thick);
z17.hidebubble();
plot z18 = if show_lines_wsquares and x18 then r018mid else na;
z18.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z18.SetDefaultColor(Color.gray);
z18.setlineweight(line_thick);
z18.hidebubble();
plot z19 = if show_lines_wsquares and x19 then r019mid else na;
z19.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z19.SetDefaultColor(Color.gray);
z19.setlineweight(line_thick);
z19.hidebubble();
plot z20 = if show_lines_wsquares and x20 then r020mid else na;
z20.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z20.SetDefaultColor(Color.gray);
z20.setlineweight(line_thick);
z20.hidebubble();
plot z21 = if show_lines_wsquares and x21 then r021mid else na;
z21.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z21.SetDefaultColor(Color.gray);
z21.setlineweight(line_thick);
z21.hidebubble();
plot z22 = if show_lines_wsquares and x22 then r022mid else na;
z22.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z22.SetDefaultColor(Color.gray);
z22.setlineweight(line_thick);
z22.hidebubble();
plot z23 = if show_lines_wsquares and x23 then r023mid else na;
z23.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z23.SetDefaultColor(Color.gray);
z23.setlineweight(line_thick);
z23.hidebubble();
plot z24 = if show_lines_wsquares and x24 then r024mid else na;
z24.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z24.SetDefaultColor(Color.gray);
z24.setlineweight(line_thick);
z24.hidebubble();
plot z25 = if show_lines_wsquares and x25 then r025mid else na;
z25.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z25.SetDefaultColor(Color.gray);
z25.setlineweight(line_thick);
z25.hidebubble();
plot z26 = if show_lines_wsquares and x26 then r026mid else na;
z26.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z26.SetDefaultColor(Color.gray);
z26.setlineweight(line_thick);
z26.hidebubble();
plot z27 = if show_lines_wsquares and x27 then r027mid else na;
z27.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z27.SetDefaultColor(Color.gray);
z27.setlineweight(line_thick);
z27.hidebubble();
plot z28 = if show_lines_wsquares and x28 then r028mid else na;
z28.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z28.SetDefaultColor(Color.gray);
z28.setlineweight(line_thick);
z28.hidebubble();
plot z29 = if show_lines_wsquares and x29 then r029mid else na;
z29.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z29.SetDefaultColor(Color.gray);
z29.setlineweight(line_thick);
z29.hidebubble();
plot z30 = if show_lines_wsquares and x30 then r030mid else na;
z30.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z30.SetDefaultColor(Color.gray);
z30.setlineweight(line_thick);
z30.hidebubble();
plot z31 = if show_lines_wsquares and x31 then r031mid else na;
z31.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z31.SetDefaultColor(Color.gray);
z31.setlineweight(line_thick);
z31.hidebubble();
plot z32 = if show_lines_wsquares and x32 then r032mid else na;
z32.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z32.SetDefaultColor(Color.gray);
z32.setlineweight(line_thick);
z32.hidebubble();
plot z33 = if show_lines_wsquares and x33 then r033mid else na;
z33.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z33.SetDefaultColor(Color.gray);
z33.setlineweight(line_thick);
z33.hidebubble();
plot z34 = if show_lines_wsquares and x34 then r034mid else na;
z34.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z34.SetDefaultColor(Color.gray);
z34.setlineweight(line_thick);
z34.hidebubble();
plot z35 = if show_lines_wsquares and x35 then r035mid else na;
z35.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z35.SetDefaultColor(Color.gray);
z35.setlineweight(line_thick);
z35.hidebubble();
plot z36 = if show_lines_wsquares and x36 then r036mid else na;
z36.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z36.SetDefaultColor(Color.gray);
z36.setlineweight(line_thick);
z36.hidebubble();
plot z37 = if show_lines_wsquares and x37 then r037mid else na;
z37.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z37.SetDefaultColor(Color.gray);
z37.setlineweight(line_thick);
z37.hidebubble();
plot z38 = if show_lines_wsquares and x38 then r038mid else na;
z38.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z38.SetDefaultColor(Color.gray);
z38.setlineweight(line_thick);
z38.hidebubble();
plot z39 = if show_lines_wsquares and x39 then r39mid else na;
z39.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
z39.SetDefaultColor(Color.gray);
z39.setlineweight(line_thick);
z39.hidebubble();
#---------------------------
# test stuff
input test1 = no;
addchartbubble(test1, 82,
bn + "\n" +
lastbn + "\n" +
maxdata + "\n" +
r00cnt + "\n" +
r00r + "\n" +
#visual_row_width + "\n" +
floor(r00cnt / maxdata) + "\n" +
x0
, color.yellow, no);
#