ใช้เครื่องมือนี้ เพื่อแสดงรูปกราฟปริมาณการซื้อขาย ให้เราเห็นกันแบบชัดๆไปเลย ด้วย Volume Profile Histogram เอาตรงๆ ดูแบบนี้มันก็เข้าใจง่ายดีเหมือนกันนะเนี่ย

  • เทคนิคที่ใช้:
    • นำเสนอปริมาณการซื้อขายในรูปแบบของกราฟแบบเบลล์เคิร์ฟ/ฮิสโตแกรม
    • แยกปริมาณการซื้อและขายออกจากกัน โดยการขายถูกจัดเป็นการขายเมื่อราคาเปิดสูงกว่าราคาปิด และการซื้อเมื่อราคาปิดสูงกว่าราคาเปิด
    • จัดเรียงปริมาณการซื้อขายตามช่วงราคา และให้ข้อมูลจุดควบคุมของการซื้อขาย (POCs) ซึ่งคือพื้นที่ที่มีปริมาณการซื้อขายสูง
    • ใช้ตารางความถี่เพื่อแสดงจำนวนการสังเกตในแต่ละช่วงราคา
    • มีการวิเคราะห์ช่วง ATR โดยใช้ปริมาณการซื้อขาย
  • สัญญาณซื้อเกิดเมื่อ:
    • จุดควบคุมของการซื้อ (Bullish POC) บ่งบอกถึงพื้นที่ที่มีการซื้อสูง
    • ราคาอยู่ในช่วงที่มีการซื้อสูงสะสมหรือเมื่อเกิดการเปลี่ยนแปลงชัดเจนในตารางความถี่
  • สัญญาณขายเกิดเมื่อ:
    • จุดควบคุมของการขาย (Bearish POC) บ่งบอกถึงพื้นที่ที่มีการขายสูง
    • ราคาอยู่ในช่วงที่มีการขายสูงสะสมหรือเมื่อเกิดการเปลี่ยนแปลงชัดเจนในตารางความถี่
  • ใช้งานในโปรแกรม TradingView https://www.tradingview.com/?aff_id=134641
  • เปิดบัญชีทดลอง: การเริ่มต้นของ Passive Income https://bit.ly/3Sdkir2
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//  /$$$$$$   /$$                                                         /$$                                            
// /$$__  $$ | $$                                                        | $$                                            
//| $$  \__//$$$$$$    /$$$$$$  /$$    /$$ /$$$$$$   /$$$$$$   /$$$$$$$ /$$$$$$    /$$$$$$  /$$    /$$ /$$$$$$   /$$$$$$$
//|  $$$$$$|_  $$_/   /$$__  $$|  $$  /$$//$$__  $$ /$$__  $$ /$$_____/|_  $$_/   /$$__  $$|  $$  /$$//$$__  $$ /$$_____/
// \____  $$ | $$    | $$$$$$$$ \  $$/$$/| $$$$$$$$| $$  \__/|  $$$$$$   | $$    | $$$$$$$$ \  $$/$$/| $$$$$$$$|  $$$$$$ 
// /$$  \ $$ | $$ /$$| $$_____/  \  $$$/ | $$_____/| $$       \____  $$  | $$ /$$| $$_____/  \  $$$/ | $$_____/ \____  $$
//|  $$$$$$/ |  $$$$/|  $$$$$$$   \  $/  |  $$$$$$$| $$       /$$$$$$$/  |  $$$$/|  $$$$$$$   \  $/  |  $$$$$$$ /$$$$$$$/
// \______/   \___/   \_______/    \_/    \_______/|__/      |_______/    \___/   \_______/    \_/    \_______/|_______/ 

/////////////////////////////////////////       ___________________             //////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////      /                   \            //////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////     /  _____        _____ \           //////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////    /  /     \      /     \  \         //////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// __/__/       \____/       \__\_____   //////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////|           ___________           ____|//////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// \_________/           \_________/     //////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////            \  /////// /               //////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////            \/////////                 //////////////////////////////////////////////////////////////////////////////////
// © Steversteves
//@version=5
indicator("Volume Profile Histogram [SS]")
import Steversteves/SPTS_StatsPakLib/4 as spts 

len =           input(252, "Lookback Length")
showtime =      input(true, "Show Start and End Time")
showpoc =       input(true, "Show Bullish and Bearish POC")
showfreq =      input(false, "Show Frequency Table")
rngbyvol =      input(false, "Show Range Analytics by Volume")

// Data Inputs 
cl_arr = array.new_float() 
vol_arr = array.new<float>() 
for i = 0 to len 
    array.push(cl_arr, close[i])
    vol_arr.push(volume[i]) 

max = array.max(cl_arr) 
min = array.min(cl_arr) 
sd = array.stdev(cl_arr) 
sd_halved = sd / 2 

a1_bull = array.new_float() 
a2_bull = array.new_float() 
a3_bull = array.new_float() 
a4_bull = array.new_float() 
a5_bull = array.new_float() 
a6_bull = array.new_float() 
a7_bull = array.new_float() 
a8_bull = array.new_float() 
a9_bull = array.new_float() 
a10_bull = array.new_float() 

a1_bear = array.new_float() 
a2_bear = array.new_float() 
a3_bear = array.new_float() 
a4_bear = array.new_float() 
a5_bear = array.new_float() 
a6_bear = array.new_float() 
a7_bear = array.new_float() 
a8_bear = array.new_float() 
a9_bear = array.new_float() 
a10_bear = array.new_float() 

a1_v = min + sd_halved 
a2_v = a1_v + sd_halved 
a3_v = a2_v + sd_halved
a4_v = a3_v + sd_halved
a5_v = a4_v + sd_halved 
a6_v = a5_v + sd_halved 
a7_v = a6_v + sd_halved 
a8_v = a7_v + sd_halved
a9_v = a8_v + sd_halved
a10_v = a9_v + sd_halved 

// strings 
string a1_values = str.tostring(math.round(min,2)) + " \n to \n" + str.tostring(math.round(a1_v,2))
string a2_values = str.tostring(math.round(a1_v,2)) + "\n to \n" + str.tostring(math.round(a2_v,2))
string a3_values = str.tostring(math.round(a2_v,2)) + "\n to \n" + str.tostring(math.round(a3_v,2))
string a4_values = str.tostring(math.round(a3_v,2)) + "\n to \n" + str.tostring(math.round(a4_v,2))
string a5_values = str.tostring(math.round(a4_v,2)) + "\n to \n " + str.tostring(math.round(a5_v,2))
string a6_values = str.tostring(math.round(a5_v,2)) + "\n to \n " + str.tostring(math.round(a6_v,2))
string a7_values = str.tostring(math.round(a6_v,2)) + "\n to \n " + str.tostring(math.round(a7_v,2))
string a8_values = str.tostring(math.round(a7_v,2)) + "\n to \n " + str.tostring(math.round(a8_v,2))
string a9_values = str.tostring(math.round(a8_v,2)) + "\n to \n " + str.tostring(math.round(a9_v,2))
string a10_values = str.tostring(math.round(a9_v,2)) + "\n to" + str.tostring(math.round(a10_v,2))

value_array = array.from(a1_values, a2_values, a3_values, a4_values, a5_values, a6_values, a7_values, a8_values, a9_values, a10_values) 
bullish = close > open 
bearish = open > close 

for i = 0 to array.size(cl_arr) - 1 
    if bullish[i] 
        if array.get(cl_arr, i) >= min and array.get(cl_arr, i) < a1_v
            array.push(a1_bull, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a1_v and array.get(cl_arr, i) < a2_v 
            array.push(a2_bull, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a2_v and array.get(cl_arr, i) < a3_v  
            array.push(a3_bull, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a3_v and array.get(cl_arr, i) < a4_v
            array.push(a4_bull, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a4_v and array.get(cl_arr, i) < a5_v 
            array.push(a5_bull, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a5_v and array.get(cl_arr, i) < a6_v 
            array.push(a6_bull, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a6_v and array.get(cl_arr, i) < a7_v 
            array.push(a7_bull, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a7_v and array.get(cl_arr, i) < a8_v 
            array.push(a8_bull, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a8_v and array.get(cl_arr, i) < a9_v 
            array.push(a9_bull, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a9_v 
            array.push(a10_bull, array.get(vol_arr, i))
    if bearish[i]         
        if array.get(cl_arr, i) >= min and array.get(cl_arr, i) < a1_v 
            array.push(a1_bear, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a1_v and array.get(cl_arr, i) < a2_v 
            array.push(a2_bear, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a2_v and array.get(cl_arr, i) < a3_v 
            array.push(a3_bear, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a3_v and array.get(cl_arr, i) < a4_v 
            array.push(a4_bear, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a4_v and array.get(cl_arr, i) < a5_v 
            array.push(a5_bear, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a5_v and array.get(cl_arr, i) < a6_v 
            array.push(a6_bear, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a6_v and array.get(cl_arr, i) < a7_v 
            array.push(a7_bear, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a7_v and array.get(cl_arr, i) < a8_v 
            array.push(a8_bear, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a8_v and array.get(cl_arr, i) < a9_v 
            array.push(a9_bear, array.get(vol_arr, i))
        else if array.get(cl_arr, i) >= a9_v 
            array.push(a10_bear, array.get(vol_arr, i))


bull_frequency = array.from(array.size(a1_bull), array.size(a2_bull), array.size(a3_bull), array.size(a4_bull), array.size(a5_bull), array.size(a6_bull), array.size(a7_bull), array.size(a8_bull), array.size(a9_bull), array.size(a10_bull)) 
bear_frequency = array.from(array.size(a1_bear), array.size(a2_bear), array.size(a3_bear), array.size(a4_bear), array.size(a5_bear), array.size(a6_bear), array.size(a7_bear), array.size(a8_bear), array.size(a9_bear), array.size(a10_bear)) 

if showfreq
    var table freq = table.new(position.middle_right, 5, 15, bgcolor = color.white, border_color = color.black, border_width = 2, frame_color = color.black, frame_width = 3)
    table.cell(freq, 1, 1, text = "Range", text_color = color.black, text_size = size.tiny) 
    table.cell(freq, 2, 1, text = "Bullish \n Frequency", text_color = color.lime, text_size = size.tiny) 
    table.cell(freq, 3, 1, text = "Bearish \n Frequency", text_color = color.red, text_size = size.tiny) 

    for i = 0 to 9
        table.cell(freq, 1, 2 + i,  text = str.tostring(array.get(value_array, i)), text_color = color.black) 
        table.cell(freq, 2, 2 + i,  text = str.tostring(array.get(bull_frequency, i)), text_color = color.black) 
        table.cell(freq, 3, 2 + i,  text = str.tostring(array.get(bear_frequency, i)), text_color = color.black) 


a1_bull_sum = array.sum(a1_bull),           a6_bull_sum = array.sum(a6_bull) 
a2_bull_sum = array.sum(a2_bull),           a7_bull_sum = array.sum(a7_bull) 
a3_bull_sum = array.sum(a3_bull),           a8_bull_sum = array.sum(a8_bull) 
a4_bull_sum = array.sum(a4_bull),           a9_bull_sum = array.sum(a9_bull) 
a5_bull_sum = array.sum(a5_bull),           a10_bull_sum = array.sum(a10_bull) 

a1_bear_sum = array.sum(a1_bear),           a6_bear_sum = array.sum(a6_bear) 
a2_bear_sum = array.sum(a2_bear),           a7_bear_sum = array.sum(a7_bear) 
a3_bear_sum = array.sum(a3_bear),           a8_bear_sum = array.sum(a8_bear) 
a4_bear_sum = array.sum(a4_bear),           a9_bear_sum = array.sum(a9_bear) 
a5_bear_sum = array.sum(a5_bear),           a10_bear_sum = array.sum(a10_bear) 

color redfill =     color.new(color.red, 65) 
color yellowfill =  color.new(color.yellow, 65) 
color orangefill =  color.new(color.orange, 65) 
color bluefill =    color.new(color.blue, 65) 
color greenfill =   color.new(color.green, 65) 
color white =       color.white 
color transp =      color.new(color.white, 100)
color black =       color.rgb(0, 0, 0) 
color yellow =      color.yellow 
color statscol =    color.rgb(7, 205, 227),     color purple = color.purple 
color[] reds =      array.from(color.rgb(255, 128, 128), color.rgb(255, 102, 102), color.rgb(255, 77, 77), color.rgb(255, 51, 51), color.rgb(255, 26, 26), color.rgb(255, 0, 0), color.rgb(230, 0, 0), color.rgb(204, 0, 0), color.rgb(179, 0, 0), color.rgb(153, 0, 0))
color[] greens =    array.from(color.rgb(179, 255, 179), color.rgb(153, 255, 153), color.rgb(128, 255, 128), color.rgb(102, 255, 102), color.rgb(77, 255, 77), color.rgb(51, 255, 51), color.rgb(26, 255, 26), color.rgb(0, 255, 0), color.rgb(0, 230, 0), color.rgb(0, 204, 0))

a1_bullt = a1_bull_sum > 0 ? a1_bull_sum : 0,    a2_bullt = a2_bull_sum > 0 ? a2_bull_sum : 0,    a3_bullt = a3_bull_sum > 0 ? a3_bull_sum : 0,    a4_bullt = a4_bull_sum > 0 ? a4_bull_sum : 0
a5_bullt = a5_bull_sum > 0 ? a5_bull_sum : 0, a6_bullt = a6_bull_sum > 0 ? a6_bull_sum : 0,     a7_bullt = a7_bull_sum > 0 ? a7_bull_sum : 0, 
a8_bullt = a8_bull_sum > 0 ? a8_bull_sum : 0,   a9_bullt = a9_bull_sum > 0 ? a9_bull_sum : 0,   a10_bullt = a10_bull_sum > 0 ? a10_bull_sum : 0 

a1_beart = a1_bear_sum > 0 ? a1_bear_sum : 0,    a2_beart = a2_bear_sum > 0 ? a2_bear_sum : 0,    a3_beart = a3_bear_sum > 0 ? a3_bear_sum : 0,    a4_beart = a4_bear_sum > 0 ? a4_bear_sum : 0
a5_beart = a5_bear_sum > 0 ? a5_bear_sum : 0, a6_beart = a6_bear_sum > 0 ? a6_bear_sum : 0,     a7_beart = a7_bear_sum > 0 ? a7_bear_sum : 0, 
a8_beart = a8_bear_sum > 0 ? a8_bear_sum : 0,   a9_beart = a9_bear_sum > 0 ? a9_bear_sum : 0,   a10_beart = a10_bear_sum > 0 ? a10_bear_sum : 0 
totes_buyers = (a1_bullt + a2_bullt + a3_bullt + a4_bullt + a5_bullt + a6_bullt + a7_bullt + a8_bullt + a9_bullt + a10_bullt)
totes_sellers = (a1_beart + a2_beart + a3_beart + a4_beart + a5_beart + a6_beart + a7_beart + a8_beart + a9_beart + a10_beart)
buying_comp(value) => 
    math.round((value / totes_buyers) * 100, 2) 

selling_comp(value) => 
    math.round((value / totes_sellers) * 100, 2)

label_location(bull, bear) => 
    float output = 0.0 
    if bull > bear 
        output := bull 
    else 
        output := bear 
    output 
f_timeToString(_t) =>
    str.tostring(year(_t), "0000") + "." + str.tostring(month(_t), "00") + "." + str.tostring(dayofmonth(_t), "00") //+ " " + str.tostring(hour(_t), "00") + ":" + str.tostring(minute(_t), "00") + ":" + str.tostring(second(_t), "00")
cur_time = f_timeToString(time)
start_time = f_timeToString(time[len])

buying_comp_array = array.from(a1_bull_sum, a2_bull_sum, a3_bull_sum, a4_bull_sum, a5_bull_sum, a6_bull_sum, a7_bull_sum, a8_bull_sum, a9_bull_sum, a10_bull_sum)
selling_comp_array = array.from(a1_bear_sum, a2_bear_sum, a3_bear_sum, a4_bear_sum, a5_bear_sum, a6_bear_sum, a7_bear_sum, a8_bear_sum, a9_bear_sum, a10_bear_sum)
array.sort(buying_comp_array, order.ascending) 
array.sort(selling_comp_array, order.ascending)
bullcolor_assign(value) =>
    color assigned = na
    if value == array.get(buying_comp_array, 0) 
        assigned := array.get(greens, 0)
    else if value == array.get(buying_comp_array, 1) 
        assigned := array.get(greens, 1) 
    else if value == array.get(buying_comp_array, 2) 
        assigned := array.get(greens, 2) 
    else if value == array.get(buying_comp_array, 3)
        assigned := array.get(greens, 3) 
    else if value == array.get(buying_comp_array, 4) 
        assigned := array.get(greens, 4) 
    else if value == array.get(buying_comp_array, 5) 
        assigned := array.get(greens, 5) 
    else if value == array.get(buying_comp_array, 6) 
        assigned := array.get(greens, 6) 
    else if value == array.get(buying_comp_array, 7) 
        assigned := array.get(greens, 7) 
    else if value == array.get(buying_comp_array, 8) 
        assigned := array.get(greens, 8) 
    else if value == array.get(buying_comp_array, 9) 
        assigned := array.get(greens, 9) 

bearcolor_assign(value) =>
    color assigned = na
    if value == array.get(selling_comp_array, 0) 
        assigned := array.get(reds, 0)
    else if value == array.get(selling_comp_array, 1) 
        assigned := array.get(reds, 1) 
    else if value == array.get(selling_comp_array, 2)  
        assigned := array.get(reds, 2) 
    else if value == array.get(selling_comp_array, 3)  
        assigned := array.get(reds, 3) 
    else if value == array.get(selling_comp_array, 4)  
        assigned := array.get(reds, 4) 
    else if value == array.get(selling_comp_array, 5)  
        assigned := array.get(reds, 5) 
    else if value == array.get(selling_comp_array, 6)  
        assigned := array.get(reds, 6) 
    else if value == array.get(selling_comp_array, 7)  
        assigned := array.get(reds, 7) 
    else if value == array.get(selling_comp_array, 8)  
        assigned := array.get(reds, 8) 
    else if value == array.get(selling_comp_array, 9)  
        assigned := array.get(reds, 9) 
    assigned 

find_bullish_poc = math.max(a1_bullt, a2_bullt, a3_bullt, a4_bullt, a5_bullt, a6_bullt, a7_bullt, a8_bullt, a9_bullt, a10_bullt)
find_bearish_poc = math.max(a1_beart, a2_beart, a3_beart, a4_beart, a5_beart, a6_beart, a7_beart, a8_beart, a9_beart, a10_beart)
string bullish_poc = find_bullish_poc == a1_bullt ? str.tostring(a1_values) : find_bullish_poc == a2_bullt ? str.tostring(a2_values) : find_bullish_poc == a3_bullt ? str.tostring(a3_values) : find_bullish_poc == a4_bullt ? str.tostring(a4_values) : find_bullish_poc == a5_bullt ? str.tostring(a5_values) : find_bullish_poc == a6_bullt ? str.tostring(a6_values) : find_bullish_poc == a7_bullt ? str.tostring(a7_values) : find_bullish_poc == a8_bullt ? str.tostring(a8_values) : find_bullish_poc == a9_bullt ? str.tostring(a9_values) : find_bullish_poc == a10_bullt ? str.tostring(a10_values) : na 
string bearish_poc = find_bearish_poc == a1_beart ? str.tostring(a1_values) : find_bearish_poc == a2_beart ? str.tostring(a2_values) : find_bearish_poc == a3_beart ? str.tostring(a3_values) : find_bearish_poc == a4_beart ? str.tostring(a4_values) : find_bearish_poc == a5_beart ? str.tostring(a5_values) : find_bearish_poc == a6_beart ? str.tostring(a6_values) : find_bearish_poc == a7_beart ? str.tostring(a7_values) : find_bearish_poc == a8_beart ? str.tostring(a8_values) : find_bearish_poc == a9_beart ? str.tostring(a9_values) : find_bearish_poc == a10_bullt ? str.tostring(a10_values) : na 
var box a1_box = na,    var label a1_label = na  
var box a2_box = na,    var label a2_label = na  
var box a3_box = na,    var label a3_label = na 
var box a4_box = na,    var label a4_label = na 
var box a5_box = na,    var label a5_label = na
var box a6_box = na,    var label a6_label = na 
var box a7_box = na,    var label a7_label = na  
var box a8_box = na,    var label a8_label = na 
var box a9_box = na,    var label a9_label = na 
var box a10_box = na,   var label a10_label = na 
var box a1_bbox = na,   var box a3_bbox = na 
var box a2_bbox = na,   var box a4_bbox = na 
var box a5_bbox = na,   var box a6_bbox = na 
var box a7_bbox = na,   var box a8_bbox = na,   var box a9_bbox = na,       var box a10_bbox = na 
if barstate.isconfirmed 
    box.delete(a1_box),     label.delete(a1_label),      box.delete(a6_box),    label.delete(a6_label),     box.delete(a1_bbox),    a6_bbox.delete() 
    box.delete(a2_box),     label.delete(a2_label),      box.delete(a7_box),    label.delete(a7_label),     a3_bbox.delete(),       a7_bbox.delete()  
    box.delete(a3_box),     label.delete(a3_label),      box.delete(a8_box),    label.delete(a8_label),     a2_bbox.delete(),       a8_bbox.delete() 
    box.delete(a4_box),     label.delete(a4_label),      box.delete(a9_box),    label.delete(a9_label),     a4_bbox.delete(),       a9_bbox.delete() 
    box.delete(a5_box),     label.delete(a5_label),      box.delete(a10_box),   label.delete(a10_label),    a5_bbox.delete(),       a10_bbox.delete() 

    a1_box := box.new(bar_index[70], 0, bar_index[67], a1_bull_sum, border_color =white,bgcolor = bullcolor_assign(a1_bull_sum), text = str.tostring(buying_comp(a1_bull_sum)) + "%", text_color = white) 
    a1_bbox := box.new(bar_index[67], 0, bar_index[64], a1_bear_sum, border_color =white,bgcolor = bearcolor_assign(a1_bear_sum), text = str.tostring(selling_comp(a1_bear_sum)) + "%", text_color = white) 
    
    a2_box := box.new(bar_index[63], 0, bar_index[60], a2_bull_sum, border_color = white, bgcolor = bullcolor_assign(a2_bull_sum), text = str.tostring(buying_comp(a2_bull_sum)) + "%", text_color = white) 
    a2_bbox := box.new(bar_index[60], 0, bar_index[57], a2_bear_sum, border_color = white, bgcolor =  bearcolor_assign(a2_bear_sum), text = str.tostring(selling_comp(a2_bear_sum)) + "%", text_color = white) 
    
    a3_box := box.new(bar_index[56], 0, bar_index[53], a3_bull_sum, border_color = white, bgcolor = bullcolor_assign(a3_bull_sum), text = str.tostring(buying_comp(a3_bull_sum)) + "%", text_color = white)  
    a3_bbox := box.new(bar_index[53], 0, bar_index[50], a3_bear_sum, border_color = white, bgcolor =  bearcolor_assign(a3_bear_sum), text = str.tostring(selling_comp(a3_bear_sum)) + "%", text_color = white)  
    
    a4_box := box.new(bar_index[49], 0, bar_index[46], a4_bull_sum, border_color = white, bgcolor = bullcolor_assign(a4_bull_sum), text = str.tostring(buying_comp(a4_bull_sum)) + "%", text_color = white)
    a4_bbox := box.new(bar_index[46], 0, bar_index[43], a4_bear_sum, border_color = white, bgcolor =  bearcolor_assign(a4_bear_sum), text = str.tostring(selling_comp(a4_bear_sum)) + "%", text_color = white)  
    
    a5_box := box.new(bar_index[42], 0, bar_index[39], a5_bull_sum, border_color = white, bgcolor = bullcolor_assign(a5_bull_sum), text = str.tostring(buying_comp(a5_bull_sum)) + "%", text_color = white) 
    a5_bbox := box.new(bar_index[39], 0, bar_index[36], a5_bear_sum, border_color = white, bgcolor =  bearcolor_assign(a5_bear_sum), text = str.tostring(selling_comp(a5_bear_sum)) + "%", text_color = white) 
    
    a6_box := box.new(bar_index[35], 0, bar_index[32], a6_bull_sum, border_color = white, bgcolor = bullcolor_assign(a6_bull_sum), text = str.tostring(buying_comp(a6_bull_sum)) + "%", text_color = white) 
    a6_bbox := box.new(bar_index[32], 0, bar_index[29], a6_bear_sum, border_color = white, bgcolor =  bearcolor_assign(a6_bear_sum), text = str.tostring(selling_comp(a6_bear_sum)) + "%", text_color = white) 

    a7_box := box.new(bar_index[28], 0, bar_index[25], a7_bull_sum, border_color = white, bgcolor = bullcolor_assign(a7_bull_sum), text = str.tostring(buying_comp(a7_bull_sum)) + "%", text_color = white)
    a7_bbox := box.new(bar_index[25], 0, bar_index[22], a7_bear_sum, border_color = white, bgcolor =  bearcolor_assign(a7_bear_sum), text = str.tostring(selling_comp(a7_bear_sum)) + "%", text_color = white)

    a8_box := box.new(bar_index[21], 0, bar_index[18], a8_bull_sum, border_color = white, bgcolor = bullcolor_assign(a8_bull_sum), text = str.tostring(buying_comp(a8_bull_sum)) + "%", text_color = white)
    a8_bbox := box.new(bar_index[18], 0, bar_index[15], a8_bull_sum, border_color = white, bgcolor =  bearcolor_assign(a8_bear_sum), text = str.tostring(selling_comp(a8_bear_sum)) + "%", text_color = white)

    a1_label := label.new(bar_index[67], label_location(a1_bull_sum, a1_bear_sum), text = str.tostring(a1_values), color = transp, textcolor = white, style = label.style_label_down)
    a2_label := label.new(bar_index[60], label_location(a2_bull_sum, a2_bear_sum), text = str.tostring(a2_values), color = transp, textcolor = white, style = label.style_label_down) 
    a3_label := label.new(bar_index[53], label_location(a3_bull_sum, a3_bear_sum), text = str.tostring(a3_values), color = transp, textcolor = white, style = label.style_label_down) 
    a4_label := label.new(bar_index[46], label_location(a4_bull_sum, a4_bear_sum), text = str.tostring(a4_values), color = transp, textcolor = white, style = label.style_label_down)
    a5_label := label.new(bar_index[39], label_location(a5_bull_sum, a5_bear_sum), text = str.tostring(a5_values), color = transp, textcolor = white, style = label.style_label_down) 
    a6_label := label.new(bar_index[32], label_location(a6_bull_sum, a6_bear_sum), text = str.tostring(a6_values), color = transp, textcolor = white, style = label.style_label_down)
    a7_label := label.new(bar_index[25], label_location(a7_bull_sum, a7_bear_sum), text = str.tostring(a7_values), color = transp, textcolor = white, style = label.style_label_down) 
    a8_label := label.new(bar_index[18], label_location(a8_bull_sum, a8_bear_sum), text = str.tostring(a8_values), color = transp, textcolor = white, style = label.style_label_down)
    if array.size(a9_bull) - 1 > 0  
        a9_box := box.new(bar_index[14], 0, bar_index[11], a9_bull_sum, border_color = white, bgcolor = bullcolor_assign(a9_bull_sum), text = str.tostring(buying_comp(a9_bull_sum)) + "%", text_color = white)
        a9_bbox := box.new(bar_index[11], 0, bar_index[8], a9_bull_sum, border_color = white, bgcolor =  bearcolor_assign(a9_bear_sum), text = str.tostring(selling_comp(a9_bear_sum)) + "%", text_color = white) 
        a9_label := label.new(bar_index[13], label_location(a9_bull_sum, a9_bear_sum), text = str.tostring(a9_values), color = transp, textcolor = white, style = label.style_label_down)
    if array.size(a10_bull) -1 > 0 
        a10_box := box.new(bar_index[7], 0, bar_index[4], a10_bull_sum, border_color = white, bgcolor = bullcolor_assign(a10_bull_sum), text = str.tostring(buying_comp(a10_bull_sum)) + "%", text_color = white) 
        a10_bbox := box.new(bar_index[4], 0, bar_index[1], a10_bull_sum, border_color = white, bgcolor =  bearcolor_assign(a10_bear_sum), text = str.tostring(selling_comp(a10_bear_sum)) + "%", text_color = white) 
        a10_label := label.new(bar_index[6], label_location(a10_bull_sum, a10_bear_sum), text = str.tostring(a10_values), color = transp, textcolor = white, style = label.style_label_down)

if showtime or showpoc 
    var table stats = table.new(position.middle_left, 3, 5, bgcolor = statscol, frame_color = black, frame_width = 2)
    table.cell(stats, 1, 1, text = "Stats Table", text_color = black)
    if showtime  
        table.cell(stats, 1, 2, text = "Start Time: " + str.tostring(start_time) + "\n End Time: " + str.tostring(cur_time), text_color = black) 
    if showpoc 
        table.cell(stats, 1, 3, text = "Bullish POC:\n" + str.tostring(bullish_poc), text_color = black) 
        table.cell(stats, 1, 4, text = "Bearish POC:\n" + str.tostring(bearish_poc), text_color = black)
        var label bullish_poc_lbl = na,     var label bearish_poc_lbl = na 
        if barstate.islast
            bullish_poc_lbl.delete(),   bearish_poc_lbl.delete() 
            if find_bullish_poc == a1_bullt 
                bullish_poc_lbl := label.new(bar_index[69], a1_bull_sum, " ", color = purple, style = label.style_diamond)
            else if find_bullish_poc == a2_bullt 
                bullish_poc_lbl := label.new(bar_index[62], a2_bull_sum, " ", color = purple, style = label.style_diamond)
            else if find_bullish_poc == a3_bullt 
                bullish_poc_lbl := label.new(bar_index[55], a3_bull_sum, " ", color = purple, style = label.style_diamond)
            else if find_bullish_poc == a4_bullt 
                bullish_poc_lbl := label.new(bar_index[48], a4_bull_sum, " ", color = purple, style = label.style_diamond)
            else if find_bullish_poc == a5_bullt 
                bullish_poc_lbl := label.new(bar_index[41], a5_bull_sum, " ", color = purple, style = label.style_diamond)
            else if find_bullish_poc == a6_bullt 
                bullish_poc_lbl := label.new(bar_index[34], a6_bull_sum, " ", color = purple, style = label.style_diamond)
            else if find_bullish_poc == a7_bullt 
                bullish_poc_lbl := label.new(bar_index[27], a7_bull_sum, " ", color = purple, style = label.style_diamond)
            else if find_bullish_poc == a8_bullt 
                bullish_poc_lbl := label.new(bar_index[20], a8_bull_sum, " ", color = purple, style = label.style_diamond)
            else if find_bullish_poc == a9_bullt
                bullish_poc_lbl := label.new(bar_index[13], a9_bull_sum, " ", color = purple, style = label.style_diamond)
            else if find_bullish_poc == a10_bullt 
                bullish_poc_lbl := label.new(bar_index[9], a10_bull_sum, " ", color = purple, style = label.style_diamond)

            if find_bearish_poc == a1_beart 
                bearish_poc_lbl := label.new(bar_index[66], a1_bear_sum, " ", color = yellow, style = label.style_diamond)
            else if find_bearish_poc == a2_beart 
                bearish_poc_lbl := label.new(bar_index[59], a2_bear_sum, " ", color = yellow, style = label.style_diamond)
            else if find_bearish_poc == a3_beart 
                bearish_poc_lbl := label.new(bar_index[52], a3_bear_sum, " ", color = yellow, style = label.style_diamond)
            else if find_bearish_poc == a4_bullt 
                bearish_poc_lbl := label.new(bar_index[44], a4_bear_sum, " ", color = yellow, style = label.style_diamond)
            else if find_bearish_poc == a5_beart 
                bearish_poc_lbl := label.new(bar_index[38], a5_bear_sum, " ", color = yellow, style = label.style_diamond)
            else if find_bearish_poc == a6_beart 
                bearish_poc_lbl := label.new(bar_index[31], a6_bear_sum, " ", color = yellow, style = label.style_diamond)
            else if find_bearish_poc == a7_beart 
                bearish_poc_lbl := label.new(bar_index[24], a7_bear_sum, " ", color = yellow, style = label.style_diamond)
            else if find_bearish_poc == a8_beart 
                bearish_poc_lbl := label.new(bar_index[17], a8_bear_sum, " ", color = yellow, style = label.style_diamond)
            else if find_bearish_poc == a9_beart
                bearish_poc_lbl := label.new(bar_index[10], a9_bear_sum, " ", color = yellow, style = label.style_diamond)
            else if find_bearish_poc == a10_beart 
                bearish_poc_lbl := label.new(bar_index[3], a10_bear_sum, " ", color = yellow, style = label.style_diamond)


            

f_avg(array) => 
    math.round(array.avg(array),2) 

// Volume Ranges 
if rngbyvol
    vol_max = array.max(vol_arr) 
    vol_min = array.min(vol_arr) 
    vol_sd = array.stdev(vol_arr) 
    vol_median = array.median(vol_arr) 
    vol_rng_1 = vol_min + vol_sd 
    vol_rng_2 = vol_rng_1 + vol_sd 
    vol_rng_3 = vol_rng_2 + vol_sd 
    vol_rng_4 = vol_rng_3 + vol_sd 
    vol_rng_5 = vol_rng_4 + vol_sd 

    vol_hi_rng = high - open  
    vol_lo_rng = open - low 

    vol1_hi_rng = array.new<float>()  
    vol2_hi_rng = array.new<float>()  
    vol3_hi_rng = array.new<float>()  
    vol4_hi_rng = array.new<float>()  
    vol5_hi_rng = array.new<float>()   

    vol1_lo_rng = array.new<float>()  
    vol2_lo_rng = array.new<float>()  
    vol3_lo_rng = array.new<float>()  
    vol4_lo_rng = array.new<float>()  
    vol5_lo_rng = array.new<float>()   
    bool rng_1_vol = volume >= vol_min and volume < vol_rng_1 
    bool rng_2_vol = volume >= vol_rng_1 and volume < vol_rng_2 
    bool rng_3_vol = volume >= vol_rng_2 and volume < vol_rng_3 
    bool rng_4_vol = volume >= vol_rng_3 and volume < vol_rng_4 
    bool rng_5_vol = volume >= vol_rng_4  

    for i = 0 to len 
        if rng_1_vol[i] 
            array.push(vol1_hi_rng, vol_hi_rng[i])
            array.push(vol1_lo_rng, vol_lo_rng[i])
        if rng_2_vol[i] 
            array.push(vol2_hi_rng, vol_hi_rng[i])
            array.push(vol2_lo_rng, vol_lo_rng[i]) 
        if rng_3_vol[i] 
            array.push(vol3_hi_rng, vol_hi_rng[i])
            array.push(vol3_lo_rng, vol_lo_rng[i])
        if rng_4_vol[i] 
            array.push(vol4_hi_rng, vol_hi_rng[i])
            array.push(vol4_lo_rng, vol_lo_rng[i])
        if rng_5_vol[i] 
            array.push(vol5_hi_rng, vol_hi_rng[i])
            array.push(vol5_lo_rng, vol_lo_rng[i])
    vol_rnges = array.from(vol_rng_1, vol_rng_2, vol_rng_3, vol_rng_4, vol_rng_5) 
    hi_rnges = array.from(array.avg(vol1_hi_rng), array.avg(vol2_hi_rng), array.avg(vol3_hi_rng), array.avg(vol4_hi_rng), array.avg(vol5_hi_rng)) 
    lo_rnges = array.from(array.avg(vol1_lo_rng), array.avg(vol2_lo_rng), array.avg(vol3_lo_rng), array.avg(vol4_lo_rng), array.avg(vol5_lo_rng)) 
    hi1_rng = f_avg(vol1_hi_rng) 
    hi2_rng = f_avg(vol2_hi_rng) 
    hi3_rng = f_avg(vol3_hi_rng) 
    hi4_rng = f_avg(vol4_hi_rng) 
    hi5_rng = f_avg(vol5_hi_rng) 
    lo1_rng = f_avg(vol1_lo_rng)
    lo2_rng = f_avg(vol2_lo_rng) 
    lo3_rng = f_avg(vol3_lo_rng) 
    lo4_rng = f_avg(vol4_lo_rng) 
    lo5_rng = f_avg(vol5_lo_rng) 

    array.sort(hi_rnges, order.ascending) 
    array.sort(lo_rnges, order.ascending)
    var box baseb1 = na,        var box baseb2 = na,        var box baseb3 = na,        var box baseb4 = na,        var box baseb5 = na 
    var box box1 = na,          var box box2 = na,          var box box3 = na,          var box box4 = na,          var box box5 = na,
    var box box6 = na,          var box box7 = na,          var box box8 = na,          var box box9 = na,          var box box10 = na,
    if barstate.islast 
        baseb1.delete(), baseb2.delete(), baseb3.delete(), baseb4.delete(), baseb5.delete(), box1.delete(), box2.delete(), box3.delete(), box4.delete(), box5.delete() 
        box6.delete(), box7.delete(), box8.delete(), box9.delete(), box10.delete() 
        baseb1 := box.new(bar_index, 0, bar_index + 6, vol_max, border_color =  array.get(reds, 3), bgcolor = array.get(reds, 3), text = str.tostring(vol_min))
        baseb2 := box.new(bar_index + 6, 0, bar_index + 12, vol_max, border_color = array.get(reds, 2), bgcolor = array.get(reds, 2)) 
        baseb3 := box.new(bar_index + 12, 0, bar_index + 18, vol_max, border_color = array.get(reds, 1), bgcolor = array.get(reds, 1), text = str.tostring(vol_median)) 
        baseb4 := box.new(bar_index + 18, 0, bar_index + 24, vol_max, border_color = array.get(greens, 0), bgcolor = array.get(greens, 0)) 
        baseb5 := box.new(bar_index + 24, 0, bar_index + 30, vol_max, border_color = array.get(greens, 9), bgcolor = array.get(greens, 9), text = str.tostring(vol_max)) 

        box1 := box.new(bar_index, vol_max, bar_index + 6, (vol_max * 2) * array.avg(vol1_hi_rng), border_color =  array.get(greens, 2), bgcolor = array.get(greens, 2), text = str.tostring(hi1_rng)) 
        box2 := box.new(bar_index, 0, bar_index + 6, (vol_max * -2) * array.avg(vol1_lo_rng), border_color =  array.get(reds, 2), bgcolor = array.get(reds, 2), text = str.tostring(lo1_rng)) 
        box3 := box.new(bar_index + 6, 0, bar_index + 12, (vol_max * -2) * array.avg(vol2_lo_rng), border_color = array.get(reds, 1), bgcolor = array.get(reds, 1), text=str.tostring(lo2_rng)) 
        box4 := box.new(bar_index + 6, vol_max, bar_index + 12, (vol_max * 2) * array.avg(vol2_hi_rng), border_color = array.get(greens, 0), bgcolor = array.get(greens, 0), text = str.tostring(hi2_rng)) 
        box5 := box.new(bar_index + 12, 0, bar_index + 18, (vol_max * -2) * array.avg(vol3_lo_rng), border_color = array.get(reds, 3), bgcolor = array.get(reds, 3), text = str.tostring(lo3_rng))  
        box6 := box.new(bar_index + 12, vol_max, bar_index + 18, (vol_max * 2) * array.avg(vol3_hi_rng), border_color = array.get(greens, 3), bgcolor = array.get(greens, 3), text = str.tostring(hi3_rng)) 
        box7 := box.new(bar_index + 18, 0, bar_index + 24, (vol_max * -2) * array.avg(vol4_lo_rng), border_color = array.get(reds, 4), bgcolor = array.get(reds, 4), text = str.tostring(lo4_rng))
        box8 := box.new(bar_index + 18, vol_max, bar_index + 24, (vol_max * 2) * array.avg(vol4_hi_rng), border_color = array.get(greens, 4), bgcolor = array.get(greens, 4), text = str.tostring(hi4_rng)) 
        box9 := box.new(bar_index + 24, 0, bar_index + 30, (vol_max * -2) * array.avg(vol5_lo_rng), border_color = array.get(reds, 5), bgcolor = array.get(reds, 5), text = str.tostring(lo5_rng))
        box10 := box.new(bar_index + 24, vol_max, bar_index + 30, (vol_max * 2) * array.avg(vol5_hi_rng), border_color = array.get(greens, 5), bgcolor = array.get(greens, 5), text = str.tostring(hi5_rng)) 



        



https://www.tradingview.com/script/p7XKh2pa-Volume-Profile-Histogram-SS/

ใส่ความเห็น

อีเมลของคุณจะไม่แสดงให้คนอื่นเห็น ช่องข้อมูลจำเป็นถูกทำเครื่องหมาย *