-
https://tr.tradingview.com/script/ITCgiV4j/
Super Oscilador by Rouro
PHP Code:
//@version=5
indicator("Super Oscilador by Rouro", overlay=false)
// === INPUTS DE INDICADORES ===
rsiPeriod = input.int(14, title="RSI - Periodo")
stochKPeriod = input.int(14, title="Stochastic %K - Periodo")
cciPeriod = input.int(20, title="CCI - Periodo")
rocPeriod = input.int(10, title="ROC - Periodo")
willrPeriod = input.int(14, title="Williams %R - Periodo")
rsiOver = input.int(70, title="RSI - Sobrecompra")
rsiUnder = input.int(30, title="RSI - Sobreventa")
stochOver = input.int(80, title="Stochastic - Sobrecompra")
stochUnder = input.int(20, title="Stochastic - Sobreventa")
cciOver = input.int(100, title="CCI - Sobrecompra")
cciUnder = input.int(-100, title="CCI - Sobreventa")
// ROC manual (por si no se usa ATR)
rocManualOver = input.float(0.5, title="ROC % Sobrecompra (manual)")
rocManualUnder = input.float(-0.5, title="ROC % Sobreventa (manual)")
// Selector de método dinámico
useATR = input.bool(true, title="Usar ATR para ROC dinámico")
atrPeriod = input.int(14, title="ATR - Periodo para ROC")
atrFactor = input.float(1.0, title="Factor ATR → umbral ROC")
willrOver = input.int(-20, title="Williams %R - Sobrecompra")
willrUnder = input.int(-80, title="Williams %R - Sobreventa")
// OPCIONES VISUALES
mostrarLineaBase = input.bool(false, title="Mostrar línea base")
emaSuavizado = input.int(5, title="Periodo de suavizado EMA")
nivelInferior = input.float(-0.8, title="Nivel Inferior (Sobreventa)")
nivelSuperior = input.float( 0.8, title="Nivel Superior (Sobrecompra)")
// === CÁLCULO DE INDICADORES ===
rsiVal = ta.rsi(close, rsiPeriod)
stochVal = ta.stoch(high, low, close, stochKPeriod)
cciVal = ta.cci(close, cciPeriod)
rocVal = ta.roc(close, rocPeriod) // ROC en %
den = ta.highest(high, willrPeriod) - ta.lowest(low, willrPeriod)
willrVal = den != 0 ? -100 * (ta.highest(high, willrPeriod) - close) / den : na
// === CÁLCULO ROC dinámico vía ATR ===
atrPct = ta.atr(atrPeriod) / close * 100
rocATROver = atrPct * atrFactor
rocATRUnder = -rocATROver
rocOver = useATR ? rocATROver : rocManualOver
rocUnder = useATR ? rocATRUnder : rocManualUnder
// === SCORES INDIVIDUALES ===
rsiScore = rsiVal > rsiOver ? 1 : rsiVal < rsiUnder ? -1 : 0
stochScore = stochVal > stochOver ? 1 : stochVal < stochUnder ? -1 : 0
cciScore = cciVal > cciOver ? 1 : cciVal < cciUnder ? -1 : 0
rocScore = rocVal > rocOver ? 1 : rocVal < rocUnder ? -1 : 0
willrScore = willrVal > willrOver ? 1 : willrVal < willrUnder ? -1 : 0
// === NORMALIZACIÓN & SUAVIZADO ===
score = rsiScore + stochScore + cciScore + rocScore + willrScore
lineaOsc = score / 5
emaOsc = ta.ema(lineaOsc, emaSuavizado)
// === COLOR DINÁMICO DEL OSCILADOR ===
oscColor = emaOsc > nivelSuperior ? color.red :
emaOsc < nivelInferior ? color.green :
color.blue
// === PLOTS DEL OSCILADOR ===
plot(emaOsc, title="EMA Súper Oscilador", color=oscColor, linewidth=2)
plot(mostrarLineaBase ? lineaOsc : na, title="Línea base", color=color.gray, linewidth=1)
hline(nivelSuperior, "Sobrecompra", color=color.new(color.red, 60), linestyle=hline.style_dashed)
hline(0, "Centro", color=color.gray, linestyle=hline.style_dotted)
hline(nivelInferior,"Sobreventa", color=color.new(color.green, 60), linestyle=hline.style_dashed)
// === TABLA SEMÁFORO ===
rsiState = rsiScore == 1 ? color.green : rsiScore == -1 ? color.red : color.gray
stochState = stochScore == 1 ? color.green : stochScore == -1 ? color.red : color.gray
cciState = cciScore == 1 ? color.green : cciScore == -1 ? color.red : color.gray
rocState = rocScore == 1 ? color.green : rocScore == -1 ? color.red : color.gray
willrState = willrScore == 1 ? color.green : willrScore == -1 ? color.red : color.gray
var table semaforo = table.new(position.top_right, 2, 6, border_width=1, frame_width=1)
if barstate.islast
table.cell(semaforo, 0, 0, "IND", text_color=color.white, bgcolor=color.black)
table.cell(semaforo, 1, 0, "EST", text_color=color.white, bgcolor=color.black)
table.cell(semaforo, 0, 1, "RSI", text_color=color.white)
table.cell(semaforo, 1, 1, "●", text_color=rsiState, bgcolor=color.new(rsiState, 85))
table.cell(semaforo, 0, 2, "STO", text_color=color.white)
table.cell(semaforo, 1, 2, "●", text_color=stochState, bgcolor=color.new(stochState, 85))
table.cell(semaforo, 0, 3, "CCI", text_color=color.white)
table.cell(semaforo, 1, 3, "●", text_color=cciState, bgcolor=color.new(cciState, 85))
table.cell(semaforo, 0, 4, "ROC", text_color=color.white)
table.cell(semaforo, 1, 4, "●", text_color=rocState, bgcolor=color.new(rocState, 85))
table.cell(semaforo, 0, 5, "W%R", text_color=color.white)
table.cell(semaforo, 1, 5, "●", text_color=willrState, bgcolor=color.new(willrState, 85))
// === SEÑALES DENTRO DEL PANEL DEL OSCILADOR ===
// Venta: sale de sobrecompra (cierre bajo nivelSuperior)
sellSignal = ta.crossunder(emaOsc, nivelSuperior) and barstate.isconfirmed
// Compra: sale de sobreventa (cierre sobre nivelInferior)
buySignal = ta.crossover (emaOsc, nivelInferior) and barstate.isconfirmed
plotshape(series = sellSignal ? nivelSuperior : na,title = "Señal Venta",style = shape.triangledown,location = location.absolute,size = size.small,color = color.red,text = "Sell")
plotshape(series = buySignal ? nivelInferior : na,title = "Señal Compra",style = shape.triangleup,location = location.absolute,size = size.small,color = color.green,text = "Buy")
// === ALERTAS PARA TRADINGVIEW ===
alertcondition(sellSignal, "Señal Venta", "El Súper Oscilador sale de sobrecompra")
alertcondition(buySignal, "Señal Compra","El Súper Oscilador sale de sobreventa")
-
https://tr.tradingview.com/script/u7...n%C3%BC%C5%9F/
Fibonacci Trend v7.2 - MA50 Şartsız Dönüş
PHP Code:
//@version=5
strategy("Fibonacci Trend v7.2 - MA50 Şartsız Dönüş", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// === Parametreler ===
fibLen = input.int(50, "Fibonacci Aralığı")
fibTol = input.float(0.01, "Fib Yakınlık Toleransı (%)", step=0.001)
slMult = input.float(1.5, "SL - ATR", step=0.1)
tp2Mult = input.float(2.0, "TP2 - ATR", step=0.1)
volMult = input.float(1.5, "Hacim Çarpanı", step=0.1)
srLookback = input.int(20, "Destek/Direnç Mum Sayısı")
// === Göstergeler ===
ema50 = ta.ema(close, 50)
atr = ta.atr(14)
volumeMA = ta.sma(volume, 20)
// === Fibonacci Seviyeleri ===
lowestLow = ta.lowest(low, fibLen)
highestHigh = ta.highest(high, fibLen)
fibRange = highestHigh - lowestLow
f0 = lowestLow
f236 = lowestLow + 0.236 * fibRange
f382 = lowestLow + 0.382 * fibRange
f500 = lowestLow + 0.5 * fibRange
f618 = lowestLow + 0.618 * fibRange
f786 = lowestLow + 0.786 * fibRange
f1 = highestHigh
// === Fibonacci Çizgileri ===
plot(f0, title="Fib 0.0", color=color.gray)
plot(f236, title="Fib 0.236", color=color.red)
plot(f382, title="Fib 0.382", color=color.orange)
plot(f500, title="Fib 0.5", color=color.gray)
plot(f618, title="Fib 0.618", color=color.green)
plot(f786, title="Fib 0.786", color=color.green)
plot(f1, title="Fib 1.0", color=color.blue)
// === Fitil ve Hacim Tespiti ===
longWick = close > open and (low < f0 or math.abs(low - f0)/close < fibTol)
shortWick = close < open and (high > f1 or math.abs(high - f1)/close < fibTol)
volSpike = volume > volumeMA * volMult
// === Long / Short Koşulları ===
canLong = longWick and volSpike
canShort = shortWick and volSpike
// Önceki poz kontrolü
notInPosition = strategy.position_size == 0
// === Sinyaller ===
if canLong and notInPosition
strategy.entry("Long", strategy.long)
entry = close
sl = entry - atr * slMult
tp = entry + atr * tp2Mult
strategy.exit("TP/SL Long", from_entry="Long", stop=sl, limit=tp)
if canShort and notInPosition
strategy.entry("Short", strategy.short)
entry = close
sl = entry + atr * slMult
tp = entry - atr * tp2Mult
strategy.exit("TP/SL Short", from_entry="Short", stop=sl, limit=tp)
// === Etiketler ===
plotshape(canLong and notInPosition, location=location.belowbar, color=color.green, style=shape.labelup, text="Long")
plotshape(canShort and notInPosition, location=location.abovebar, color=color.red, style=shape.labeldown, text="Short")
-
https://tr.tradingview.com/script/MX8EUksX/
Super SMA 5 8 13
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tamerbozoglu
//@version=4
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
//# *
//# * Study : SMA 5 8 13 Buy / Sell Signal
//# * Author : @BozzTamer
//# * Strategist : @xtrader_
//# * Revision History
//# * Release : Sep 17, 2023
//# *
//# *
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//
//This indicator is based on the 5 8 13 simple moving average strategy of strategist Selcuk Gonencler.
//The indicator shows buy and sell signals when favorable conditions occur.
// ══ H O W T O U S E ══════════════════════════════════════════════════════════════════════════ //
// Above 5-8-13 - Confirmed hold/buy
// 5 below (8-13 above) - Be careful, lose weight but don't run away.
// Below 5-8 (above 13) - Risk has begun. Don't be stubborn. 13 is your last castle.
// 5-8-13 below. Don't fight! Wait until it rises above 5-8 again.
study(title="Super SMA 5 8 13", overlay=true)
src = close
ma5 = sma(src, 5)
ma8 = sma(src, 8)
ma13 = sma(src, 13)
buy_cond = cross(ma5, ma13) and ma5 > ma13
sell_cond = cross(ma5, ma13) and ma5 < ma8 and ma5 < ma13
plot( ma5, color=color.rgb(0, 255, 8), style=plot.style_line, title="SMA 5", linewidth=2, transp = 0)
plot( ma8, color=color.rgb(255, 230, 0), style=plot.style_line, title="SMA 8", linewidth=2, transp = 0)
plot( ma13, color=color.rgb(255, 0, 0), style=plot.style_line, title="SMA 13", linewidth=2, transp = 0)
plotarrow(buy_cond ? 1 : 0, colordown=color.rgb(0, 255, 8), title="BUY SIGNAL",maxheight=50, minheight=50, transp = 0)
plotarrow(sell_cond ? -1 : 0, colorup=color.rgb(255, 0, 0), title="SELL SIGNAL",maxheight=50, minheight=50, transp = 0)
alertcondition(buy_cond, title = "Buy Condition", message = "Buy Alert!")
alertcondition(sell_cond, title = "Sell Condition", message = "Sell Alert!")
versiyon 5 hali
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tamerbozoglu
//@version=5
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
//# *
//# * Study : SMA 5 8 13 Buy / Sell Signal
//# * Author : @BozzTamer
//# * Strategist : @xtrader_
//# * Revision History
//# * Release : Sep 17, 2023
//# *
//# *
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//
//This indicator is based on the 5 8 13 simple moving average strategy of strategist Selcuk Gonencler.
//The indicator shows buy and sell signals when favorable conditions occur.
// ══ H O W T O U S E ══════════════════════════════════════════════════════════════════════════ //
// Above 5-8-13 - Confirmed hold/buy
// 5 below (8-13 above) - Be careful, lose weight but don't run away.
// Below 5-8 (above 13) - Risk has begun. Don't be stubborn. 13 is your last castle.
// 5-8-13 below. Don't fight! Wait until it rises above 5-8 again.
indicator(title='Super SMA 5 8 13', overlay=true)
src = close
ma5 = ta.sma(src, 5)
ma8 = ta.sma(src, 8)
ma13 = ta.sma(src, 13)
buy_cond = ta.cross(ma5, ma13) and ma5 > ma13
sell_cond = ta.cross(ma5, ma13) and ma5 < ma8 and ma5 < ma13
plot(ma5, color=color.rgb(0, 255, 8), style=plot.style_line, title='SMA 5', linewidth=2, transp=0)
plot(ma8, color=color.rgb(255, 230, 0), style=plot.style_line, title='SMA 8', linewidth=2, transp=0)
plot(ma13, color=color.rgb(255, 0, 0), style=plot.style_line, title='SMA 13', linewidth=2, transp=0)
plotarrow(buy_cond ? 1 : 0, colordown=color.rgb(0, 255, 8), title='BUY SIGNAL', maxheight=50, minheight=50, transp=0)
plotarrow(sell_cond ? -1 : 0, colorup=color.rgb(255, 0, 0), title='SELL SIGNAL', maxheight=50, minheight=50, transp=0)
alertcondition(buy_cond, title='Buy Condition', message='Buy Alert!')
alertcondition(sell_cond, title='Sell Condition', message='Sell Alert!')
versiyon 6 hali
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tamerbozoglu
//@version=6
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
//# *
//# * Study : SMA 5 8 13 Buy / Sell Signal
//# * Author : @BozzTamer
//# * Strategist : @xtrader_
//# * Revision History
//# * Release : Sep 17, 2023
//# *
//# *
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//
//This indicator is based on the 5 8 13 simple moving average strategy of strategist Selcuk Gonencler.
//The indicator shows buy and sell signals when favorable conditions occur.
// ══ H O W T O U S E ══════════════════════════════════════════════════════════════════════════ //
// Above 5-8-13 - Confirmed hold/buy
// 5 below (8-13 above) - Be careful, lose weight but don't run away.
// Below 5-8 (above 13) - Risk has begun. Don't be stubborn. 13 is your last castle.
// 5-8-13 below. Don't fight! Wait until it rises above 5-8 again.
indicator(title = 'Super SMA 5 8 13', overlay = true)
src = close
ma5 = ta.sma(src, 5)
ma8 = ta.sma(src, 8)
ma13 = ta.sma(src, 13)
buy_cond = ta.cross(ma5, ma13) and ma5 > ma13
sell_cond = ta.cross(ma5, ma13) and ma5 < ma8 and ma5 < ma13
plot(ma5, color = color.rgb(0, 255, 8), style = plot.style_line, title = 'SMA 5', linewidth = 2)
plot(ma8, color = color.rgb(255, 230, 0), style = plot.style_line, title = 'SMA 8', linewidth = 2)
plot(ma13, color = color.rgb(255, 0, 0), style = plot.style_line, title = 'SMA 13', linewidth = 2)
plotarrow(buy_cond ? 1 : 0, colordown = color.rgb(0, 255, 8), title = 'BUY SIGNAL', maxheight = 50, minheight = 50)
plotarrow(sell_cond ? -1 : 0, colorup = color.rgb(255, 0, 0), title = 'SELL SIGNAL', maxheight = 50, minheight = 50)
alertcondition(buy_cond, title = 'Buy Condition', message = 'Buy Alert!')
alertcondition(sell_cond, title = 'Sell Condition', message = 'Sell Alert!')
sade hali...sinyalli...
PHP Code:
//@version=6
indicator(title = 'Super SMA 5 8 13', overlay = true)
src = close
ma5 = ta.sma(src, 5)
ma8 = ta.sma(src, 8)
ma13 = ta.sma(src, 13)
buy_cond = ta.cross(ma5, ma13) and ma5 > ma13
sell_cond = ta.cross(ma5, ma13) and ma5 < ma8 and ma5 < ma13
//plot(ma5, color = color.rgb(0, 255, 8), style = plot.style_line, title = 'SMA 5', linewidth = 2)
//plot(ma8, color = color.rgb(255, 230, 0), style = plot.style_line, title = 'SMA 8', linewidth = 2)
//plot(ma13, color = color.rgb(255, 0, 0), style = plot.style_line, title = 'SMA 13', linewidth = 2)
plotarrow(buy_cond ? 1 : 0, colordown = color.rgb(0, 255, 8), title = 'BUY SIGNAL', maxheight = 50, minheight = 50)
plotarrow(sell_cond ? -1 : 0, colorup = color.rgb(255, 0, 0), title = 'SELL SIGNAL', maxheight = 50, minheight = 50)
-
periyotler için en iyi sma bulucu....https://tr.tradingview.com/script/WL...st-SMA-Finder/
bunu kullanarak...
örneğin x100 için...
sma değerlerini değiştirerek kullanılabilir...
1dak-15dak ve 1 saatlik için bulunan değerler uygulanınca...
saatlik görüntü...https://www.tradingview.com/x/S2TkbLBd/
-
-
PHP Code:
//@version=6
indicator(title = 'Master Trend BUY&SELL', shorttitle = 'MASTER TREND BUY&SELL', overlay = true)
// Color variables
upTrendColor = color.green
neutralColor = #0e0e0e
downTrendColor = color.red
fillColor = color.rgb(12, 12, 12, 70) // Color between lines
yellowColor = color.rgb(230, 214, 2)
blackTextColor = color.rgb(0, 0, 0)
blueColor = color.rgb(233, 217, 0)
whiteTextColor = color.rgb(7, 7, 7)
greenColor = color.green
redColor = color.red
// Source
source = input(defval = close, title = 'Source')
// Sampling Period
period = input.int(defval = 100, minval = 1, title = 'Sampling Period')
// Range Multiplier
multiplier = input.float(defval = 3.0, minval = 0.1, title = 'Range Multiplier')
// Take Profit Settings
takeProfitPips = input.float(defval = 600.0, title = 'Take Profit (in pips)')
// Smooth Average Range
smoothRange(x, t, m) =>
adjustedPeriod = t * 2 - 1
avgRange = ta.ema(math.abs(x - x[1]), t)
smoothRange = ta.ema(avgRange, adjustedPeriod) * m
smoothRange
smoothedRange = smoothRange(source, period, multiplier)
// Trend Filter
trendFilter(x, r) =>
filtered = x
filtered := x > nz(filtered[1]) ? x - r < nz(filtered[1]) ? nz(filtered[1]) : x - r : x + r > nz(filtered[1]) ? nz(filtered[1]) : x + r
filtered
filter = trendFilter(source, smoothedRange)
// Filter Direction
upCount = 0.0
upCount := filter > filter[1] ? nz(upCount[1]) + 1 : filter < filter[1] ? 0 : nz(upCount[1])
downCount = 0.0
downCount := filter < filter[1] ? nz(downCount[1]) + 1 : filter > filter[1] ? 0 : nz(downCount[1])
// Colors
filterColor = upCount > 0 ? upTrendColor : downCount > 0 ? downTrendColor : neutralColor
// Double Line Design
lineOffset = smoothedRange * 0.1
//upperLinePlot = plot(filter + lineOffset, color = filterColor, linewidth = 3, title = 'Upper Trend Line')
lowerLinePlot = plot(filter - lineOffset, color = filterColor, linewidth = 3, title = 'Lower Trend Line')
//fill(upperLinePlot, lowerLinePlot, color = fillColor, title = 'Trend Fill')
// Break Outs
longCondition = bool(na)
shortCondition = bool(na)
longCondition := source > filter and source > source[1] and upCount > 0 or source > filter and source < source[1] and upCount > 0
shortCondition := source < filter and source < source[1] and downCount > 0 or source < filter and source > source[1] and downCount > 0
initialCondition = 0
initialCondition := longCondition ? 1 : shortCondition ? -1 : initialCondition[1]
longSignal = longCondition and initialCondition[1] == -1
shortSignal = shortCondition and initialCondition[1] == 1
// Take Profit Logic
var float entryPriceBuy = na
var float entryPriceSell = na
takeProfitSignalBuy = false
takeProfitSignalSell = false
if longSignal
entryPriceBuy := source
entryPriceBuy
if not na(entryPriceBuy) and source >= entryPriceBuy + takeProfitPips * syminfo.mintick
takeProfitSignalBuy := true
entryPriceBuy := na
entryPriceBuy
if shortSignal
entryPriceSell := source
entryPriceSell
if not na(entryPriceSell) and source <= entryPriceSell - takeProfitPips * syminfo.mintick
takeProfitSignalSell := true
entryPriceSell := na
entryPriceSell
// Alerts and Signals
plotshape(longSignal, title = 'Smart Buy Signal', text = 'Al', textcolor = color.white, style = shape.labelup, size = size.small, location = location.belowbar, color = greenColor)
plotshape(shortSignal, title = 'Smart Sell Signal', text = 'Sat', textcolor = color.white, style = shape.labeldown, size = size.small, location = location.abovebar, color = redColor)
//plotshape(takeProfitSignalBuy, title = 'Book Profit Buy', text = 'Book Profit', textcolor = blackTextColor, style = shape.labeldown, size = size.small, location = location.abovebar, color = yellowColor)
//plotshape(takeProfitSignalSell, title = 'Book Profit Sell', text = 'Book Profit', textcolor = whiteTextColor, style = shape.labelup, size = size.small, location = location.belowbar, color = blueColor)
PHP Code:
//@version=6
indicator(title = 'Master Trend BUY&SELL', shorttitle = 'MASTER TREND BUY&SELL', overlay = true)
// Color variables
upTrendColor = color.green
neutralColor = #0e0e0e
downTrendColor = color.red
fillColor = color.rgb(12, 12, 12, 70) // Color between lines
yellowColor = color.rgb(230, 214, 2)
blackTextColor = color.rgb(0, 0, 0)
blueColor = color.rgb(233, 217, 0)
whiteTextColor = color.rgb(7, 7, 7)
greenColor = color.green
redColor = color.red
// Source
source = input(defval = close, title = 'Source')
// Sampling Period
period = input.int(defval = 50, minval = 1, title = 'Sampling Period')
// Range Multiplier
multiplier = input.float(defval = 3.0, minval = 0.1, title = 'Range Multiplier')
// Take Profit Settings
takeProfitPips = input.float(defval = 600.0, title = 'Take Profit (in pips)')
// Smooth Average Range
smoothRange(x, t, m) =>
adjustedPeriod = t * 2 - 1
avgRange = ta.ema(math.abs(x - x[1]), t)
smoothRange = ta.ema(avgRange, adjustedPeriod) * m
smoothRange
smoothedRange = smoothRange(source, period, multiplier)
// Trend Filter
trendFilter(x, r) =>
filtered = x
filtered := x > nz(filtered[1]) ? x - r < nz(filtered[1]) ? nz(filtered[1]) : x - r : x + r > nz(filtered[1]) ? nz(filtered[1]) : x + r
filtered
filter = trendFilter(source, smoothedRange)
// Filter Direction
upCount = 0.0
upCount := filter > filter[1] ? nz(upCount[1]) + 1 : filter < filter[1] ? 0 : nz(upCount[1])
downCount = 0.0
downCount := filter < filter[1] ? nz(downCount[1]) + 1 : filter > filter[1] ? 0 : nz(downCount[1])
// Colors
filterColor = upCount > 0 ? upTrendColor : downCount > 0 ? downTrendColor : neutralColor
// Double Line Design
lineOffset = smoothedRange * 0.1
//upperLinePlot = plot(filter + lineOffset, color = filterColor, linewidth = 3, title = 'Upper Trend Line')
lowerLinePlot = plot(filter - lineOffset, color = filterColor, linewidth = 3, title = 'Lower Trend Line')
//fill(upperLinePlot, lowerLinePlot, color = fillColor, title = 'Trend Fill')
// Break Outs
longCondition = bool(na)
shortCondition = bool(na)
longCondition := source > filter and source > source[1] and upCount > 0 or source > filter and source < source[1] and upCount > 0
shortCondition := source < filter and source < source[1] and downCount > 0 or source < filter and source > source[1] and downCount > 0
initialCondition = 0
initialCondition := longCondition ? 1 : shortCondition ? -1 : initialCondition[1]
longSignal = longCondition and initialCondition[1] == -1
shortSignal = shortCondition and initialCondition[1] == 1
// Take Profit Logic
var float entryPriceBuy = na
var float entryPriceSell = na
takeProfitSignalBuy = false
takeProfitSignalSell = false
if longSignal
entryPriceBuy := source
entryPriceBuy
if not na(entryPriceBuy) and source >= entryPriceBuy + takeProfitPips * syminfo.mintick
takeProfitSignalBuy := true
entryPriceBuy := na
entryPriceBuy
if shortSignal
entryPriceSell := source
entryPriceSell
if not na(entryPriceSell) and source <= entryPriceSell - takeProfitPips * syminfo.mintick
takeProfitSignalSell := true
entryPriceSell := na
entryPriceSell
// Alerts and Signals
plotshape(longSignal, title = 'Smart Buy Signal', text = 'Al', textcolor = color.white, style = shape.labelup, size = size.small, location = location.belowbar, color = greenColor)
plotshape(shortSignal, title = 'Smart Sell Signal', text = 'Sat', textcolor = color.white, style = shape.labeldown, size = size.small, location = location.abovebar, color = redColor)
//plotshape(takeProfitSignalBuy, title = 'Book Profit Buy', text = 'Book Profit', textcolor = blackTextColor, style = shape.labeldown, size = size.small, location = location.abovebar, color = yellowColor)
//plotshape(takeProfitSignalSell, title = 'Book Profit Sell', text = 'Book Profit', textcolor = whiteTextColor, style = shape.labelup, size = size.small, location = location.belowbar, color = blueColor)
/////
// === Inputs ===
fairLen = input.int(50, "Fair Value EMA Length")
zLen = input.int(100, "Z-Score Lookback Length")
zThreshold = input.float(3.0, "Z-Score Threshold")
src = input.source(close, "Source")
rsiLen = input.int(14, "RSI Length")
rsiEmaLen = input.int(7, "EMA of RSI Slope")
colorMode = input.string("None", "Bar Coloring Mode", options=[
"None",
"Reversal Solid",
"Reversal Fade",
"Exceeding Bands",
"Classic Heat"
])
enableSignals = input.bool(false,'Show Signals')
// === Smooth RGB Gradient Function
f_colorGradient(_ratio, _colA, _colB) =>
rA = color.r(_colA)
gA = color.g(_colA)
bA = color.b(_colA)
rB = color.r(_colB)
gB = color.g(_colB)
bB = color.b(_colB)
rr = rA + int((rB - rA) * _ratio)
rg = gA + int((gB - gA) * _ratio)
rb = bA + int((bB - bA) * _ratio)
color.rgb(rr, rg, rb, 0)
// === Color Scheme ===
bullMain = color.new(#5CF0D7, 0)
bearMain = color.new(#B32AC3, 0)
labelTextCol = color.white
borderCol = color.white
// === Fair Value (EMA Only) ===
fair = ta.ema(src, fairLen)
// === Z-Score Deviation
dev = src - fair
devMean = ta.sma(dev, zLen)
devStdev = ta.stdev(dev, zLen)
zScore = devStdev != 0 ? (dev - devMean) / devStdev : 0
// === Z-Bands
upperBand = fair + zThreshold * devStdev
lowerBand = fair - zThreshold * devStdev
// === Re-entry Logic
wasAbove = src[1] > upperBand[1]
wasBelow = src[1] < lowerBand[1]
backInsideFromAbove = wasAbove and src <= upperBand
backInsideFromBelow = wasBelow and src >= lowerBand
// === RSI EMA Slope Filter
rsi = ta.rsi(close, rsiLen)
rsiEma = ta.ema(rsi, rsiEmaLen)
rsiSlope = rsiEma - rsiEma[1]
slopeUp = rsiSlope > 0
slopeDown = rsiSlope < 0
// === Signal Memory (One per slope)
var bool buyFiredOnSlope = false
var bool sellFiredOnSlope = false
// Reset logic when slope flips
buyReset = ta.crossover(rsiSlope, 0)
sellReset = ta.crossunder(rsiSlope, 0)
if buyReset
buyFiredOnSlope := false
if sellReset
sellFiredOnSlope := false
// Final entry conditions
finalBuy = backInsideFromBelow and slopeUp and not buyFiredOnSlope and enableSignals
finalSell = backInsideFromAbove and slopeDown and not sellFiredOnSlope and enableSignals
if finalBuy
buyFiredOnSlope := true
if finalSell
sellFiredOnSlope := true
// === Plot Fair Value and Bands (All White)
pUpper = plot(upperBand, "Upper Band", color=borderCol, linewidth=1)
pLower = plot(lowerBand, "Lower Band", color=borderCol, linewidth=1)
pFair = plot(fair, "Fair Value EMA", color=borderCol, linewidth=2)
// === Elegant Signal Labels
plotshape(finalBuy, title="Buy", location=location.belowbar, style=shape.labelup, text="𝓤𝓹", color=bullMain, textcolor=#000000, size=size.small)
plotshape(finalSell, title="Sell", location=location.abovebar, style=shape.labeldown, text="𝓓𝓸𝔀𝓷", color=bearMain, textcolor=labelTextCol, size=size.small)
// === Barcolor with Smoothing
// === Gradient Fill: Top → Mid, Bottom → Mid
fill(pUpper, pFair, upperBand, fair,color.new(bearMain, 60), #00010400)
fill(pFair, pLower, fair, lowerBand, color.new(#000000, 100),color.new(bullMain, 60))
// === Bar Coloring Modes
// Reversal Memory (for "Reversal Solid" and "Reversal Fade")
var string lastSignal = ""
if finalBuy
lastSignal := "bull"
if finalSell
lastSignal := "bear"
// Reversal Fade Tracker
var int signalAge = 0
if finalBuy or finalSell
signalAge := 0
else
signalAge += 1
// info
var string lastTrend = ""
if close > upperBand
lastTrend := "bull"
else if close < lowerBand
lastTrend := "bear"
// === Bar Coloring Logic
var color barCol = na
// 1. Reversal Solid
if colorMode == "Reversal Solid"
barCol := lastSignal == "bull" ? color.new(bullMain, 0) : lastSignal == "bear" ? color.new(bearMain, 0) : na
if colorMode == "None"
barCol := na
// 2. Reversal Fade
if colorMode == "Reversal Fade"
fade = math.min(90, signalAge * 1)
barCol := lastSignal == "bull" ? color.new(bullMain, fade) : lastSignal == "bear" ? color.new(bearMain, fade) : na
// 4. Exceeding Bands Only (only when outside bands)
if colorMode == "Exceeding Bands"
barCol := close > upperBand ? color.new(bullMain, 0) : close < lowerBand ? color.new(bearMain, 0) : na
// 5. Classic Heat — correct: strongest color near bands, fade near fair
// 5. Classic Heat — fixed: most intense near boundaries, fades toward fair
// 6. Gradient Flow — RGB blend from bull to bear based on band distance
if colorMode == "Classic Heat"
bandRange = upperBand - lowerBand
ratioRaw = (close - lowerBand) / bandRange
ratioClamped = math.max(0.0, math.min(ratioRaw, 1.0))
barCol := f_colorGradient(ratioClamped, bullMain, bearMain)
barcolor(barCol)
// === Table Position Setting
enableTable = input.bool(true,'Enable Table')
tablePos = input.string("Top Right", "Table Position", options=["Top Left", "Top Right", "Bottom Left", "Bottom Right"])
pos = tablePos == "Top Left" ? position.top_left :
tablePos == "Top Right" ? position.top_right :
tablePos == "Bottom Left" ? position.bottom_left :
position.bottom_right
// === Scoring Logic
score_z = zScore < -zThreshold ? +1 : zScore > zThreshold ? -1 : 0
score_slope = rsiSlope > 0 ? +1 : rsiSlope < 0 ? -1 : 0
score_price = close > fair ? +1 : close < fair ? -1 : 0
score_trend = lastTrend == "bull" ? +1 : lastTrend == "bear" ? -1 : 0
score_reentry = finalBuy ? +1 : finalSell ? -1 : 0
// === Score Aggregation
totalScore = score_z + score_slope + score_price + score_trend + score_reentry
scoreCount = 5
avgScore = totalScore / scoreCount
finalSignal = avgScore > 0.1 ? "Buy" : avgScore < -0.1 ? "Sell" : "Neutral"
finalColor = avgScore > 0.1 ? bullMain : avgScore < -0.1 ? bearMain : color.gray
// === Shared Style
bgcolor = color.new(#000000, 0)
textCol = color.white
// === Table Drawing
if bar_index % 2 == 0 and enableTable
var table scoreTable = table.new(pos, 2, 7,frame_width = 1, border_width=1, frame_color=color.white, border_color=color.white)
table.cell(scoreTable, 0, 0, "Metric", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 0, "Score", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 1, "Z-Score", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 1, str.tostring(score_z), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 2, "RSI Slope", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 2, str.tostring(score_slope), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 3, "Price vs Fair", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 3, str.tostring(score_price), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 4, "Trend State", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 4, str.tostring(score_trend), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 5, "Reentry", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 5, str.tostring(score_reentry),bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 6, "Final Signal", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 6, finalSignal, bgcolor=bgcolor, text_color=finalColor)
table.cell_set_text_font_family(scoreTable,0,0,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,0,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,1,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,1,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,2,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,2,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,3,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,3,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,4,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,4,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,5,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,5,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,6,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,6,font.family_monospace)
-
PHP Code:
//@version=6
indicator(title = 'Master Trend BUY&SELL', shorttitle = '.', overlay = true)
// Color variables
upTrendColor = color.green
neutralColor = #0e0e0e
downTrendColor = color.red
fillColor = color.rgb(12, 12, 12, 70) // Color between lines
yellowColor = color.rgb(230, 214, 2)
blackTextColor = color.rgb(0, 0, 0)
blueColor = color.rgb(233, 217, 0)
whiteTextColor = color.rgb(7, 7, 7)
greenColor = color.green
redColor = color.red
// Source
source = input(defval = close, title = 'Source')
// Sampling Period
period = input.int(defval = 50, minval = 1, title = 'Sampling Period')
// Range Multiplier
multiplier = input.float(defval = 3.0, minval = 0.1, title = 'Range Multiplier')
// Take Profit Settings
takeProfitPips = input.float(defval = 600.0, title = 'Take Profit (in pips)')
// Smooth Average Range
smoothRange(x, t, m) =>
adjustedPeriod = t * 2 - 1
avgRange = ta.ema(math.abs(x - x[1]), t)
smoothRange = ta.ema(avgRange, adjustedPeriod) * m
smoothRange
smoothedRange = smoothRange(source, period, multiplier)
// Trend Filter
trendFilter(x, r) =>
filtered = x
filtered := x > nz(filtered[1]) ? x - r < nz(filtered[1]) ? nz(filtered[1]) : x - r : x + r > nz(filtered[1]) ? nz(filtered[1]) : x + r
filtered
filter = trendFilter(source, smoothedRange)
// Filter Direction
upCount = 0.0
upCount := filter > filter[1] ? nz(upCount[1]) + 1 : filter < filter[1] ? 0 : nz(upCount[1])
downCount = 0.0
downCount := filter < filter[1] ? nz(downCount[1]) + 1 : filter > filter[1] ? 0 : nz(downCount[1])
// Colors
filterColor = upCount > 0 ? upTrendColor : downCount > 0 ? downTrendColor : neutralColor
// Double Line Design
lineOffset = smoothedRange * 0.1
upperLinePlot = plot(filter + lineOffset, color = filterColor, linewidth = 1, title = 'Yükseliş Trend Çizgisi')
lowerLinePlot = plot(filter - lineOffset, color = filterColor, linewidth = 1, title = 'Düşüş Trend Çizgisi')
//fill(upperLinePlot, lowerLinePlot, color = fillColor, title = 'Trend Fill')
// Break Outs
longCondition = bool(na)
shortCondition = bool(na)
longCondition := source > filter and source > source[1] and upCount > 0 or source > filter and source < source[1] and upCount > 0
shortCondition := source < filter and source < source[1] and downCount > 0 or source < filter and source > source[1] and downCount > 0
initialCondition = 0
initialCondition := longCondition ? 1 : shortCondition ? -1 : initialCondition[1]
longSignal = longCondition and initialCondition[1] == -1
shortSignal = shortCondition and initialCondition[1] == 1
// Take Profit Logic
var float entryPriceBuy = na
var float entryPriceSell = na
takeProfitSignalBuy = false
takeProfitSignalSell = false
if longSignal
entryPriceBuy := source
entryPriceBuy
if not na(entryPriceBuy) and source >= entryPriceBuy + takeProfitPips * syminfo.mintick
takeProfitSignalBuy := true
entryPriceBuy := na
entryPriceBuy
if shortSignal
entryPriceSell := source
entryPriceSell
if not na(entryPriceSell) and source <= entryPriceSell - takeProfitPips * syminfo.mintick
takeProfitSignalSell := true
entryPriceSell := na
entryPriceSell
// Alerts and Signals
plotshape(longSignal, title = 'Smart Buy Signal', text = 'Al', textcolor = color.white, style = shape.labelup, size = size.small, location = location.belowbar, color = greenColor)
plotshape(shortSignal, title = 'Smart Sell Signal', text = 'Sat', textcolor = color.white, style = shape.labeldown, size = size.small, location = location.abovebar, color = redColor)
//plotshape(takeProfitSignalBuy, title = 'Book Profit Buy', text = 'Book Profit', textcolor = blackTextColor, style = shape.labeldown, size = size.small, location = location.abovebar, color = yellowColor)
//plotshape(takeProfitSignalSell, title = 'Book Profit Sell', text = 'Book Profit', textcolor = whiteTextColor, style = shape.labelup, size = size.small, location = location.belowbar, color = blueColor)
/////
// === Inputs ===
fairLen = input.int(50, "Fair Value EMA Length")
zLen = input.int(100, "Z-Score Lookback Length")
zThreshold = input.float(3.0, "Z-Score Threshold")
src = input.source(close, "Source")
rsiLen = input.int(14, "RSI Length")
rsiEmaLen = input.int(7, "EMA of RSI Slope")
colorMode = input.string("None", "Bar Coloring Mode", options=[
"None",
"Reversal Solid",
"Reversal Fade",
"Exceeding Bands",
"Classic Heat"
])
enableSignals = input.bool(false,'Show Signals')
// === Smooth RGB Gradient Function
f_colorGradient(_ratio, _colA, _colB) =>
rA = color.r(_colA)
gA = color.g(_colA)
bA = color.b(_colA)
rB = color.r(_colB)
gB = color.g(_colB)
bB = color.b(_colB)
rr = rA + int((rB - rA) * _ratio)
rg = gA + int((gB - gA) * _ratio)
rb = bA + int((bB - bA) * _ratio)
color.rgb(rr, rg, rb, 0)
// === Color Scheme ===
bullMain = color.new(#5CF0D7, 0)
bearMain = color.new(#B32AC3, 0)
labelTextCol = color.white
borderCol = color.white
// === Fair Value (EMA Only) ===
fair = ta.ema(src, fairLen)
// === Z-Score Deviation
dev = src - fair
devMean = ta.sma(dev, zLen)
devStdev = ta.stdev(dev, zLen)
zScore = devStdev != 0 ? (dev - devMean) / devStdev : 0
// === Z-Bands
upperBand = fair + zThreshold * devStdev
lowerBand = fair - zThreshold * devStdev
// === Re-entry Logic
wasAbove = src[1] > upperBand[1]
wasBelow = src[1] < lowerBand[1]
backInsideFromAbove = wasAbove and src <= upperBand
backInsideFromBelow = wasBelow and src >= lowerBand
// === RSI EMA Slope Filter
rsi = ta.rsi(close, rsiLen)
rsiEma = ta.ema(rsi, rsiEmaLen)
rsiSlope = rsiEma - rsiEma[1]
slopeUp = rsiSlope > 0
slopeDown = rsiSlope < 0
// === Signal Memory (One per slope)
var bool buyFiredOnSlope = false
var bool sellFiredOnSlope = false
// Reset logic when slope flips
buyReset = ta.crossover(rsiSlope, 0)
sellReset = ta.crossunder(rsiSlope, 0)
if buyReset
buyFiredOnSlope := false
if sellReset
sellFiredOnSlope := false
// Final entry conditions
finalBuy = backInsideFromBelow and slopeUp and not buyFiredOnSlope and enableSignals
finalSell = backInsideFromAbove and slopeDown and not sellFiredOnSlope and enableSignals
if finalBuy
buyFiredOnSlope := true
if finalSell
sellFiredOnSlope := true
// === Plot Fair Value and Bands (All White)
pUpper = plot(upperBand, "Üst Band", color=borderCol, linewidth=1)
pLower = plot(lowerBand, "Alt Band", color=borderCol, linewidth=1)
pFair = plot(fair, "Adil EMA", color=borderCol, linewidth=2)
// === Elegant Signal Labels
plotshape(finalBuy, title="Buy", location=location.belowbar, style=shape.labelup, text="𝓤𝓹", color=bullMain, textcolor=#000000, size=size.small)
plotshape(finalSell, title="Sell", location=location.abovebar, style=shape.labeldown, text="𝓓𝓸𝔀𝓷", color=bearMain, textcolor=labelTextCol, size=size.small)
// === Barcolor with Smoothing
// === Gradient Fill: Top → Mid, Bottom → Mid
fill(pUpper, pFair, upperBand, fair,color.new(bearMain, 60), #00010400)
fill(pFair, pLower, fair, lowerBand, color.new(#000000, 100),color.new(bullMain, 60))
// === Bar Coloring Modes
// Reversal Memory (for "Reversal Solid" and "Reversal Fade")
var string lastSignal = ""
if finalBuy
lastSignal := "bull"
if finalSell
lastSignal := "bear"
// Reversal Fade Tracker
var int signalAge = 0
if finalBuy or finalSell
signalAge := 0
else
signalAge += 1
// info
var string lastTrend = ""
if close > upperBand
lastTrend := "bull"
else if close < lowerBand
lastTrend := "bear"
// === Bar Coloring Logic
var color barCol = na
// 1. Reversal Solid
if colorMode == "Reversal Solid"
barCol := lastSignal == "bull" ? color.new(bullMain, 0) : lastSignal == "bear" ? color.new(bearMain, 0) : na
if colorMode == "None"
barCol := na
// 2. Reversal Fade
if colorMode == "Reversal Fade"
fade = math.min(90, signalAge * 1)
barCol := lastSignal == "bull" ? color.new(bullMain, fade) : lastSignal == "bear" ? color.new(bearMain, fade) : na
// 4. Exceeding Bands Only (only when outside bands)
if colorMode == "Exceeding Bands"
barCol := close > upperBand ? color.new(bullMain, 0) : close < lowerBand ? color.new(bearMain, 0) : na
// 5. Classic Heat — correct: strongest color near bands, fade near fair
// 5. Classic Heat — fixed: most intense near boundaries, fades toward fair
// 6. Gradient Flow — RGB blend from bull to bear based on band distance
if colorMode == "Classic Heat"
bandRange = upperBand - lowerBand
ratioRaw = (close - lowerBand) / bandRange
ratioClamped = math.max(0.0, math.min(ratioRaw, 1.0))
barCol := f_colorGradient(ratioClamped, bullMain, bearMain)
barcolor(barCol)
// === Table Position Setting
enableTable = input.bool(true,'Enable Table')
tablePos = input.string("Top Right", "Table Position", options=["Top Left", "Top Right", "Bottom Left", "Bottom Right"])
pos = tablePos == "Top Left" ? position.top_left :
tablePos == "Top Right" ? position.top_right :
tablePos == "Bottom Left" ? position.bottom_left :
position.bottom_right
// === Scoring Logic
score_z = zScore < -zThreshold ? +1 : zScore > zThreshold ? -1 : 0
score_slope = rsiSlope > 0 ? +1 : rsiSlope < 0 ? -1 : 0
score_price = close > fair ? +1 : close < fair ? -1 : 0
score_trend = lastTrend == "bull" ? +1 : lastTrend == "bear" ? -1 : 0
score_reentry = finalBuy ? +1 : finalSell ? -1 : 0
// === Score Aggregation
totalScore = score_z + score_slope + score_price + score_trend + score_reentry
scoreCount = 5
avgScore = totalScore / scoreCount
finalSignal = avgScore > 0.1 ? "AL" : avgScore < -0.1 ? "SAT" : "Nötr"
finalColor = avgScore > 0.1 ? bullMain : avgScore < -0.1 ? bearMain : color.gray
// === Shared Style
bgcolor = color.new(#000000, 0)
textCol = color.white
// === Table Drawing
if bar_index % 2 == 0 and enableTable
var table scoreTable = table.new(pos, 2, 7,frame_width = 1, border_width=1, frame_color=color.white, border_color=color.white)
table.cell(scoreTable, 0, 0, "İnd", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 0, "Puan", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 1, "Z-Score", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 1, str.tostring(score_z), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 2, "RSI", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 2, str.tostring(score_slope), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 3, "Fiyat", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 3, str.tostring(score_price), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 4, "Trend ", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 4, str.tostring(score_trend), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 5, "R Giriş", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 5, str.tostring(score_reentry),bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 6, "Sonuç", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 6, finalSignal, bgcolor=bgcolor, text_color=finalColor)
table.cell_set_text_font_family(scoreTable,0,0,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,0,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,1,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,1,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,2,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,2,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,3,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,3,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,4,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,4,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,5,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,5,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,6,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,6,font.family_monospace)
/////////////////
src88 = input.source(close,"RSI Source",group = "Connors RSI")
lenrsi = input(24, "RSI Length",group = "Connors RSI")
lenupdown = input(20, "UpDown Length",group = "Connors RSI")
lenroc = input(75, "ROC Length",group = "Connors RSI")
z_score_length = input(14, "Z-Score Lookback",group = "Filtering")
threshold = input.float(1.5, "Z-Score Threshold", step=0.025,group = "Filtering")
trendingLongThreshold = input.float(65, "Trending Long Threshold" ,group = "Filtering")
trendingShortThreshold = input.float(35, "Trending Short Threshold",group = "Filtering")
revertingLongThreshold = input.float(70, title="Reverting Long Threshold",group = "Filtering")
revertingShortThreshold = input.float(30, title="Reverting Short Threshold",group = "Filtering")
// ─── CONNORS RSI ──────────────────────────────────────────────────────────
updown(s) =>
isEqual = s == s[1]
isGrowing = s > s[1]
ud = 0.0
ud := isEqual ? 0 : isGrowing ? (nz(ud[1]) <= 0 ? 1 : nz(ud[1])+1) : (nz(ud[1]) >= 0 ? -1 : nz(ud[1])-1)
ud
rsi88 = ta.rsi(src88, lenrsi)
updownrsi = ta.rsi(updown(src88), lenupdown)
percentrank = ta.percentrank(ta.roc(src88, 1), lenroc)
crsi = math.avg(rsi, updownrsi, percentrank)
// ─── Z-SCORING ──────────────────────────────────────────────────────────
mean = ta.sma(crsi, z_score_length)
stdDev = ta.stdev(crsi, z_score_length)
zScore88 = (crsi - mean) / stdDev
isTrending = math.abs(zScore88) > threshold
// ─── Signal Generation ────────────────────────────────────────────────
var int signal = 0
if barstate.isconfirmed
if isTrending
signal := crsi > trendingLongThreshold ? 1 : crsi < trendingShortThreshold ? -1 : signal[1]
else
signal := crsi > revertingLongThreshold ? 1 : crsi < revertingShortThreshold ? -1 : signal[1]
trendColor = signal == 1 ? #17dfad : signal == -1 ? #dd326b : color.gray
//decor = plot(crsi,"Decor",style = plot.style_columns,histbase = 50,color=trendColor,linewidth = 2)
bgcolor(color.new(trendColor,75))
//plotcandle(open,high,low,close,"Candles",color=trendColor,wickcolor = trendColor,bordercolor = trendColor,force_overlay = true)
-
2-3-5 sma stratejisi eklenmiş hali...
PHP Code:
//@version=6
indicator(title = 'Master Trend BUY&SELL', shorttitle = '.', overlay = true)
// Color variables
upTrendColor = color.green
neutralColor = #0e0e0e
downTrendColor = color.red
fillColor = color.rgb(12, 12, 12, 70) // Color between lines
yellowColor = color.rgb(230, 214, 2)
blackTextColor = color.rgb(0, 0, 0)
blueColor = color.rgb(233, 217, 0)
whiteTextColor = color.rgb(7, 7, 7)
greenColor = color.green
redColor = color.red
// Source
source = input(defval = close, title = 'Source')
// Sampling Period
period = input.int(defval = 50, minval = 1, title = 'Sampling Period')
// Range Multiplier
multiplier = input.float(defval = 3.0, minval = 0.1, title = 'Range Multiplier')
// Take Profit Settings
takeProfitPips = input.float(defval = 600.0, title = 'Take Profit (in pips)')
// Smooth Average Range
smoothRange(x, t, m) =>
adjustedPeriod = t * 2 - 1
avgRange = ta.ema(math.abs(x - x[1]), t)
smoothRange = ta.ema(avgRange, adjustedPeriod) * m
smoothRange
smoothedRange = smoothRange(source, period, multiplier)
// Trend Filter
trendFilter(x, r) =>
filtered = x
filtered := x > nz(filtered[1]) ? x - r < nz(filtered[1]) ? nz(filtered[1]) : x - r : x + r > nz(filtered[1]) ? nz(filtered[1]) : x + r
filtered
filter = trendFilter(source, smoothedRange)
// Filter Direction
upCount = 0.0
upCount := filter > filter[1] ? nz(upCount[1]) + 1 : filter < filter[1] ? 0 : nz(upCount[1])
downCount = 0.0
downCount := filter < filter[1] ? nz(downCount[1]) + 1 : filter > filter[1] ? 0 : nz(downCount[1])
// Colors
filterColor = upCount > 0 ? upTrendColor : downCount > 0 ? downTrendColor : neutralColor
// Double Line Design
lineOffset = smoothedRange * 0.1
upperLinePlot = plot(filter + lineOffset, color = filterColor, linewidth = 1, title = 'Yükseliş Trend Çizgisi')
lowerLinePlot = plot(filter - lineOffset, color = filterColor, linewidth = 1, title = 'Düşüş Trend Çizgisi')
//fill(upperLinePlot, lowerLinePlot, color = fillColor, title = 'Trend Fill')
// Break Outs
longCondition = bool(na)
shortCondition = bool(na)
longCondition := source > filter and source > source[1] and upCount > 0 or source > filter and source < source[1] and upCount > 0
shortCondition := source < filter and source < source[1] and downCount > 0 or source < filter and source > source[1] and downCount > 0
initialCondition = 0
initialCondition := longCondition ? 1 : shortCondition ? -1 : initialCondition[1]
longSignal = longCondition and initialCondition[1] == -1
shortSignal = shortCondition and initialCondition[1] == 1
// Take Profit Logic
var float entryPriceBuy = na
var float entryPriceSell = na
takeProfitSignalBuy = false
takeProfitSignalSell = false
if longSignal
entryPriceBuy := source
entryPriceBuy
if not na(entryPriceBuy) and source >= entryPriceBuy + takeProfitPips * syminfo.mintick
takeProfitSignalBuy := true
entryPriceBuy := na
entryPriceBuy
if shortSignal
entryPriceSell := source
entryPriceSell
if not na(entryPriceSell) and source <= entryPriceSell - takeProfitPips * syminfo.mintick
takeProfitSignalSell := true
entryPriceSell := na
entryPriceSell
// Alerts and Signals
plotshape(longSignal, title = 'Smart Buy Signal', text = 'Al', textcolor = color.white, style = shape.labelup, size = size.small, location = location.belowbar, color = greenColor)
plotshape(shortSignal, title = 'Smart Sell Signal', text = 'Sat', textcolor = color.white, style = shape.labeldown, size = size.small, location = location.abovebar, color = redColor)
//plotshape(takeProfitSignalBuy, title = 'Book Profit Buy', text = 'Book Profit', textcolor = blackTextColor, style = shape.labeldown, size = size.small, location = location.abovebar, color = yellowColor)
//plotshape(takeProfitSignalSell, title = 'Book Profit Sell', text = 'Book Profit', textcolor = whiteTextColor, style = shape.labelup, size = size.small, location = location.belowbar, color = blueColor)
/////
// === Inputs ===
fairLen = input.int(50, "Fair Value EMA Length")
zLen = input.int(100, "Z-Score Lookback Length")
zThreshold = input.float(3.0, "Z-Score Threshold")
src = input.source(close, "Source")
rsiLen = input.int(14, "RSI Length")
rsiEmaLen = input.int(7, "EMA of RSI Slope")
colorMode = input.string("None", "Bar Coloring Mode", options=[
"None",
"Reversal Solid",
"Reversal Fade",
"Exceeding Bands",
"Classic Heat"
])
enableSignals = input.bool(false,'Show Signals')
// === Smooth RGB Gradient Function
f_colorGradient(_ratio, _colA, _colB) =>
rA = color.r(_colA)
gA = color.g(_colA)
bA = color.b(_colA)
rB = color.r(_colB)
gB = color.g(_colB)
bB = color.b(_colB)
rr = rA + int((rB - rA) * _ratio)
rg = gA + int((gB - gA) * _ratio)
rb = bA + int((bB - bA) * _ratio)
color.rgb(rr, rg, rb, 0)
// === Color Scheme ===
bullMain = color.new(#5CF0D7, 0)
bearMain = color.new(#B32AC3, 0)
labelTextCol = color.white
borderCol = color.white
// === Fair Value (EMA Only) ===
fair = ta.ema(src, fairLen)
// === Z-Score Deviation
dev = src - fair
devMean = ta.sma(dev, zLen)
devStdev = ta.stdev(dev, zLen)
zScore = devStdev != 0 ? (dev - devMean) / devStdev : 0
// === Z-Bands
upperBand = fair + zThreshold * devStdev
lowerBand = fair - zThreshold * devStdev
// === Re-entry Logic
wasAbove = src[1] > upperBand[1]
wasBelow = src[1] < lowerBand[1]
backInsideFromAbove = wasAbove and src <= upperBand
backInsideFromBelow = wasBelow and src >= lowerBand
// === RSI EMA Slope Filter
rsi = ta.rsi(close, rsiLen)
rsiEma = ta.ema(rsi, rsiEmaLen)
rsiSlope = rsiEma - rsiEma[1]
slopeUp = rsiSlope > 0
slopeDown = rsiSlope < 0
// === Signal Memory (One per slope)
var bool buyFiredOnSlope = false
var bool sellFiredOnSlope = false
// Reset logic when slope flips
buyReset = ta.crossover(rsiSlope, 0)
sellReset = ta.crossunder(rsiSlope, 0)
if buyReset
buyFiredOnSlope := false
if sellReset
sellFiredOnSlope := false
// Final entry conditions
finalBuy = backInsideFromBelow and slopeUp and not buyFiredOnSlope and enableSignals
finalSell = backInsideFromAbove and slopeDown and not sellFiredOnSlope and enableSignals
if finalBuy
buyFiredOnSlope := true
if finalSell
sellFiredOnSlope := true
// === Plot Fair Value and Bands (All White)
pUpper = plot(upperBand, "Üst Band", color=borderCol, linewidth=1)
pLower = plot(lowerBand, "Alt Band", color=borderCol, linewidth=1)
pFair = plot(fair, "Adil EMA", color=borderCol, linewidth=2)
// === Elegant Signal Labels
//plotshape(finalBuy, title="Buy", location=location.belowbar, style=shape.labelup, text="𝓤𝓹", color=bullMain, textcolor=#000000, size=size.small)
//plotshape(finalSell, title="Sell", location=location.abovebar, style=shape.labeldown, text="𝓓𝓸𝔀𝓷", color=bearMain, textcolor=labelTextCol, size=size.small)
// === Barcolor with Smoothing
// === Gradient Fill: Top → Mid, Bottom → Mid
fill(pUpper, pFair, upperBand, fair,color.new(bearMain, 60), #00010400)
fill(pFair, pLower, fair, lowerBand, color.new(#000000, 100),color.new(bullMain, 60))
// === Bar Coloring Modes
// Reversal Memory (for "Reversal Solid" and "Reversal Fade")
var string lastSignal = ""
if finalBuy
lastSignal := "bull"
if finalSell
lastSignal := "bear"
// Reversal Fade Tracker
var int signalAge = 0
if finalBuy or finalSell
signalAge := 0
else
signalAge += 1
// info
var string lastTrend = ""
if close > upperBand
lastTrend := "bull"
else if close < lowerBand
lastTrend := "bear"
// === Bar Coloring Logic
var color barCol = na
// 1. Reversal Solid
if colorMode == "Reversal Solid"
barCol := lastSignal == "bull" ? color.new(bullMain, 0) : lastSignal == "bear" ? color.new(bearMain, 0) : na
if colorMode == "None"
barCol := na
// 2. Reversal Fade
if colorMode == "Reversal Fade"
fade = math.min(90, signalAge * 1)
barCol := lastSignal == "bull" ? color.new(bullMain, fade) : lastSignal == "bear" ? color.new(bearMain, fade) : na
// 4. Exceeding Bands Only (only when outside bands)
if colorMode == "Exceeding Bands"
barCol := close > upperBand ? color.new(bullMain, 0) : close < lowerBand ? color.new(bearMain, 0) : na
// 5. Classic Heat — correct: strongest color near bands, fade near fair
// 5. Classic Heat — fixed: most intense near boundaries, fades toward fair
// 6. Gradient Flow — RGB blend from bull to bear based on band distance
if colorMode == "Classic Heat"
bandRange = upperBand - lowerBand
ratioRaw = (close - lowerBand) / bandRange
ratioClamped = math.max(0.0, math.min(ratioRaw, 1.0))
barCol := f_colorGradient(ratioClamped, bullMain, bearMain)
barcolor(barCol)
// === Table Position Setting
enableTable = input.bool(true,'Enable Table')
tablePos = input.string("Top Right", "Table Position", options=["Top Left", "Top Right", "Bottom Left", "Bottom Right"])
pos = tablePos == "Top Left" ? position.top_left :
tablePos == "Top Right" ? position.top_right :
tablePos == "Bottom Left" ? position.bottom_left :
position.bottom_right
// === Scoring Logic
score_z = zScore < -zThreshold ? +1 : zScore > zThreshold ? -1 : 0
score_slope = rsiSlope > 0 ? +1 : rsiSlope < 0 ? -1 : 0
score_price = close > fair ? +1 : close < fair ? -1 : 0
score_trend = lastTrend == "bull" ? +1 : lastTrend == "bear" ? -1 : 0
score_reentry = finalBuy ? +1 : finalSell ? -1 : 0
// === Score Aggregation
totalScore = score_z + score_slope + score_price + score_trend + score_reentry
scoreCount = 5
avgScore = totalScore / scoreCount
finalSignal = avgScore > 0.1 ? "AL" : avgScore < -0.1 ? "SAT" : "Nötr"
finalColor = avgScore > 0.1 ? bullMain : avgScore < -0.1 ? bearMain : color.gray
// === Shared Style
bgcolor = color.new(#000000, 0)
textCol = color.white
// === Table Drawing
if bar_index % 2 == 0 and enableTable
var table scoreTable = table.new(pos, 2, 7,frame_width = 1, border_width=1, frame_color=color.white, border_color=color.white)
table.cell(scoreTable, 0, 0, "İnd", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 0, "Puan", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 1, "Z-Score", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 1, str.tostring(score_z), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 2, "RSI", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 2, str.tostring(score_slope), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 3, "Fiyat", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 3, str.tostring(score_price), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 4, "Trend ", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 4, str.tostring(score_trend), bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 5, "R Giriş", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 5, str.tostring(score_reentry),bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 0, 6, "Sonuç", bgcolor=bgcolor, text_color=textCol)
table.cell(scoreTable, 1, 6, finalSignal, bgcolor=bgcolor, text_color=finalColor)
table.cell_set_text_font_family(scoreTable,0,0,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,0,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,1,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,1,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,2,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,2,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,3,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,3,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,4,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,4,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,5,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,5,font.family_monospace)
table.cell_set_text_font_family(scoreTable,0,6,font.family_monospace)
table.cell_set_text_font_family(scoreTable,1,6,font.family_monospace)
/////////////////
src88 = input.source(close,"RSI Source",group = "Connors RSI")
lenrsi = input(24, "RSI Length",group = "Connors RSI")
lenupdown = input(20, "UpDown Length",group = "Connors RSI")
lenroc = input(75, "ROC Length",group = "Connors RSI")
z_score_length = input(14, "Z-Score Lookback",group = "Filtering")
threshold = input.float(1.5, "Z-Score Threshold", step=0.025,group = "Filtering")
trendingLongThreshold = input.float(65, "Trending Long Threshold" ,group = "Filtering")
trendingShortThreshold = input.float(35, "Trending Short Threshold",group = "Filtering")
revertingLongThreshold = input.float(70, title="Reverting Long Threshold",group = "Filtering")
revertingShortThreshold = input.float(30, title="Reverting Short Threshold",group = "Filtering")
// ─── CONNORS RSI ──────────────────────────────────────────────────────────
updown(s) =>
isEqual = s == s[1]
isGrowing = s > s[1]
ud = 0.0
ud := isEqual ? 0 : isGrowing ? (nz(ud[1]) <= 0 ? 1 : nz(ud[1])+1) : (nz(ud[1]) >= 0 ? -1 : nz(ud[1])-1)
ud
rsi88 = ta.rsi(src88, lenrsi)
updownrsi = ta.rsi(updown(src88), lenupdown)
percentrank = ta.percentrank(ta.roc(src88, 1), lenroc)
crsi = math.avg(rsi, updownrsi, percentrank)
// ─── Z-SCORING ──────────────────────────────────────────────────────────
mean = ta.sma(crsi, z_score_length)
stdDev = ta.stdev(crsi, z_score_length)
zScore88 = (crsi - mean) / stdDev
isTrending = math.abs(zScore88) > threshold
// ─── Signal Generation ────────────────────────────────────────────────
var int signal = 0
if barstate.isconfirmed
if isTrending
signal := crsi > trendingLongThreshold ? 1 : crsi < trendingShortThreshold ? -1 : signal[1]
else
signal := crsi > revertingLongThreshold ? 1 : crsi < revertingShortThreshold ? -1 : signal[1]
trendColor = signal == 1 ? #17dfad : signal == -1 ? #dd326b : color.gray
bgcolor(color.new(trendColor,75))
/////////////
//@version=6
src6 = close
ma5 = ta.sma(src6, 2)
ma8 = ta.sma(src6, 3)
ma13 = ta.sma(src6, 5)
buy_cond = ta.cross(ma5, ma13) and ma5 > ma13
sell_cond = ta.cross(ma5, ma13) and ma5 < ma8 and ma5 < ma13
plotarrow(buy_cond ? 1 : 0, colordown = color.rgb(0, 255, 8), title = 'BUY SIGNAL', maxheight = 50, minheight = 50)
plotarrow(sell_cond ? -1 : 0, colorup = color.rgb(255, 0, 0), title = 'SELL SIGNAL', maxheight = 50, minheight = 50)