@Lokraan/

vol profile generator

Python

generate code for pinescript (tradingview coding language)

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# p0 := _is_range_sub(_h, _l, d_range, 0.01, 0) ? nz(p0[1]) + range : p0[1]

n = 20
prefix = "p"
inc = 1.0 / n
print(inc)
for i in range(n):
  var = f"{prefix}{i}"
  j = i + 1

  mult_amt = round(inc * (j), 2)

  out = f"{var} := nb ? i == 1 ? abs(_range_sub_amt(_h, _l, dH, d_range, {mult_amt}, {round(mult_amt - inc, 2)}) * vol_p) : nz({var}, 0) + abs(_range_sub_amt(_h, _l, dH, d_range, {mult_amt}, {round(mult_amt - inc, 2)}) * vol_p) : {var}[1]"

  print(out)

for i in range(n):
  out = f"plot({prefix}{i}, color=col)"
  print(out)

out = "max("
for i in range(n):
  out += f"{prefix}{i}, max("

for i in range(n):
  out = f"{prefix}{i}_n = {prefix}{i} / max_v"
  
  print(out)

# print(out)