OPEN-SOURCE SCRIPT

Samet-AL SAT SinyaL

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © Samce

//version=5

indicator(title='Samet-AL SAT SinyaL', shorttitle='Samet-AL SAT SinyaL', overlay=true)


pSARbeginningValue = input.int(2, minval=0, maxval=10, title='PSAR başlangıç değeri')
pSARendValue = input.int(2, minval=1, maxval=10, title='PSAR bitiş değeri')
pSARmultiplierValue = input.int(2, minval=0, maxval=10, title=' PSAR katsayi değeri')

pSARbeginningMethod = pSARbeginningValue * .01
pSARendMethod = pSARendValue * .10
pSARmultiplierMethod = pSARmultiplierValue * .01

pSAR_UpValue = ta.sar(pSARbeginningMethod, pSARmultiplierMethod, pSARendMethod)
pSAR_DownValue = ta.sar(pSARbeginningMethod, pSARmultiplierMethod, pSARendMethod)

pSAR_UpColor = close >= pSAR_DownValue ? color.green : na
pSAR_DownColor = close <= pSAR_UpValue ? color.red : na

plot(pSAR_UpValue ? pSAR_UpValue : na, style=plot.style_columns, color=pSAR_UpColor, linewidth=0, title='PSAR yukarı', transp=85)
plot(pSAR_DownValue ? pSAR_DownValue : na, style=plot.style_columns, color=pSAR_DownColor, linewidth=1, title='PSAR aşağı', transp=85)

//Zone Identification - This is once again ATR based method to identify the zone based on its strength

zoneSource = input(hl2, title='Kaynak')
src = input(hl2, title='Kaynak')
zoneLength = input(defval=10, title='ATR Alan Uzunluğu')
zoneMultiplier = input.float(defval=3.0, step=0.1, title='ATR Alan Katsayısı')
zoneATR = ta.atr(zoneLength)

downZone = zoneSource + zoneMultiplier * zoneATR
downZoneNew = nz(downZone[1], downZone)
downZone := close[1] < downZoneNew ? math.min(downZone, downZoneNew) : downZone
upZone = zoneSource - zoneMultiplier * zoneATR
upZoneNew = nz(upZone[1], upZone)
upZone := close[1] > upZoneNew ? math.max(upZone, upZoneNew) : upZone

zoneDecider = 1
zoneDecider := nz(zoneDecider[1], zoneDecider)
zoneDecider := zoneDecider == -1 and close > downZoneNew ? 1 : zoneDecider == 1 and close < upZoneNew ? -1 : zoneDecider

redZone = zoneDecider == -1 and zoneDecider[1] == 1
greenZone = zoneDecider == 1 and zoneDecider[1] == -1
downZoneColor = zoneDecider == -1 ? color.red : color.gray
upZoneColor = zoneDecider == 1 ? color.green : color.gray

downZonePlot = plot(zoneDecider == 1 ? na : downZone, style=plot.style_linebr, linewidth=2, color=color.new(color.red, 0), title='Düşüş Bölgesi')

plotshape(redZone ? downZone : na, location=location.absolute, style=shape.diamond, size=size.tiny, color=color.new(color.red, 0), title='Düşüş Bölgesi Başlangıçı')
plotshape(redZone ? downZone : na, location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), title='SAT', text='Samet/ SAT(short)')

upZonePlot = plot(zoneDecider == 1 ? upZone : na, style=plot.style_linebr, linewidth=2, color=color.new(color.green, 0), title='Yükseliş Bölgesi')

plotshape(greenZone ? upZone : na, location=location.absolute, style=shape.diamond, size=size.tiny, color=color.new(color.green, 0), title='Yükseliş Bölgesi Başlangıçı')
plotshape(greenZone ? upZone : na, location=location.belowbar, style=shape.labelup, size=size.tiny, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), title='AL', text='Samet/ AL(long)')

aldigimfiyat = str.tostring(ta.valuewhen(greenZone, zoneSource, 0))
sattigimfiyat = str.tostring(ta.valuewhen(redZone, zoneSource, 0))

Buy = greenZone
Sell = redZone
if greenZone == 1
l = label.new(bar_index, na)
label.set_text(l, aldigimfiyat)
label.set_color(l, color.green)
label.set_yloc(l, yloc.belowbar)
label.set_style(l, label.style_label_up)
if redZone == 1
l = label.new(bar_index, na)
label.set_text(l, sattigimfiyat)
label.set_color(l, color.red)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_label_down)

neutralZonePlot = plot(ohlc4, style=plot.style_circles, linewidth=0, title='Alan Stili')
fill(neutralZonePlot, downZonePlot, color=downZoneColor, title='Düşüş Rengi', transp=90)
fill(neutralZonePlot, upZonePlot, color=upZoneColor, title='Yükseliş Rengi', transp=90)


emaLowerPeriod = input.int(9, minval=1, title='EMA Düşük Periyotlar için')

emaLower = ta.ema(input(close), emaLowerPeriod)

plot(emaLower, color=color.new(color.fuchsia, 0), linewidth=2, title='EMA Düşük Periyot')

showEMA2 = input(false, title='EMA - Orta Periyotlar için')

emaMediumPeriod = input.int(27, minval=1, title='EMA Orta Periyotlar için')

emaMedium = ta.ema(input(close), emaMediumPeriod)

plot(showEMA2 and emaMedium ? emaMedium : na, color=color.new(color.aqua, 0), linewidth=2, title='EMA Orta Periyotlar için')


hmaLongPeriod = input.int(200, minval=1, title='HMA Uzun Periyotlar için')

hmaLong = ta.hma(input(close), hmaLongPeriod)

plot(hmaLong, color=color.new(color.gray, 0), linewidth=2, title='HMA Uzun Periyotlar için')


isCloseAbove = close > emaLower and close > hmaLong
isCloseBelow = close < emaLower and close < hmaLong
isCloseBetween = close > emaLower and close < hmaLong or close < emaLower and close > hmaLong

isNeutral = close > pSAR_DownValue and isCloseBelow or close < pSAR_DownValue and isCloseAbove


barcolor(isNeutral or isCloseBetween ? color.yellow : isCloseBelow ? color.red : isCloseAbove ? color.green : color.black)


position = input(500)
h = ta.highest(position)
info_label_off = input(50, title='Bilgilendirme paneli gösterilsin mi?')
info_label_size = input.string(size.normal, options=[size.tiny, size.small, size.normal, size.large, size.huge], title='Info panel label size')
info_panel_x = timenow + math.round(ta.change(time) * 10)
info_panel_y = h
info_current_close = '\n\nSON KAPANIŞ : ' + str.tostring(close)

disp_panels1 = input(true, title='ALIŞ BİLGİLENDİRME PANELİ İSTİYORMUSUNUZ?')
disp_panels2 = input(true, title='SATIŞ BİLGİLENDİRME PANELİ İSTİYORMUSUNUZ?')

Long = '-=-=-ALIŞ DETAY-=-=- '
Short = '-=-=-SATIŞ DETAY-=-=- '

pp1 = '\nAldıktan sonra geçen BAR : ' + str.tostring(ta.barssince(Buy), '##.##')
pp2 = '\nSattıktan sonra geçen BAR : ' + str.tostring(ta.barssince(Sell), '##.##')

Buyprice = '\nSatın aldığımız fiyat : ' + str.tostring(ta.valuewhen(Buy, src, 0), '##.##') + ''
ProfitLong = '\nKAR : ' + '(' + str.tostring(100 * ((src - ta.valuewhen(Buy, src, 0)) / ta.valuewhen(Buy, src, 0)), '##.##') + '%' + ')'

Sellprice = '\nSatın aldığımız fiyat : ' + str.tostring(ta.valuewhen(Sell, src, 0), '##.##') + ''
ProfitShort = '\nKAR : ' + '(' + str.tostring(100 * ((ta.valuewhen(Sell, src, 0) - src) / ta.valuewhen(Sell, src, 0)), '##.##') + '%' + ')'

info_textlongbuy = Long + info_current_close + pp1 + Buyprice + ProfitLong
info_textlongsell = Short + info_current_close + pp2 + Sellprice + ProfitShort
info_panellongbuy = zoneDecider == 1 and disp_panels1 ? label.new(x=info_panel_x, y=info_panel_y, text=info_textlongbuy, xloc=xloc.bar_time, yloc=yloc.price, color=color.green, style=label.style_label_up, textcolor=color.black, size=info_label_size) : na
info_panellongsell = zoneDecider == -1 and disp_panels2 ? label.new(x=info_panel_x, y=info_panel_y, text=info_textlongsell, xloc=xloc.bar_time, yloc=yloc.price, color=color.red, style=label.style_label_up, textcolor=color.black, size=info_label_size) : na
label.delete(info_panellongbuy[1])
label.delete(info_panellongsell[1])

Bands and ChannelsExponential Moving Average (EMA)Parabolic Stop and Reverse (PSAR)

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer