Professional Documents
Culture Documents
V. Profile
V. Profile
//|—————————————————————————————————————————————————————————
//| Name: V-Profile
//| Version: 1.3
//| Date: 11.11.2020
//| Autor: Haft (by EulerMethod)
//|—————————————————————————————————————————————————————————
//| Tradingview: https://ru.tradingview.com/u/EulerMethod
//|—————————————————————————————————————————————————————————
//|
———————————————————————————————————————————————————————————————————————————————————
————————————————
//| Title | Variable | Type | Description |
Описание
//|
———————————————————————————————————————————————————————————————————————————————————
————————————————
//| On Δ | Off Σ | input_delta | boolean | Delta or Cumulative | Дельта
или Кумулятивный
//| POC | input_poc | boolean | Point of Control | Точка
контроля
//|——————————————————|———————————————|—————————|——————————————————————————|
———————————————————————————
//| Depth [20; 1k] | input_depth | integer | Depth of history | Глубина
истории
//| Range ± | input_range | boolean | Floating range |
Плавающий диапазон
//| ∟ % [0.1; 30] | input_persent | float | Floating range % |
Плавающий диапазон %
//| Scale Lg | input_log10 | boolean | Logarithmic scale |
Логарифмическая шкала
//|——————————————————|———————————————|—————————|——————————————————————————|
———————————————————————————
//| Amp [10; 100] | input_amp | integer | Amplitude of histogram |
Амплитуда гистограммы
//| Dot size | input_size | integer | Histogram dot size | Размер
точек гистограммы
//|——————————————————|———————————————|—————————|——————————————————————————|
———————————————————————————
//| Color: # | input_c_# | color | Palette | Палитра
//|
———————————————————————————————————————————————————————————————————————————————————
————————————————
study(
title = "V-Profile",
shorttitle = "V-Profile",
precision = 4,
overlay = true,
linktoseries = true,
max_bars_back = 1000
)
///////////////////////
// //
// INTERFACE //
// //
///////////////////////
//MOD'S
bool input_delta = input( title = "Delta", type = input.bool,
defval = false )
bool input_poc = input( title = "POC", type = input.bool,
defval = false )
//FRAME: Y
int input_depth = input( title = "Depth [10; 1k]", type = input.integer,
defval = 100, minval = 10, maxval = 1000 )
bool input_range = input( title = "Range ±", type = input.bool,
defval = false )
float input_persent = input( title = "∟ % [0.1; 50]", type = input.float,
defval = 5, minval = 0.1, maxval = 50, step = 0.1 )
bool input_log10 = input( title = "Scale Lg", type = input.bool,
defval = false )
//FRAME: X
int input_amp = input( title = "Amp [10; 100]", type = input.integer,
defval = 50, minval = 10, maxval = 100 )
int input_size = input( title = "Dot size", type = input.integer,
defval = 1, minval = 1, maxval = 3 )
//PALETTE
color input_c_info = input( title = "Color: Info", type = input.color,
defval = color.new(#FFFFFF, 0) ) //EM color White
color input_c_frame = input( title = "Color: Frame", type = input.color,
defval = color.new(#617793, 0) ) //EM color Palladium
color input_c_total = input( title = "Color: Σ", type = input.color,
defval = color.new(#00C3D3, 0) ) //EM color Palladium
color input_c_plus = input( title = "Color: Δ +", type = input.color,
defval = color.new(#1BDB00, 0) ) //EM color Green
color input_c_minus = input( title = "Color: Δ –", type = input.color,
defval = color.new(#E60000, 0) ) //EM color Blue
//////////////////
// //
// DATA //
// //
//////////////////
//// FRAME
//true depth
int depth = input_depth
//// POC
float POC = na
float POC_DP = na
float POC_DN = na
//// INTERFACE
//text
string txt_top = input_range ? "+ " + tostring(input_persent, "0.0") + " %" : " " +
(input_amp < 20 ? "H ⇅ L" : "HIGH ⇅ LOW")
string txt_btm = "❮ " + tostring(input_depth)
//size
var dot_size = input_size == 1 ? size.tiny : input_size == 2 ? size.small :
size.normal
//invisible
var color c_opacity = color.new(color.white, 100)
////////////////////////
// //
// EXCEPTIONS //
// //
////////////////////////
//no volume
if exception_no_volume
txt_top := input_amp < 20 ? "🚫" : "🚫 NO VOLUME"
//depth correction
if exception_excess_depth and barstate.islast
for i = 2 to input_depth
if na(close[i])
depth := i, break
txt_btm := "❮ " + tostring(depth)
//////////////////////////
// //
// CALCULATIONS //
// //
//////////////////////////
//// FRAME
//// FUNCTIONS
//row axis
float axis_step = (input_log10 ? log10(FH / FL) : FH - FL) / 50 //step (logarithmic
or linear)
Axis(i) => input_log10 ? pow(10, log10(FL) + i * axis_step) : FL + i * axis_step //
i steps
//drawing histogram
Histogram(i) =>
string T = (input_delta and array.get(DP, i)) or (not input_delta and
array.get(TP, i)) ? "◄ " : " "
if array.get(TV, i) > 0
int D_ = array.get(DA, i)
for j = 0 to array.get(TA, i)
T := T + (input_delta ? (D_ > j ? "•" : " ‧") : "•")
else
T := " ‧"
T
//row color
Color(m) => input_delta and array.get(DA, m) != 0 ? (array.get(DV, m) > 0 ?
input_c_plus : input_c_minus) : input_c_total
//// MAIN
if barstate.islast and not exception_no_volume
//full depth
for i = 0 to depth - 1
int C = 0 //denominator
TS = array.new_float(50, 0) //divisible volumes
DS = array.new_float(50, 0) //divisible deltas
if C != 0
//rows value
for j = 0 to 49
array.set(TV, j, array.get(TV, j) + (array.get(TS, j) * K / C ))
if input_delta
array.set(DV, j, array.get(DV, j) + (array.get(DS, j) *
K / C ))
array.clear(TS), array.clear(DS)
TM := array.max(TV)
for i = 0 to 49
//amplitude
array.set(TA, i, floor(input_amp * array.get(TV, i) / TM))
if not input_delta
//peak 4 < X > 4
float T_ = array.get(TV, i)
bool p4 = i - 4 < 0 ? true : T_ > array.get(TV, i - 4)
bool p3 = i - 3 < 0 ? true : T_ > array.get(TV, i - 3)
bool p2 = i - 2 < 0 ? true : T_ > array.get(TV, i - 2)
bool p1 = i - 1 < 0 ? true : T_ > array.get(TV, i - 1)
bool n1 = i + 1 > 49 ? true : T_ > array.get(TV, i + 1)
bool n2 = i + 2 > 49 ? true : T_ > array.get(TV, i + 2)
bool n3 = i + 3 > 49 ? true : T_ > array.get(TV, i + 3)
bool n4 = i + 4 > 49 ? true : T_ > array.get(TV, i + 4)
array.set(TP, i, p4 and p3 and p2 and p1 and n1 and n2 and n3 and
n4)
else
//amplitude
array.set(DA, i, floor(array.get(TA, i) * abs(array.get(DV, i)) /
array.get(TV, i)))
//POC
if input_poc
for i = 0 to 49
float R_ = array.get(R, i)
float D_ = array.get(DV, i)
seller_sum := seller_sum + (D_ < 0 ? D_ : 0)
seller_mass := seller_mass + (D_ < 0 ? D_ * R_ : 0)
buyer_sum := buyer_sum + (D_ > 0 ? D_ : 0)
buyer_mass := buyer_mass + (D_ > 0 ? D_ * R_ : 0)
//////////////////////
// //
// BUILDING //
// //
//////////////////////
//// POC
//// INTERFACE
// FRAME
//// HISTOGRAM
int r1 = time_close
float r2 = close
string r3 = ""
color r4 = input_c_total
var r5 = xloc.bar_time
var r6 = yloc.price
color r7 = c_opacity
var r8 = label.style_label_left
var r9 = dot_size
if barstate.islast
//Frame: limits
int time_start = max(time[depth - 1], time_first)
int time_finish = time_close
//// INTERFACE
//// POC
//// FRAME
line.set_xloc(line_FH, time_start, time_finish, xloc.bar_time)
line.set_y1(line_FH, FH)
line.set_y2(line_FH, FH)
//// HISTOGRAM