0% found this document useful (0 votes)
83 views

tradingview spot gamma script

The document is a Pine Script code for a TradingView study named 'SG Levels v0.30'. It allows users to input various parameters for drawing horizontal lines and labels on a price chart based on specific data inputs. The script includes functions for customizing line styles, colors, and label properties to enhance chart visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

tradingview spot gamma script

The document is a Pine Script code for a TradingView study named 'SG Levels v0.30'. It allows users to input various parameters for drawing horizontal lines and labels on a price chart based on specific data inputs. The script includes functions for customizing line styles, colors, and label properties to enhance chart visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

//@version=4

study("SG Levels v0.30", shorttitle="SGL", overlay=true)

text = input("", title="SG Text")


ColNum = input(1, title="Column Number", maxval=2, minval=1) - 1
LineColor = input(color.aqua, title="Line Color")
lsty = input("Solid", title="Line Style", options=["Solid", "Dashed", "Dotted"])
SGI_H_LineColor = input(color.lime, title="SGI High Line Color")
SGI_L_LineColor = input(color.red, title="SGI Low Line Color")
SGI_lsty = input("Dotted", title="Line Style", options=["Solid", "Dashed",
"Dotted"])
EnableLabels = input(true, title="Enable Line Labels")
LabelTextColor = LineColor
LabelOffset = input(100, title="Label Offset")
label_fs = input("Medium", title="Trade Label Size", options=["Auto", "Small",
"Medium", "Large"])
label_font_size = label_fs == "Auto" ? size.auto : label_fs == "Small" ? size.small
: label_fs == "Large" ? size.large : size.normal

line_style(lsty) =>
lsty == "Dashed" ? line.style_dashed
: lsty == "Dotted" ? line.style_dotted
: lsty == "Solid" ? line.style_solid
: na

draw_hline(start, end, price, line_color, lsty) =>


var line _line = na
_line := line.new(bar_index - start,
price, bar_index - end, price,
xloc=xloc.bar_index, style=line_style(lsty), color=line_color,
extend=extend.both, width=2)

draw_Text(_text, _x, _y, font_size, text_color)=>


var label la_panel = na
label.delete(la_panel)
la_panel := label.new(
x=_x, y=_y,
text=_text, xloc=xloc.bar_time, yloc=yloc.price,
style=label.style_none, textcolor=text_color, size=font_size)

outA_text = str.replace_all(text, "Date: ", "Date:_")


outB_text = str.replace_all(outA_text, "y S", "y_S")
outC_text = str.replace_all(outB_text, "a L", "a_L")
out0_text = str.replace_all(outC_text, "SPX PX", "SPX_PX")
out1_text = str.replace_all(out0_text, "ES PX", "ES_PX")
out2_text = str.replace_all(out1_text, "l I", "l_I")
out3_text = str.replace_all(out2_text, "e G", "e_G")
out4_text = str.replace_all(out3_text, "l W", "l_W")
out5_text = str.replace_all(out4_text, "o G", "o_G")
out6_text = str.replace_all(out5_text, "l T", "l_T")
out7_text = str.replace_all(out6_text, "t W", "t_W")
out8_text = str.replace_all(out7_text, "I I", "I_I")
out9_text = str.replace_all(out8_text, " / ", "/")
out10_text = str.replace_all(out9_text, "NDX PX", "NDX_PX")
out11_text = str.replace_all(out10_text, "NQ PX", "NQ_PX")
out12_text = str.replace_all(out11_text, "RUT PX", "RUT_PX")
out13_text = str.replace_all(out12_text, "RTY PX", "RTY_PX")
out_array = str.split(out13_text, " ")
//GET TAB
string_text = array.get(out_array, 2)
string_array = str.split(string_text, "")
c_s = array.get(string_array, 6)

out_array_s = array.size(out_array) - 1

getPrice(i) =>
out_array_s >= i ? tonumber(array.get(str.split(array.get(out_array, i), c_s),
ColNum)) : na

L1A = getPrice(3)
L2A = getPrice(4)
L3A = getPrice(5)
L4A = getPrice(6)
L5A = getPrice(7)
L6A = getPrice(8)
L7A = getPrice(9)
L8A = getPrice(10)
L9A = getPrice(11)
L10A = getPrice(12)
L11A = getPrice(13)
L12A = getPrice(14)
L13A = getPrice(15)

float LSGI_H = na
float LSGI_L = na

if out_array_s >= 16
iLSGI = array.get(str.split(array.get(out_array, 16), c_s), 2)
LSGI_0 = tonumber(array.get(str.split(iLSGI, "/"), 0))
LSGI_1 = tonumber(array.get(str.split(iLSGI, "/"), 1))
LSGI_H := max(LSGI_0, LSGI_1)
LSGI_L := min(LSGI_0, LSGI_1)
else
LSGI_H := na
LSGI_L := na

draw_hline(100, 0, L1A, LineColor, lsty)


draw_hline(100, 0, L2A, LineColor, lsty)
draw_hline(100, 0, L3A, LineColor, lsty)
draw_hline(100, 0, L4A, LineColor, lsty)
draw_hline(100, 0, L5A, LineColor, lsty)
draw_hline(100, 0, L6A, LineColor, lsty)
draw_hline(100, 0, L7A, LineColor, lsty)
draw_hline(100, 0, L8A, LineColor, lsty)
draw_hline(100, 0, L9A, LineColor, lsty)
draw_hline(100, 0, L10A, LineColor, lsty)
draw_hline(100, 0, L11A, LineColor, lsty)
draw_hline(100, 0, L12A, LineColor, lsty)
draw_hline(100, 0, L13A, LineColor, lsty)
if out_array_s >= 16
draw_hline(100, 0, LSGI_H, SGI_H_LineColor, SGI_lsty)
draw_hline(100, 0, LSGI_L, SGI_L_LineColor, SGI_lsty)

getLabel(i) =>
out_array_s >= i ? array.get(str.split(array.get(out_array, i), c_s), 2) : na

L1C = getLabel(3)
L2C = getLabel(4)
L3C = getLabel(5)
L4C = getLabel(6)
L5C = getLabel(7)
L6C = getLabel(8)
L7C = getLabel(9)
L8C = getLabel(10)
L9C = getLabel(11)
L10C = getLabel(12)
L11C = getLabel(13)
L12C = getLabel(14)
L13C = getLabel(15)

string SGI_H_Lbl = na
string SGI_L_Lbl = na
if out_array_s >= 16
SGI_H_Lbl := array.get(str.split(array.get(out_array, 16), c_s), 0) + "High"
SGI_L_Lbl := array.get(str.split(array.get(out_array, 16), c_s), 0) + "Low"

f_median(series) => percentile_nearest_rank(series, 100, 50)


offset_right_x(mult) => time + round(f_median(time_close - time)) * mult
tx = offset_right_x(LabelOffset)

if EnableLabels
draw_Text(L1C, tx, L1A, label_font_size, LabelTextColor)
draw_Text(L2C, tx, L2A, label_font_size, LabelTextColor)
draw_Text(L3C, tx, L3A, label_font_size, LabelTextColor)
draw_Text(L4C, tx, L4A, label_font_size, LabelTextColor)
draw_Text(L5C, tx, L5A, label_font_size, LabelTextColor)
draw_Text(L6C, tx, L6A, label_font_size, LabelTextColor)
draw_Text(L7C, tx, L7A, label_font_size, LabelTextColor)
draw_Text(L8C, tx, L8A, label_font_size, LabelTextColor)
draw_Text(L9C, tx, L9A, label_font_size, LabelTextColor)
draw_Text(L10C, tx, L10A, label_font_size, LabelTextColor)
draw_Text(L11C, tx, L11A, label_font_size, LabelTextColor)
draw_Text(L12C, tx, L12A, label_font_size, LabelTextColor)
draw_Text(L13C, tx, L13A, label_font_size, LabelTextColor)
if out_array_s >= 16
draw_Text(SGI_H_Lbl, tx, LSGI_H, label_font_size, SGI_H_LineColor)
draw_Text(SGI_L_Lbl, tx, LSGI_L, label_font_size, SGI_L_LineColor)

// // FOR DEBUGGING
// getArrayText(array0) =>
// a_index = max(array.size(array0) - 1, 0)
// string otext = na
// for c = 0 to a_index
// array0_out = array.get(array0, c)
// otext := otext
// + array0_out
// + "\n"
// otext

// draw_InfoPanel(_text, _x, _y, font_size, BGcolor)=>


// var label la_panel = na
// label.delete(la_panel)
// la_panel := label.new(
// x=_x, y=_y,
// text=_text, xloc=xloc.bar_time, yloc=yloc.price,
// color=BGcolor, style=label.style_label_left, textcolor=color.white,
size=font_size)

// out = getArrayText(out_array)

// draw_InfoPanel(tostring(string_array), time_close, highest(close, 200),


size.normal, color.black)
// draw_InfoPanel(out, time_close, close, size.normal, color.black)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy