Pine Script collection
الذهاب إلى القناة على Telegram
I don't know the copyright of these scripts. Just collected for testing and educational purposes Use at your own risk I don't accept any responsibility...
إظهار المزيدلم يتم تحديد البلدالفئة غير محددة
2 310
المشتركون
لا توجد بيانات24 ساعات
لا توجد بيانات7 أيام
لا توجد بيانات30 أيام
أرشيف المشاركات
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LonesomeTheBlue
//@version=4
study("Price Change Rate by Pivot Points - Dynamic", overlay=true, max_bars_back = 2000)
prd = input(defval = 30, title="Pivot Point Period", minval = 5, maxval = 100)
showpivot = input(defval = true, title="Show Pivot Points")
showret = input(defval = true, title="Show retracement")
showprice = input(defval = false, title="Show Prices")
showline = input(defval = true, title="Show Lines")
showoncurr = input(defval = false, title="Show Label on current High/Low")
float ph = na, float pl = na
ph := pivothigh(prd, prd)
pl := pivotlow(prd, prd)
plotshape(ph and showpivot, text="H", style=shape.labeldown, color=na, textcolor=color.blue, location=location.abovebar, transp=0, offset = -prd)
plotshape(pl and showpivot, text="L", style=shape.labeldown, color=na, textcolor=color.blue, location=location.belowbar, transp=0, offset = -prd)
_highest(len) =>
_hi = high
_hloc = 0
for i = 1 to len -1
if na(high[i])
break
if nz(high[i]) > _hi
_hi := nz(high[i])
_hloc := i
[_hi, _hloc]
_lowest(len) =>
_lo = low
_hloc = 0
for i = 1 to len -1
if na(low[i])
break
if nz(low[i]) < _lo
_lo := nz(low[i])
_hloc := i
[_lo, _hloc]
hcont = true
hcont := pl ? false : nz(hcont[1], true)
lcont = true
lcont := ph ? false : nz(lcont[1], true)
float lastphi = na, float lastplo = na
hiloc = 0, loloc = 0
lastphi := nz(lastphi[1])
lastplo := nz(lastplo[1])
hiloc := nz(hiloc[1]) + 1
loloc := nz(loloc[1]) + 1
hchg = false
if ph
if (hcont and lastphi != 0 and ph > lastphi) or not hcont
hchg := (hcont and lastphi != 0 and ph > lastphi)
lastphi := ph
hiloc := prd
hcont := true
lchg = false
if pl
if (lcont and lastplo != 0 and pl < lastplo) or not lcont
lchg := (lcont and lastplo != 0 and pl < lastplo)
lastplo := pl
loloc := prd
lcont := true
[lwd, h_locd] = _lowest(hiloc)
var line lnd = na
var label lbd = na
if hiloc != 0 and lastphi != 0
if change(lastphi) == 0 or hchg
line.delete(lnd)
label.delete(lbd)
if showline
lnd := line.new(bar_index - hiloc, lastphi, showoncurr ? bar_index - h_locd : bar_index - hiloc, lwd, color = color.red, style = line.style_arrow_right)
prctxt = showprice ? tostring(lastphi) + "\n" + tostring(lwd) + "\n" : ""
ret = ""
ret := ret[1]
ret := showret ? hcont ? tostring((lastphi - lwd) / (lastphi - lastplo), '#.###') + "\n" : ret : ""
txt = prctxt + ret + "-% " + tostring(((lastphi - lwd) / lastphi) * 100, '#.#')
lbd := label.new(showoncurr ? bar_index - h_locd : bar_index - hiloc, lwd, text = txt, color = color.red, textcolor = color.white, style = label.style_label_up)
[lwu, h_locu] = _highest(loloc)
var line lnu = na
var label lbu = na
if loloc != 0 and lastplo != 0
if change(lastplo) == 0 or lchg
line.delete(lnu)
label.delete(lbu)
if showline
lnu := line.new(bar_index - loloc, lastplo, showoncurr ? bar_index - h_locu : bar_index - loloc, lwu, color = color.lime, style = line.style_arrow_right)
prctxt = showprice ? tostring(lastplo) + "\n" + tostring(lwu) + "\n" : ""
ret = ""
ret := ret[1]
ret := showret ? lcont ? tostring((lwu - lastplo) / (lastphi - lastplo), '#.###') + "\n" : ret : ""
txt = prctxt + ret + "+% " + tostring(((lwu - lastplo) / lastplo) * 100, '#.#')
lbu := label.new(showoncurr ? bar_index - h_locu : bar_index - loloc, lwu, text = txt, color = color.lime, textcolor = color.black, style = label.style_label_down)study(title = "TheLark Relative Momentum Index (RMI)",overlay=false)
// Relative Momentum Index (RMI)
// "... The Relative Momentum Index was developed by Roger Altman
// and was introduced in his article in the February, 1993 issue of
// Technical Analysis of Stocks & Commodities magazine. "
// "... While RSI counts up and down days from close to close, the Relative
// Momentum Index counts up and down days from the close relative to a
// close x number of days ago. "
// Requested by glaz @ TradingView
// inputs
len = input(20, title="Length")
mom = input(4, title="Momentum",minval=0)
ob = input(70,title="Overbought")
os = input(30,title="Oversold")
c = close
docol = input(true,title="Change Color?")
dosignal = input(true,title="Show Signal Line?")
sig = input(6,title="Signal Length")
dohist = input(false,title="Show Hist?")
//calc
up = ema(max(c - c[mom],0),len)
dn = ema(max(c[mom] - c,0),len)
rmi = dn == 0 ? 0 : 100 - 100 / (1 + up / dn)
signal = sma(rmi,sig)
//plots
hline(ob)
hline(os)
plot(dohist?(rmi-signal)+50:na,color=#FF006E,histbase=50,style=histogram,linewidth=2)
plot(dosignal?signal:na,color=#D87A68)
col = docol ? rmi > rmi[1] ? #0094FF : #FF006E : #0094FF
plot(rmi, color=col,linewidth=2)//@version=4
study(" linear regression support and resistance",overlay=true)
//code for linear taken from pine script manual
multiplier = input(title="Bollinger Deviation", type=input.float, defval=2, minval=1)
src = input(close)
len = input(100)
offset = 0
calcSlope(src, len) =>
sumX = 0.0
sumY = 0.0
sumXSqr = 0.0
sumXY = 0.0
for i = 1 to len
val = src[len-i]
per = i + 1.0
sumX := sumX + per
sumY := sumY + val
sumXSqr := sumXSqr + per * per
sumXY := sumXY + val * per
slope = (len * sumXY - sumX * sumY) / (len * sumXSqr - sumX * sumX)
average = sumY / len
intercept = average - slope * sumX / len + slope
[slope, average, intercept]
var float tmp = na
[s, a, i] = calcSlope(src, len)
linear=(i + s * (len - offset))
sdev = stdev(close, len)
dev = multiplier * sdev
top=linear+dev
bott=linear-dev
calculationToPlotAverageMeanLine=linear
useUpperDeviation = input(true, "Upper Deviation", input.bool)
useLowerDeviation = input(true, "Lower Deviation", input.bool)
calculationToPlotUpperLine=top
calculationToPlotLowerLine=bott
plotUpperDeviationLine = plot(not useUpperDeviation ? na : calculationToPlotUpperLine, color=color.blue)
plotAverageMeanLine = plot(calculationToPlotAverageMeanLine, color=color.olive)
plotLowererDeviationLine = plot(not useLowerDeviation ? na : calculationToPlotLowerLine, color=color.red)
fill(plotUpperDeviationLine, plotAverageMeanLine, color=color.blue)
fill(plotLowererDeviationLine, plotAverageMeanLine, color=color.red)
//
length10 = input(title="Bollinger Length", type=input.integer, defval=34, minval=1)
overbought = input(title="Overbought", type=input.integer, defval=1, minval=1)
oversold = input(title="Oversold", type=input.integer, defval=0, minval=1)
smabasis = linear
stdev = stdev(close, length10)
cierre = close
alta = high
baja = low
basis1 = smabasis
stdevb = stdev
dev5 = multiplier * stdevb // stdev(cierre, length)
upper = basis1 + dev5
lower5 = basis1 - dev5
bbr = (cierre - lower5) / (upper - lower5)
// plot(bbr)
// // MARCA LAS RESISTENCIAS
pintarojo = 0.0
pintarojo := nz(pintarojo[1])
pintarojo := bbr[1] > overbought and bbr < overbought ? alta[1] : nz(pintarojo[1])
p = plot(pintarojo, color=color.red, style=plot.style_circles, linewidth=2)
// // MARCA LOS SOPORTES
pintaverde = 0.0
pintaverde := nz(pintaverde[1])
pintaverde := bbr[1] < oversold and bbr > oversold ? baja[1] : nz(pintaverde[1])
g = plot(pintaverde, color=color.black, style=plot.style_circles, linewidth=2)
//
// Rounding levels to min tick
nround(x) =>
n = round(x / syminfo.mintick) * syminfo.mintick
//
disp_panels = input(true, title="Display info panels?")
linear_label_off = input(10, title="linear label offset")
linear_label_size = input(size.normal, options=[size.tiny, size.small, size.normal, size.large, size.huge], title="linear label size")
r1_x = timenow + round(change(time)*linear_label_off)
r1_y = pintarojo
text1 = "linear Resistance : " + tostring(nround(pintarojo))
s1_y = pintaverde
text3 = "linear Support : " + tostring(nround(pintaverde))
R1_label = disp_panels ? label.new(x=r1_x, y=r1_y, text=text1, xloc=xloc.bar_time, yloc=yloc.price, color=color.orange, style=label.style_labelup, textcolor=color.black, size=linear_label_size) : na
S1_label = disp_panels ? label.new(x=r1_x, y=s1_y, text=text3, xloc=xloc.bar_time, yloc=yloc.price, color=color.lime, style=label.style_labelup, textcolor=color.black, size=linear_label_size) : na
label.delete(R1_label[1])
label.delete(S1_label[1])//@version=4
study(title="Triple MA&EMA + Ichimoku + Scalper's Channel", shorttitle="_", overlay=true)
//MA+EMA
sma0_len = input(20, minval=1, title="SMA 20")
sma0_src = input(close, title="Source")
smaA_len = input(50, minval=1, title="SMA 50")
smaA_src = input(close, title="Source")
smaB_len = input(100, minval=1, title="SMA 100")
smaB_src = input(close, title="Source")
smaC_len = input(200, minval=1, title="SMA 200")
smaC_src = input(close, title="Source")
emaA_len = input(50, minval=1, title="EMA 50")
emaA_src = input(close, title="Source")
emaB_len = input(100, minval=1, title="EMA 100")
emaB_src = input(close, title="Source")
emaC_len = input(200, minval=1, title="EMA 200")
emaC_src = input(close, title="Source")
sma0 = sma(sma0_src, sma0_len)
smaA = sma(smaA_src, smaA_len)
smaB = sma(smaB_src, smaB_len)
smaC = sma(smaC_src, smaC_len)
emaA = ema(emaA_src, emaA_len)
emaB = ema(emaB_src, emaB_len)
emaC = ema(emaC_src, emaC_len)
plot(sma0, color=#FF0000, title="MA 20")
plot(smaA, color=#FF0000, title="MA 50")
plot(smaB, color=#FF0000, title="MA 100")
plot(smaC, color=#FF0000, title="MA 200")
plot(emaA, color=#3EA0E0, title="EMA 50")
plot(emaB, color=#3EA0E0, title="EMA 100")
plot(emaC, color=#3EA0E0, title="EMA 200")
//ICHIMOKU
conversionPeriods = input(9, minval=1, title="Conversion Line Periods"),
basePeriods = input(26, minval=1, title="Base Line Periods")
laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Periods"),
displacement = input(26, minval=1, title="Displacement")
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
plot(conversionLine, color=#0496ff, title="Conversion Line")
plot(baseLine, color=#991515, title="Base Line")
plot(close, offset = -displacement, color=#459915, title="Lagging Span")
p1 = plot(leadLine1, offset = displacement, color=color.green,
title="Lead 1")
p2 = plot(leadLine2, offset = displacement, color=color.red,
title="Lead 2")
fill(p1, p2, color = leadLine1 > leadLine2 ? color.green : color.red)
//SCALPER'S CHANNEL
scalpers_length = input(20)
scalpers_factor = input(15)
pi = atan(1)*4
Average(x,y) => (sum(x,y) / y)
scalper_line= plot(Average(close, scalpers_factor) - log(pi * (atr(scalpers_factor))), color=color.blue, linewidth=3)
hi = plot (highest(scalpers_length), color=color.fuchsia)
lo = plot (lowest(scalpers_length), color=color.fuchsia)//@version=4
//This is an approach to get the PDH and PDL using the 15 min time frame
study("Pre-market high/low", "", true)
begHour = input(9, "Beginning time (hour)")
begMinute = input(0, "Beginning time (minute)")
endHour = input(15, "End time (hour)")
endMinute = input(00, "End time (minute)")
// Lower TF we are inspecting. Cannot be in seconds and must be lower that chart's resolution.
insideRes = input("15", type = input.resolution, title = "Intrabar resolution used")
startMinute = (begHour * 60) + begMinute
finishMinute = (endHour * 60) + endMinute
f_highBetweenTime(_start, _finish) =>
// Returns low between specific times.
var float _return = 0.
var _reset = true
_minuteNow = (hour * 60) + minute
if _minuteNow >= _start and _minuteNow <= _finish
// We are inside period.
if _reset
// We are at first bar inside period.
_return := high
_reset := false
else
_return := max(_return, high)
else
// We are past period; enable reset for when we next enter period.
_reset := true
_return
f_lowBetweenTime(_start, _finish) =>
// Returns low between specific times.
var float _return = 10e10
var _reset = true
_minuteNow = (hour * 60) + minute
if _minuteNow >= _start and _minuteNow <= _finish
// We are inside period.
if _reset
// We are at first bar inside period.
_return := low
_reset := false
else
_return := min(_return, low)
else
// We are past period; enable reset for when we next enter period.
_reset := true
_return
highAtTime = security(syminfo.tickerid, insideRes, f_highBetweenTime(startMinute, finishMinute))
lowAtTime = security(syminfo.tickerid, insideRes, f_lowBetweenTime(startMinute, finishMinute))
var PDH = 0.0
if hour == endHour and minute == endMinute
PDH := highAtTime
var PDL = 0.0
if hour == endHour and minute == endMinute
PDL := lowAtTime
plot(PDH, "High", color.green, style = plot.style_stepline)
plot(PDL, "Low", color.red, style = plot.style_stepline)//@version=4
strategy("Stoch Forex Strategy")
///// Backtest Start Date /////
startDate = input(title="Start Date", type=input.integer, defval=1, minval=1, maxval=31)
startMonth = input(title="Start Month", type=input.integer, defval=1, minval=1, maxval=12)
startYear = input(title="Start Year", type=input.integer, defval=2020, minval=1800, maxval=2100)
afterStartDate = (time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0))
// Stochastics //
periodK = input(14, title="K", minval=1)
periodD = input(3, title="D", minval=1)
smoothK = input(3, title="Smooth", minval=1)
k = sma(stoch(close, high, low, periodK), smoothK)
d = sma(k, periodD)
///// Submit orders /////
strategy.entry("Long", strategy.long, when = afterStartDate and crossover(k, 10) and k<20)
strategy.close("Long", when = afterStartDate and crossunder(k, d) and k>70)
///// Plot Stochastic Values and Lines /////
plot(k, title="%K", color=#ff0000)
plot(d, title="%D", color=#00ff00)
h0 = hline(90)
h1 = hline(10)study(title="5 indicators in 1 ", shorttitle="5 in 1", overlay=false) swa=input(false,title="AROON") length = input(14, minval=1) upper = 100 * (highestbars(high, length+1) + length)/length lower = 100 * (lowestbars(low, length+1) + length)/length midp = 0 oscillator = upper - lower osc = plot(swa? oscillator:na, color=red) mp = plot(swa?midp:na) top = plot(swa?85:na) bottom = plot(swa?-85:na) co=oscillator>=95 and oscillator[1]>=oscillator?red :oscillator<=-88 ?green:na bgcolor(swa?co:na,transp=70) fill(osc, mp) fill(top,bottom) //rsi swr=input(true,title="RSI") src = close, len = input(14, minval=1, title="Length RSI") srs=input(5, minval=1, title="Length sma RSI") up = rma(max(change(src), 0), len) down = rma(-min(change(src), 0), len) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) mr=sma(rsi,srs) plot(swr?rsi:na,title="RSI", color=purple,transp=0) plot(swr?mr:na,title="sma RSI", color=red,transp=0) //macd swm=input(false,title="MACD") source = close fastLength = input(12, minval=1), slowLength=input(26,minval=1) signalLength=input(9,minval=1) fastMA = ema(source, fastLength) slowMA = ema(source, slowLength) macd = fastMA - slowMA signal = ema(macd, signalLength) hist = macd - signal plot(swm?hist:na, color=red, style=histogram) plot(swm?macd:na, color=blue) plot(swm?signal:na, color=orange) //stoc sws=input(false,title="STOCHASTIC") periodK = input(14, title="K", minval=1) periodD = input(3, title="D", minval=1) smoothK = input(3, title="Smooth", minval=1) k = sma(stoch(close, high, low, periodK), smoothK) d = sma(k, periodD) plot(sws?k:na, title="%K", color=blue) plot(sws?d:na, title="%D", color=orange) h0 =plot(sws or swr?80:na) h1 = plot(sws or swr?20:na) fill(h0, h1, color=purple, transp=75) //ADX swx=input(false,title="ADX DI") lenx = input(14, minval=1, title="DI Length") lensig = input(14, title="ADX Smoothing", minval=1, maxval=50) th = input(title="threshold", type=integer, defval=25) upx = change(high) downx = -change(low) plusDM = na(upx) ? na : (upx > downx and upx > 0 ? upx : 0) minusDM = na(downx) ? na : (downx > upx and downx > 0 ? downx : 0) trur = rma(tr, lenx) plus = fixnan(100 * rma(plusDM, lenx) / trur) minus = fixnan(100 * rma(minusDM, lenx) / trur) sum = plus + minus adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), lensig) plot(swx?plus:na, color=blue, title="+DI") plot(swx?minus:na, color=orange, title="-DI") plot(swx?adx:na, color=red, title="ADX") plot(swx?th:na, color=black, title="th")
//@version=4
//@author=Daveatt
StudyName = "BEST Supertrend CCI"
ShortStudyName = "BEST Supertrend CCI"
study(StudyName, shorttitle=ShortStudyName, overlay=true, precision=6)
//////////////////////////
//* COLOR CONSTANTS *//
//////////////////////////
AQUA = #00FFFFFF
BLUE = #0000FFFF
RED = #FF0000FF
LIME = #00FF00FF
GRAY = #808080FF
DARKRED = #8B0000FF
DARKGREEN = #006400FF
GOLD = #FFD700
WHITE = color.white
// Plots
GREEN_LIGHT = color.new(color.green, 40)
RED_LIGHT = color.new(color.red, 40)
BLUE_LIGHT = color.new(color.aqua, 40)
PURPLE_LIGHT = color.new(color.purple, 40)
source = input(close)
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// CCI /////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
cci_period = input(14, "CCI Period")
cci = cci(source, cci_period)
//UL = input(80, "Upper level")
//LL = input(20, "Lower Level")
ML = input(0, "CCI Mid Line pivot")
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////// SUPERTREND /////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
Factor=input(1,title="[ST] Factor", minval=1,maxval = 100, type=input.float)
Pd=input(3, title="[ST] PD", minval=1,maxval = 100)
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/////////////////////// SUPERTREND DETECTION //////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
f_supertrend(Factor, Pd) =>
Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
TrendUp = 0.0
TrendUp := cci[1] > ML ? max(Up,TrendUp[1]) : Up
TrendDown = 0.0
TrendDown := cci[1]< ML ? min(Dn,TrendDown[1]) : Dn
Trend = 0.0
Trend := cci > ML ? 1: cci < ML ? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown
Tsl
st_tsl = f_supertrend(Factor, Pd)
// Plot the ST
linecolor = close >= st_tsl ? color.green : color.red
plot(st_tsl, color = linecolor , linewidth = 4,title = "SuperTrend", transp=0)
//hline(UL, title="Upper Line", linestyle=hline.style_solid, linewidth=1, color=color.red)
//hline(LL, title="Lower Line", linestyle=hline.style_solid, linewidth=1, color=color.lime)
//hline(ML, title="Mid Line", linestyle=hline.style_solid, linewidth=2, color=color.gray)Hello traders
Today I present you a Supertrend not based on candle close but based on a CCI ( Commodity Channel Index )
How does it work?
Bull event: CCI crossing over the 0 line
Bear event: CCI crossing below the 0 line
When the event is triggered, the script will plot the Supertrend as follow
UP Trend = High + ATR * Factor
DOWN Trend = Low - ATR * Factor
This is an alternative of the classical Supertrend based on candle close being above/beyond the previous Supertrend level.
Hope you'll enjoy it and it will improve your trading making you a better trader
Dave
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LonesomeTheBlue
//@version=4
study("Pivot Point SuperTrend", overlay = true)
prd = input(defval = 2, title="Pivot Point Period", minval = 1, maxval = 50)
Factor=input(defval = 3, title = "ATR Factor", minval = 1, step = 0.1)
Pd=input(defval = 10, title = "ATR Period", minval=1)
showpivot = input(defval = false, title="Show Pivot Points")
showlabel = input(defval = true, title="Show Buy/Sell Labels")
showcl = input(defval = false, title="Show PP Center Line")
showsr = input(defval = false, title="Show Support/Resistance")
float ph = na
float pl = na
ph := pivothigh(prd, prd)
pl := pivotlow(prd, prd)
plotshape(ph and showpivot, text="H", style=shape.labeldown, color=na, textcolor=color.red, location=location.abovebar, transp=0, offset = -prd)
plotshape(pl and showpivot, text="L", style=shape.labeldown, color=na, textcolor=color.lime, location=location.belowbar, transp=0, offset = -prd)
float center = na
center := center[1]
float lastpp = ph ? ph : pl ? pl : na
if lastpp
if na(center)
center := lastpp
else
center := (center * 2 + lastpp) / 3
Up = center - (Factor * atr(Pd))
Dn = center + (Factor * atr(Pd))
float TUp = na
float TDown = na
Trend = 0
TUp := close[1] > TUp[1] ? max(Up, TUp[1]) : Up
TDown := close[1] < TDown[1] ? min(Dn, TDown[1]) : Dn
Trend := close > TDown[1] ? 1: close < TUp[1]? -1: nz(Trend[1], 1)
Trailingsl = Trend == 1 ? TUp : TDown
linecolor = Trend == 1 and nz(Trend[1]) == 1 ? color.lime : Trend == -1 and nz(Trend[1]) == -1 ? color.red : na
plot(Trailingsl, color = linecolor , linewidth = 2, title = "PP SuperTrend")
plot(showcl ? center : na, color = showcl ? center < hl2 ? color.blue : color.red : na, transp = 0)
bsignal = Trend == 1 and Trend[1] == -1
ssignal = Trend == -1 and Trend[1] == 1
plotshape(bsignal and showlabel ? Trailingsl : na, title="Buy", text="Buy", location = location.absolute, style = shape.labelup, size = size.tiny, color = color.lime, textcolor = color.black, transp = 0)
plotshape(ssignal and showlabel ? Trailingsl : na, title="Sell", text="Sell", location = location.absolute, style = shape.labeldown, size = size.tiny, color = color.red, textcolor = color.white, transp = 0)
float resistance = na
float support = na
support := pl ? pl : support[1]
resistance := ph ? ph : resistance[1]
plot(showsr and support ? support : na, color = showsr and support ? color.lime : na, style = plot.style_circles, offset = -prd)
plot(showsr and resistance ? resistance : na, color = showsr and resistance ? color.red : na, style = plot.style_circles, offset = -prd)
alertcondition(Trend == 1 and Trend[1] == -1, title='Buy Signal', message='Buy Signal')
alertcondition(Trend == -1 and Trend[1] == 1, title='Sell Signal', message='Sell Signal')
alertcondition(change(Trend), title='Trend Changed', message='Trend Changed')