OPEN-SOURCE SCRIPT

merge_code

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo & Jesse.Lau

//version=5
indicator("Pivot Points High Low & Missed Reversal Levels with Supertrend and Fibonacci", overlay=true, max_labels_count=500, max_lines_count=500, max_bars_back=500)

// Inputs for pivot points and missed reversal levels
length = input(50, 'Pivot Length')
show_reg = input.bool(true, 'Regular Pivots', inline='inline1')
reg_ph_css = input.color(#ef5350, 'High', inline='inline1')
reg_pl_css = input.color(#26a69a, 'Low', inline='inline1')
show_miss = input.bool(true, 'Missed Pivots', inline='inline2')
miss_ph_css = input.color(#ef5350, 'High', inline='inline2')
miss_pl_css = input.color(#26a69a, 'Low', inline='inline2')
label_css = input.color(color.white, 'Text Label Color')

// Inputs for Supertrend and Fibonacci
atrPeriod = input(10, "ATR Length")
factor = input.float(3, "Factor", step = 0.1)
atrline = input.float(1.5, "Premium/Discount", step = 0.1)
show_zigzag = input(true, "Show Zigzag", group="Show")
show_fib = input(true, "Show Fibonacci", group="Show")
show_supertrend = input(true, "Show Supertrend", group="Show")
show_premiumdiscount = input(true, "Show Premium/Discount Line", group="Show")

// Supertrend calculation
[supertrend, direction] = ta.supertrend(factor, atrPeriod)
ATR = ta.atr(atrPeriod)
upatrline = supertrend + atrline * ATR
dnatrline = supertrend - atrline * ATR
bodyMiddle = (open + close) / 2
bodyMiddlePlot = plot(bodyMiddle)


// Plotting Supertrend and Premium/Discount levels
upTrend = plot(direction < 0 and show_supertrend ? supertrend : na, "Up Trend", color=color.green, style=plot.style_linebr)
downTrend = plot(direction > 0 and show_supertrend ? supertrend : na, "Down Trend", color=color.red, style=plot.style_linebr)
fill(bodyMiddlePlot, upTrend, show_supertrend ? color.new(color.green, 90) : na, fillgaps=false)
fill(bodyMiddlePlot, downTrend, show_supertrend ? color.new(color.red, 90) : na, fillgaps=false)
plot(direction < 0 and show_premiumdiscount ? upatrline : na, "Up ATR", color=color.white, style=plot.style_linebr)
plot(direction > 0 and show_premiumdiscount ? dnatrline : na, "Dn ATR", color=color.white, style=plot.style_linebr)

// Pivot points calculations
n = bar_index
ph = ta.pivothigh(length, length)
pl = ta.pivotlow(length, length)

// Fibonacci levels
h1 = ta.highest(high, 50)
l2 = ta.lowest(low, 50)
mid_val = (h1 + l2) / 2

// Plotting Fibonacci levels
var line hhLine = na
var line llLine = na
var line midline = na
if barstate.islast and show_fib
hhLine := line.new(bar_index - 50, h1, bar_index, h1, color=color.purple, width=1)
llLine := line.new(bar_index - 50, l2, bar_index, l2, color=color.purple, width=1)
midline := line.new(bar_index - 50, mid_val, bar_index, mid_val, color=color.purple, width=1)

// Plot missed pivots and regular pivots
var line zigzag = na
var line ghost_level = na
var max = 0., min = 0.
var max_x1 = 0, min_x1 = 0
var follow_max = 0., follow_max_x1 = 0
var follow_min = 0., follow_min_x1 = 0
var os = 0, py1 = 0., px1 = 0

if ph
if show_miss
if os[1] == 1
label.new(min_x1, min, '👻', color=miss_pl_css, style=label.style_label_up, size=size.small, tooltip=str.tostring(min, '#.####'))
zigzag := line.new(px1, py1, min_x1, min, color=miss_ph_css, style=line.style_dashed)
px1 := min_x1, py1 := min
line.set_x2(ghost_level[1], px1)
ghost_level := line.new(px1, py1, px1, py1, color=color.new(reg_pl_css, 50), width=2)
else if ph < max
label.new(max_x1, max, '👻', color=miss_ph_css, style=label.style_label_down, size=size.small, tooltip=str.tostring(max, '#.####'))
label.new(follow_min_x1, follow_min, '👻', color=miss_pl_css, style=label.style_label_up, size=size.small, tooltip=str.tostring(min, '#.####'))
zigzag := line.new(px1, py1, max_x1, max, color=miss_pl_css, style=line.style_dashed)
px1 := max_x1, py1 := max
line.set_x2(ghost_level[1], px1)
ghost_level := line.new(px1, py1, px1, py1, color=color.new(reg_ph_css, 50), width=2)
zigzag := line.new(px1, py1, follow_min_x1, follow_min, color=miss_ph_css, style=line.style_dashed)
px1 := follow_min_x1, py1 := follow_min
line.set_x2(ghost_level, px1)
ghost_level := line.new(px1, py1, px1, py1, color=color.new(reg_pl_css, 50), width=2)

if show_reg
label.new(n - length, ph, '▼', textcolor=label_css, color=reg_ph_css, style=label.style_label_down, size=size.small, tooltip=str.tostring(ph, '#.####'))
zigzag := line.new(px1, py1, n - length, ph, color=miss_pl_css, style=ph < max or os[1] == 1 ? line.style_dashed : line.style_solid)

py1 := ph, px1 := n - length, os := 1, max := ph, min := ph

if pl
if show_miss
if os[1] == 0
label.new(max_x1, max, '👻', color=miss_ph_css, style=label.style_label_down, size=size.small, tooltip=str.tostring(max, '#.####'))
zigzag := line.new(px1, py1, max_x1, max, color=miss_pl_css, style=line.style_dashed)
px1 := max_x1, py1 := max
line.set_x2(ghost_level[1], px1)
ghost_level := line.new(px1, py1, px1, py1, color=color.new(reg_ph_css, 50), width=2)
else if pl > min
label.new(follow_max_x1, follow_max, '👻', color=miss_ph_css, style=label.style_label_down, size=size.small, tooltip=str.tostring(max, '#.####'))
label.new(min_x1, min, '👻', color=miss_pl_css, style=label.style_label_up, size=size.small, tooltip=str.tostring(min, '#.####'))
zigzag := line.new(px1, py1, min_x1, min, color=miss_ph_css, style=line.style_dashed)
px1 := min_x1, py1 := min
line.set_x2(ghost_level[1], px1)
ghost_level := line.new(px1, py1, px1, py1, color=color.new(reg_pl_css, 50), width=2)
zigzag := line.new(px1, py1, follow_max_x1, follow_max, color=miss_pl_css, style=line.style_dashed)
px1 := follow_max_x1, py1 := follow_max
line.set_x2(ghost_level, px1)
ghost_level := line.new(px1, py1, px1, py1, color=color.new(reg_pl_css, 50), width=2)

if show_reg
label.new(n - length, pl, '▲', textcolor=label_css, color=reg_pl_css, style=label.style_label_up, size=size.small, tooltip=str.tostring(pl, '#.####'))
zigzag := line.new(px1, py1, n - length, pl, color=miss_ph_css, style=pl > min or os[1] == 0 ? line.style_dashed : line.style_solid)

py1 := pl, px1
Pivot points and levels

오픈 소스 스크립트

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

차트에 이 스크립트를 사용하시겠습니까?

면책사항