PHP Code:
//yörükten...başkaraya selamlarla......
//@version=5
indicator(".", overlay = true)
src = input(close, title="Source")
highlight = input(true, title="Highlighting?")
showSignals = input(true, title="Show Signals?")
Q1 = input.int(1, title="Q1")
Q2 = input.float(1, title="Q2")
Q3 = Q2/100
Q4 = ta.ema(src, Q1)
Q5 = 0.0
Q5 := (Q4*(1-Q3))>nz(Q5[1],0) ? Q4*(1-Q3) : (Q4*(1+Q3))<nz(Q5[1],0) ? Q4*(1+Q3) : nz(Q5[1],0)
Z1 = input.int(5, title="Z1")
Z2 = input.float(5, title="Z2")
Z3 = Z2/100
Z4 = ta.ema(src, Z1)
Z5 = 0.0
Z5 := (Z4*(1-Z3))>nz(Z5[1],0) ? Z4*(1-Z3) : (Z4*(1+Z3))<nz(Z5[1],0) ? Z4*(1+Z3) : nz(Z5[1],0)
BuySignal = ta.crossover(Q5,Z5)
SellSignal = ta.crossunder(Q5,Z5)
Q5pl=plot(int(Q5/1.025+1.50)*1.025, color=color.green, linewidth=1,title="Direnç")
Z5pl=plot(int(Z5/1.025+1.50)*1.025, color=color.red, linewidth=1,title="Destek")
//fill(Q5pl,Z5pl, color= highlight ? Q5>Z5 ? color.new(color.green,50) : color.new(color.red,50) : na)
//plotshape(showSignals and BuySignal, title="Buy Signal", style=shape.labelup, text="AL", textcolor=color.white, color=color.green, location=location.belowbar)
//plotshape(showSignals and SellSignal, title="Sell Signal", style=shape.labeldown, text="SAT", textcolor=color.white, color=color.red, location=location.abovebar)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ ToolTips {
t1 = "Volatility Period defines the length of the look-back period for calculating volatility. Higher values make the bands adapt more slowly to volatility changes. Lower values make them adapt more quickly."
t2 = "Trend Factor adjusts the sensitivity of the trend line to price movements. A higher value makes the trend line less sensitive and smoother. Lower values make it more sensitive and reactive to price changes."
t3 = "Trend Step controls how quickly the trend line adjusts to sudden price changes. Higher values cause slower adjustments, leading to smoother trend lines. Lower values result in quicker adjustments to sudden changes."
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Inputs {
volatilityPeriod = input.int(20, title="Period", step=10, minval=2, maxval=1000, inline="vol", group="Volatility Settings", tooltip=t1)
trendFactor = input.float(9, step=0.1, title='Factor', minval = 0.1, inline="", group="Trend Settings", tooltip=t2)
trendStep = input.float(1, "Step", step=0.1,minval = 0.5, maxval = 5.0, inline="", group="Trend Settings", tooltip=t3)
color_trend = input.color(color.rgb(209, 245, 3), title="Trend Line  ", inline="trend", group="Style")
colorForUpperBand = input.color(color.new(#862458, 10), title="Upper Band", inline="band", group="Style")
colorForLowerBand = input.color(color.new(#493893, 10), title="Lower Band", inline="band", group="Style")
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Initialize Variables
var float currentTrend = 0.0
var int trendDirection = 0
averageTrueRange = ta.atr(200)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Function to determine the trend direction
determineTrendDirection(direction) => direction - direction[1] > 0 ? 1 : (direction - direction[1] < 0 ? -1 : 0)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Calculate Trend Direction
closingPrice = close
scaledStandardDev = (nz(averageTrueRange) * trendFactor)
trendDirection := determineTrendDirection(currentTrend) * int(scaledStandardDev)
priceTrendDiff = closingPrice - currentTrend > 0 ? closingPrice - currentTrend : currentTrend - closingPrice
reciprocalFactor = (scaledStandardDev * (1 / trendFactor)) * 1 / math.pow(2, 100)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Calculate the Current Trend
trendAdjustment = priceTrendDiff > scaledStandardDev * trendStep ? math.avg(closingPrice, currentTrend) : trendDirection * reciprocalFactor + currentTrend
currentTrend := trendAdjustment
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Calculate Upper and Lower Bands
upperBand = currentTrend + scaledStandardDev - averageTrueRange - ta.ema(ta.stdev(closingPrice, volatilityPeriod), 200)
lowerBand = currentTrend - scaledStandardDev + averageTrueRange + ta.ema(ta.stdev(closingPrice, volatilityPeriod), 200)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
// ~~ Plot
isTrendConsistent = trendDirection == trendDirection[1]
colorForPlot = trendDirection == 1 ? color_trend : color_trend
plotTrend = plot(isTrendConsistent ? currentTrend : na, title="VTrend ", color=colorForPlot)
plotUpper = plot(isTrendConsistent ? upperBand : na, title="VDirenç", color = color.new(color.black, 100))
plotLower = plot(isTrendConsistent ? lowerBand : na, title="VDestek", color = color.new(color.black, 100))
//fill(plotUpper, plotTrend, top_color = colorForLowerBand, bottom_color =color.new(na,100), top_value = upperBand, bottom_value = currentTrend, title="Background Upper")
//fill(plotTrend, plotLower, top_color = color.new(na,100), bottom_color = colorForUpperBand, top_value = currentTrend, bottom_value = lowerBand, title="Background Lower")
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
//Trend Sar
psar(start1, inc1, maximum1) =>
out1 = float(na)
isUpTrend1 = bool(na)
maxMin1 = float(na)
acc1 = float(na)
prev1 = float(na)
if bar_index >= 1
prev1 := out1[1]
if bar_index == 1
if close > close[1]
isUpTrend1 := true
maxMin1 := math.max(high, high[1])
prev1 := math.min(low, low[1])
prev1
else
isUpTrend1 := false
maxMin1 := math.min(low, low[1])
prev1 := math.max(high, high[1])
prev1
acc1 := start1
acc1
else
isUpTrend1 := isUpTrend1[1]
acc1 := acc1[1]
maxMin1 := maxMin1[1]
maxMin1
if isUpTrend1
if high > maxMin1
maxMin1 := high
acc1 := math.min(acc1 + inc1, maximum1)
acc1
else
if low < maxMin1
maxMin1 := low
acc1 := math.min(acc1 + inc1, maximum1)
acc1
if na(out1)
out1 := prev1 + acc1 * (maxMin1 - prev1)
out1
if isUpTrend1
if low <= out1
isUpTrend1 := false
out1 := maxMin1
maxMin1 := low
acc1 := start1
acc1
else
if high >= out1
isUpTrend1 := true
out1 := maxMin1
maxMin1 := high
acc1 := start1
acc1
if na(out1)
if isUpTrend1
out1 := math.min(out1, bar_index == 1 ? low[1] : math.min(low[1], low[2]))
out1
else
out1 := math.max(out1, bar_index == 1 ? high[1] : math.max(high[1], high[2]))
out1
[out1, acc1, maxMin1, isUpTrend1]
start1 = input(0)
increment1 = input(0.01)
maximum1 = input(0.02)
[p1, AF1, EP1, isUpTrend1] = psar(start1, increment1, maximum1)
newEP1 = EP1 != EP1[1]
epNew1 = newEP1 ? EP1 : na
plot(p1, 'STrend', style=plot.style_stepline, color=isUpTrend1 ? color.rgb(25, 248, 5, 100) : color.rgb(243, 5, 5, 100), linewidth=1)
plot(EP1, 'STrend Devam', style=plot.style_circles, color=isUpTrend1 ? color.rgb(25, 248, 5, 100) : color.rgb(243, 5, 5, 100), linewidth=2)
/// sar hesaplamasını 1 dakika üzerinden bar renlendirmesi....
x1 = input.timeframe('1', title='Periyot')
z = ta.sar(0, 0.02, 0.02)
y1 = request.security(syminfo.tickerid, x1, z)
xz = input(true, title='Renk')
//Functions Sar for support and resistance
q3 = ta.sar(0.01, 0.02, 0.2)
q2 = ta.sar(0.01, 0.04, 0.4)
q1 = ta.sar(0.01, 0.06, 0.6)
plot(q3, title='UVSar', style=plot.style_circles, color=xz ? y1 > close ? color.red : color.lime : color.silver, linewidth=1)
plot(q2, title='OVSar', style=plot.style_circles, color=xz ? y1 > close ? color.red : color.lime : color.silver, linewidth=1)
plot(q1, title='KVSar', style=plot.style_circles, color=xz ? y1 > close ? color.red : color.lime : color.silver, linewidth=1)
//Signal
xyzq = (y1)
plot(xyzq, title='Yörük', style=plot.style_linebr, color=xz ? y1 > close ? color.rgb(255, 82, 82, 00) : color.rgb(0, 230, 119, 00) : color.silver, linewidth=1)
bcolor = ta.crossunder(close,q3) ? color.red : ta.crossover(close,q3) ? color.green: close>q2 ? color.green : close<q2 ? color.red: color.rgb(216, 4, 253) // : color.black
barcolor(bcolor)
////
//Function
inp = input(title='Source', defval=close)
res = input.timeframe(title='Resolution', defval='60')
rep = input(title='Allow Repainting?', defval=true)
//////////////////////////////////////////////////////
src1 = request.security(syminfo.tickerid, res, inp[rep ? 0 : barstate.isrealtime ? 1 : 0])[rep ? 0 : barstate.isrealtime ? 0 : 1]
fastLength1 = input.int(title='FastLength', defval=12, minval=1)
slowLength1 = input.int(title='SlowLength', defval=26, minval=1)
signalLength1 = input.int(title='SignalLength', defval=9, minval=1)
macdLevel1 = input.float(title='MacdLevel', defval=0, minval=0)
fastAlpha1 = 2.0 / (1 + fastLength1)
slowAlpha1 = 2.0 / (1 + slowLength1)
fastEma1 = ta.ema(src1, fastLength1)
slowEma1 = ta.ema(src1, slowLength1)
pMacdEq1 = fastAlpha1 - slowAlpha1 != 0 ? ((nz(fastEma1[1]) * fastAlpha1) - (nz(slowEma1[1]) * slowAlpha1)) / (fastAlpha1 - slowAlpha1) : 0
pMacdEqSig1 = ta.ema(pMacdEq1, signalLength1)
pMacdLevel1 = fastAlpha1 - slowAlpha1 != 0 ? (macdLevel1 - (nz(fastEma1[1]) * (1 - fastAlpha1)) + (nz(slowEma1[1]) * (1 - slowAlpha1))) / (fastAlpha1 - slowAlpha1) : 0
slo1 = src1 - pMacdEq1
sig1 = slo1 > 0 ? slo1 > nz(slo1[1]) ? 2 : 1 : slo1 < 0 ? slo1 < nz(slo1[1]) ? -2 : -1 : 0
rmacdColor = sig1 > 1 ? color.rgb(0, 230, 119, 100) : sig1 > 0 ? color.rgb(0, 230, 119, 100) : sig1 < -1 ? color.rgb(255, 82, 82, 100) : sig1 < 0 ? color.rgb(255, 82, 82, 100) : color.white
plot(pMacdEq1, title='MacdTrend',style=plot.style_stepline, color=rmacdColor, linewidth=2)
plot(pMacdEqSig1, title='MacdStop', color=color.rgb(255, 255, 255, 100), linewidth=1)
///////////////////////////////////////////////////////////////////////////
Yer İmleri