PHP Code:
// © KLYTON
//@version=5
indicator("Pivot Points BB and SS + Alerts",overlay=true,max_labels_count=500,max_lines_count=500,max_bars_back=500)
length = input(27,'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')
allow_alerts = input.bool(true, "Allow alerts")
label_css = input.color(color.white,'Text Label Color')
//------------------------------------------------------------------------------
var line zigzag = na
var line ghost_level = na
var max = 0.,var min = 0.
var max_x1 = 0,var min_x1 = 0
var follow_max = 0.,var follow_max_x1 = 0
var follow_min = 0.,var follow_min_x1 = 0
var os = 0,var py1 = 0.,var px1 = 0
//------------------------------------------------------------------------------
n = bar_index
ph = ta.pivothigh(length,length)
pl = ta.pivotlow(length,length)
max := math.max(high[length],max)
min := math.min(low[length],min)
follow_max := math.max(high[length],follow_max)
follow_min := math.min(low[length],follow_min)
if max > max[1]
max_x1 := n-length
follow_min := low[length]
if min < min[1]
min_x1 := n-length
follow_max := high[length]
if follow_min < follow_min[1]
follow_min_x1 := n-length
if follow_max > follow_max[1]
follow_max_x1 := n-length
//------------------------------------------------------------------------------
line.set_x2(ghost_level[1],n)
// Alert conditions
var alert_triggered_reg_high = false
var alert_triggered_reg_low = false
var alert_triggered_missed_low = false
var alert_triggered_missed_high = false
var current_signal = "none"
if ph
if show_miss
if os[1] == 1
label.new(min_x1,min,'Buy',textcolor=label_css,color=miss_pl_css,style=label.style_label_up,size=size.normal,
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)
// Set the alert condition for missed pivot
alert_triggered_missed_low := true
if current_signal == "Sell" and allow_alerts
alert("Buy")
current_signal := "Buy"
else if ph < max
label.new(max_x1,max,'Buy',textcolor=label_css,color=miss_ph_css,style=label.style_label_down,size=size.normal,
tooltip=str.tostring(max,'#.####'))
label.new(follow_min_x1,follow_min,'Buy',textcolor=label_css,color=miss_pl_css,style=label.style_label_up,size=size.normal,
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)
// Set the alert condition for regular pivot low
alert_triggered_reg_high := true
if current_signal == "Sell" and allow_alerts
alert("Buy")
current_signal := "Buy"
if show_reg
label.new(n-length,ph,'Sell',textcolor=label_css,color=reg_ph_css,style=label.style_label_down,size=size.normal,
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)
// Set the alert condition for regular pivot high
alert_triggered_reg_high := true
if current_signal == "Buy" and allow_alerts
alert("Sell")
current_signal := "Sell"
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,'Sell',textcolor=label_css,color=miss_ph_css,style=label.style_label_down,size=size.normal,
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)
// Set the alert condition for missed pivot
alert_triggered_missed_low := true
if current_signal == "Buy" and allow_alerts
alert("Sell")
current_signal := "Sell"
else if pl > min
label.new(follow_max_x1,follow_max,'Sell',textcolor=label_css,color=miss_ph_css,style=label.style_label_down,size=size.normal,
tooltip=str.tostring(max,'#.####'))
label.new(min_x1,min,'Sell',textcolor=label_css,color=miss_pl_css,style=label.style_label_up,size=size.normal,
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_ph_css,50),width=2)
// Set the alert condition for regular pivot low
alert_triggered_reg_low := true
if current_signal == "Buy" and allow_alerts
alert("Sell")
current_signal := "Sell"
if show_reg
label.new(n-length,pl,'Buy',textcolor=label_css,color=reg_pl_css,style=label.style_label_up,size=size.normal,
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)
// Set the alert condition for regular pivot high
alert_triggered_reg_high := true
if current_signal == "Sell" and allow_alerts
alert("Buy")
current_signal := "Buy"
py1 := pl,px1 := n-length,os := 0,max := pl,min := pl
//------------------------------------------------------------------------------
var label lbl = na
if barstate.islast
x = 0,y = 0.
prices = array.new_float(0)
prices_x = array.new_int(0)
for i = 0 to n-px1-1
array.push(prices,os==1?low[i]:high[i])
array.push(prices_x,n-i)
label.delete(lbl[1])
if os == 1
y := array.min(prices)
x := array.get(prices_x,array.indexof(prices,y))
if show_miss
lbl := label.new(x,y,'Buy',textcolor=label_css,color=miss_pl_css,style=label.style_label_up,size=size.normal,
tooltip=str.tostring(y,'#.####'))
else
y := array.max(prices)
x := array.get(prices_x,array.indexof(prices,y))
if show_miss
lbl := label.new(x,y,'Sell',textcolor=label_css,color=miss_ph_css,style=label.style_label_down,size=size.normal,
tooltip=str.tostring(y,'#.####'))
if show_miss
line.delete(line.new(px1,py1,x,y,color=os == 1 ? miss_ph_css : miss_pl_css,style=line.style_dashed)[1])
line.delete(line.new(x,y,n,y,color = color.new(os == 1 ? miss_ph_css : miss_pl_css,50),width=2)[1])
// Alert conditions
alertcondition(alert_triggered_reg_high, title="Regular Pivot High", message="Regular pivot high alert triggered!")
alertcondition(alert_triggered_reg_low, title="Regular Pivot Low", message="Regular pivot low alert triggered!")
alertcondition(alert_triggered_missed_high, title="Missed High Pivot", message="Missed pivot alert triggered!")
alertcondition(alert_triggered_missed_low, title="Missed Low Pivot", message="Missed pivot alert triggered!")
// created by senthil
//@version=5
//
//toggleBreaks = input(true, title='Show Breaks')
//leftBars = input(5, title='Left Bars ')
//rightBars = input(5, title='Right Bars')
//volumeThresh = input(20, title='Volume Threshold')
//
//highUsePivot = fixnan(ta.pivothigh(leftBars, rightBars)[1])
//lowUsePivot = fixnan(ta.pivotlow(leftBars, rightBars)[1])
//r1 = plot(highUsePivot, color=ta.change(highUsePivot) ? na : #FF0000, linewidth=3, offset=-(rightBars + 1), title='Resistance')
//s1 = plot(lowUsePivot, color=ta.change(lowUsePivot) ? na : #233dee, linewidth=3, offset=-(rightBars + 1), title='Support')
//Volume %
//short = ta.ema(volume, 5)
//long = ta.ema(volume, 10)
//osc = 100 * (short - long) / long
//For breaks with volume
//plotshape(toggleBreaks and ta.crossunder(close, lowUsePivot) and not(open - close < high - open) and osc > volumeThresh, title='Break', text='B', style=shape.labeldown, location=location.abovebar, color=color.rgb(255, 82, 82), textcolor=color.new(color.white, 0), size=size.tiny)
//plotshape(toggleBreaks and ta.crossover(close, highUsePivot) and not(open - low > close - open) and osc > volumeThresh, title='Break', text='B', style=shape.labelup, location=location.belowbar, color=color.rgb(56, 198, 34), textcolor=color.new(color.white, 0), size=size.tiny)
//For bull / bear wicks
//plotshape(toggleBreaks and ta.crossover(close, highUsePivot) and open - low > close - open, title='Break', text='Bull Wick', style=shape.labelup, location=location.belowbar, color=color.rgb(56, 198, 34), textcolor=color.new(color.white, 0), size=size.tiny)
//plotshape(toggleBreaks and ta.crossunder(close, lowUsePivot) and open - close < high - open, title='Break', text='Bear Wick', style=shape.labeldown, location=location.abovebar, color=color.rgb(255, 82, 82), textcolor=color.new(color.white, 0), size=size.tiny)
//alertcondition(ta.crossunder(close, lowUsePivot) and osc > volumeThresh, title='Support Broken', message='Support Broken')
//alertcondition(ta.crossover(close, highUsePivot) and osc > volumeThresh, title='Resistance Broken', message='Resistance Broken')
src = input.source(title='Source', defval=close, group='CTI')
sm = input.int(27, title='Smoothing Period', group='CTI')
cd = input.float(1.4, title='Constant D', group='CTI')
bar_col = input.bool(false, title='Color Bars', inline='br', group='Color mode')
flat = input.color(title='Line', defval=color.new(color.blue, 0), inline='br', group='Color mode')
raise = input.color(title='Color', defval=color.new(color.green, 0), inline='col', group='Style')
fall = input.color(title='Color', defval=color.new(color.red, 0), inline='col', group='Style')
di = (sm - 1.0) / 2.0 + 1.0
c1 = 2 / (di + 1.0)
c2 = 1 - c1
c3 = 3.0 * (cd * cd + cd * cd * cd)
c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
var float i1 = na
var float i2 = na
var float i3 = na
var float i4 = na
var float i5 = na
var float i6 = na
i1 := c1 * src + c2 * nz(i1[1])
i2 := c1 * i1 + c2 * nz(i2[1])
i3 := c1 * i2 + c2 * nz(i3[1])
i4 := c1 * i3 + c2 * nz(i4[1])
i5 := c1 * i4 + c2 * nz(i5[1])
i6 := c1 * i5 + c2 * nz(i6[1])
Cto = -cd * cd * cd * i6 + c3 * i5 + c4 * i4 + c5 * i3
// --------------------------------------------------------------------------
// For the Pinescript coders: Determining trend based on the mintick step.
// --------------------------------------------------------------------------
//bfrC = Cto - nz(Cto[1]) > syminfo.mintick ? green : Cto - nz(Cto[1]) < syminfo.mintick ? red : blue
bfrC = Cto > nz(Cto[1]) ? raise : Cto < nz(Cto[1]) ? fall : na
tc = bar_col ? flat : bfrC
plot(Cto, title='Trend', linewidth=3, style=plot.style_stepline, color=tc, editable=false)
barcolor(bar_col ? bfrC : na, editable=false)
shift_up = bfrC[1] == fall and bfrC == raise
shift_dn = bfrC[1] == raise and bfrC == fall
plotshape(shift_up, title='Buy', text='.', textcolor=raise, style=shape.triangleup, location=location.belowbar, color=color.new(#2dac32, 0))
plotshape(shift_dn, title='Sell', text='.', textcolor=fall, style=shape.triangledown, location=location.abovebar, color=color.new(color.orange, 0))
//alertcondition(shift_up, title='Alert for Buy', message='Buy')
//alertcondition(shift_dn, title='Alert for Sell', message='Sell')
Yer İmleri