Chart Reading Coach - EMA Trend, Support/Resistance and Candle P

TheTrendTutor · study · 188 行 · 点赞 80 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator("Chart Reading Coach [EMA Trend, S/R, Candles]", shorttitle="Chart Coach", overlay=true, max_labels_count=500, max_lines_count=100)
 
// ================= SETTINGS / AYARLAR =================
grpG = "Display / Görünüm"
lang        = input.string("English", "Language / Dil", options=["English", "Türkçe"], group=grpG)
showNotes   = input.bool(true,  "Line notes / Çizgi notları", group=grpG)
showTable   = input.bool(true,  "Info panel / Bilgi paneli", group=grpG)
showPattern = input.bool(true,  "Candle patterns / Mum formasyonları", group=grpG)
showSR      = input.bool(true,  "Support & resistance / Destek & direnç", group=grpG)
showSignal  = input.bool(true,  "Signals / Sinyaller", group=grpG)
showSmma    = input.bool(false, "SMMA line / SMMA çizgisi", group=grpG)
tableSizeS  = input.string("Small", "Panel text size / Panel yazı boyutu", options=["Tiny", "Small", "Normal"], group=grpG)
 
grpP = "Lengths / Periyotlar"
lenFast = input.int(20,  "Fast EMA / Hızlı EMA", minval=1, group=grpP)
lenMid  = input.int(50,  "Middle EMA / Orta EMA", minval=1, group=grpP)
lenSlow = input.int(200, "Slow EMA / Yavaş EMA", minval=1, group=grpP)
lenSmma = input.int(50,  "SMMA length / SMMA periyodu", minval=1, group=grpP)
rsiLen  = input.int(14,  "RSI length / RSI periyodu", minval=1, group=grpP)
pivLen  = input.int(10,  "S/R sensitivity (bars) / D/D hassasiyeti (mum)", minval=3, group=grpP)
volMult = input.float(1.8, "Volume spike multiplier / Hacim patlaması çarpanı", step=0.1, group=grpP)
patGap  = input.int(8, "Min bars between patterns / Formasyonlar arası min. mum", minval=1, group=grpP)
 
isEN = lang == "English"
tx(string en, string tr) =>
    isEN ? en : tr
 
fL = str.tostring(lenFast)
mL = str.tostring(lenMid)
sL = str.tostring(lenSlow)
 
// ================= CALCULATIONS / HESAPLAR =================
emaF   = ta.ema(close, lenFast)
emaM   = ta.ema(close, lenMid)
emaS   = ta.ema(close, lenSlow)
smma   = ta.rma(close, lenSmma)
rsi    = ta.rsi(close, rsiLen)
volAvg = ta.sma(volume, 20)
volSpike = volume > volAvg * volMult
atr    = ta.atr(14)
 
upTrend   = close > emaS and emaF > emaM
downTrend = close < emaS and emaF < emaM
 
// ================= LINES / ÇİZGİLER =================
pF = plot(emaF, "Fast EMA", color=color.new(color.aqua, 0), linewidth=1)
pM = plot(emaM, "Middle EMA", color=color.new(color.orange, 0), linewidth=2)
plot(emaS, "Slow EMA (main trend)", color=color.new(color.red, 0), linewidth=3)
plot(showSmma ? smma : na, "SMMA", color=color.new(color.purple, 0), linewidth=2)
fill(pF, pM, color = emaF > emaM ? color.new(color.green, 85) : color.new(color.red, 85), title="Trend cloud")
 
// ================= SIGNALS / SİNYALLER =================
crossUp = ta.crossover(emaF, emaM)
crossDn = ta.crossunder(emaF, emaM)
buySig  = crossUp and close > emaS and rsi < 70
sellSig = crossDn and close < emaS and rsi > 30
 
bounceUp = emaM > emaS and low <= emaM and close > emaM and close > open and close > emaS
bounceDn = emaM < emaS and high >= emaM and close < emaM and close < open and close < emaS
var int lastBU = na
var int lastBD = na
bounceUpOk = false
bounceDnOk = false
if bounceUp and (na(lastBU) or bar_index - lastBU > 10)
    bounceUpOk := true
    lastBU := bar_index
if bounceDn and (na(lastBD) or bar_index - lastBD > 10)
    bounceDnOk := true
    lastBD := bar_index
 
volNote = volSpike ? tx("\n✅ Volume well above average: strong move, more reliable signal.", "\n✅ Hacim ortalamanın çok üstünde: hareket güçlü, sinyal daha güvenilir.") : tx("\n⚠️ Normal volume: weak confirmation, be careful.", "\n⚠️ Hacim normal: onay zayıf, dikkatli ol.")
 
if showSignal and buySig
    label.new(bar_index, low - atr * 0.6, tx("BUY", "AL"), style=label.style_label_up, color=color.green, textcolor=color.white, size=size.small, tooltip=tx("EMA CROSS BUY\nEMA " + fL + " crossed above EMA " + mL + " = short-term buyers got stronger.\nPrice above EMA " + sL + " = main trend is up.\nRSI below 70 = not overbought yet.", "KESİŞİM AL\nEMA " + fL + ", EMA " + mL + "'yi yukarı kesti = kısa vadede alıcılar güçlendi.\nFiyat EMA " + sL + " üstünde = ana trend yukarı.\nRSI 70 altında = henüz aşırı pahalı değil.") + volNote + tx("\nStop idea: slightly below the last swing low.", "\nStop fikri: son dibin biraz altı."))
if showSignal and sellSig
    label.new(bar_index, high + atr * 0.6, tx("SELL", "SAT"), style=label.style_label_down, color=color.red, textcolor=color.white, size=size.small, tooltip=tx("EMA CROSS SELL\nEMA " + fL + " crossed below EMA " + mL + " = short-term sellers got stronger.\nPrice below EMA " + sL + " = main trend is down.\nRSI above 30 = not oversold yet.", "KESİŞİM SAT\nEMA " + fL + ", EMA " + mL + "'yi aşağı kesti = kısa vadede satıcılar güçlendi.\nFiyat EMA " + sL + " altında = ana trend aşağı.\nRSI 30 üstünde = henüz aşırı ucuz değil.") + volNote + tx("\nConsider protecting open positions.", "\nElinde varsa korumayı düşün."))
if showSignal and bounceUpOk
    label.new(bar_index, low - atr * 0.6, tx("Pullback BUY", "Tepki AL"), style=label.style_label_up, color=color.new(color.teal, 10), textcolor=color.white, size=size.tiny, tooltip=tx("PULLBACK BUY\nIn an uptrend, price pulled back to EMA " + mL + ", touched it and closed green above it.\nEMA " + mL + " acted as support. The trend may continue.", "TEPKİ AL\nYükselen trendde fiyat EMA " + mL + "'ye kadar geri çekildi, değdi ve üstünde yeşil kapattı.\nEMA " + mL + " burada destek gibi çalıştı. Trendin devam etme ihtimali var.") + volNote + tx("\nStop idea: slightly below EMA " + mL + ".", "\nStop fikri: EMA " + mL + "'nin biraz altı."))
if showSignal and bounceDnOk
    label.new(bar_index, high + atr * 0.6, tx("Pullback SELL", "Tepki SAT"), style=label.style_label_down, color=color.new(color.maroon, 10), textcolor=color.white, size=size.tiny, tooltip=tx("PULLBACK SELL\nIn a downtrend, price rallied to EMA " + mL + ", touched it and closed red below it.\nEMA " + mL + " acted as resistance. The decline may continue.", "TEPKİ SAT\nDüşen trendde fiyat EMA " + mL + "'ye kadar yükseldi, değdi ve altında kırmızı kapattı.\nEMA " + mL + " burada direnç gibi çalıştı. Düşüşün devam etme ihtimali var.") + volNote)
 
// ================= CANDLE PATTERNS / MUM FORMASYONLARI =================
body   = math.abs(close - open)
rng    = high - low
upperW = high - math.max(close, open)
lowerW = math.min(close, open) - low
priorDown = close[1] < close[4]
priorUp   = close[1] > close[4]
 
bullEngRaw = close > open and close[1] < open[1] and close >= open[1] and open <= close[1] and body > body[1] * 1.2 and body >= atr * 0.7 and priorDown
bearEngRaw = close < open and close[1] > open[1] and close <= open[1] and open >= close[1] and body > body[1] * 1.2 and body >= atr * 0.7 and priorUp
hammerRaw  = body > 0 and rng >= atr * 0.8 and lowerW >= body * 2 and upperW <= body * 0.5 and priorDown and rsi < 45
starRaw    = body > 0 and rng >= atr * 0.8 and upperW >= body * 2 and lowerW <= body * 0.5 and priorUp and rsi > 55
 
var int lastBullPat = na
var int lastBearPat = na
bullEng = false
hammer  = false
bearEng = false
star    = false
if (bullEngRaw or hammerRaw) and (na(lastBullPat) or bar_index - lastBullPat > patGap)
    bullEng := bullEngRaw
    hammer  := hammerRaw and not bullEngRaw
    lastBullPat := bar_index
if (bearEngRaw or starRaw) and (na(lastBearPat) or bar_index - lastBearPat > patGap)
    bearEng := bearEngRaw
    star    := starRaw and not bearEngRaw
    lastBearPat := bar_index
 
if showPattern and bullEng
    label.new(bar_index, low - atr * 1.6, tx("Engulf↑", "Yutan↑"), style=label.style_label_up, color=color.new(color.green, 40), textcolor=color.white, size=size.tiny, tooltip=tx("BULLISH ENGULFING\nAfter a decline, a large green candle fully engulfed the previous red candle.\nBuyers overpowered sellers = possible upward reversal. More meaningful at support.", "YUTAN BOĞA\nDüşüşten sonra gelen büyük yeşil mum, önceki kırmızı mumu tamamen 'yuttu'.\nAlıcılar satıcıları ezdi = yukarı dönüş işareti. Destek seviyesinde çıkarsa daha değerli."))
if showPattern and bearEng
    label.new(bar_index, high + atr * 1.6, tx("Engulf↓", "Yutan↓"), style=label.style_label_down, color=color.new(color.red, 40), textcolor=color.white, size=size.tiny, tooltip=tx("BEARISH ENGULFING\nAfter a rise, a large red candle fully engulfed the previous green candle.\nSellers took control = possible downward reversal. More meaningful at resistance.", "YUTAN AYI\nYükselişten sonra gelen büyük kırmızı mum, önceki yeşil mumu tamamen yuttu.\nSatıcılar kontrolü aldı = aşağı dönüş işareti. Direnç seviyesinde çıkarsa daha değerli."))
if showPattern and hammer
    label.new(bar_index, low - atr * 1.6, tx("Hammer", "Çekiç"), style=label.style_label_up, color=color.new(color.green, 40), textcolor=color.white, size=size.tiny, tooltip=tx("HAMMER\nLong lower wick: price was pushed down but buyers brought it back.\nAt the end of a decline it may mark a bottom. Confirmed if the next candle closes green.", "ÇEKİÇ\nUzun alt fitil: fiyat aşağı itildi ama alıcılar geri topladı.\nDüşüşün sonunda görülürse dip sinyali olabilir. Sonraki mum yeşil kapanırsa onaylanır."))
if showPattern and star
    label.new(bar_index, high + atr * 1.6, tx("Shoot. star", "Kayan Y."), style=label.style_label_down, color=color.new(color.red, 40), textcolor=color.white, size=size.tiny, tooltip=tx("SHOOTING STAR\nLong upper wick: price went up but sellers pushed it back.\nAt the end of a rise it may mark a top. Confirmed if the next candle closes red.", "KAYAN YILDIZ\nUzun üst fitil: fiyat yukarı çıktı ama satıcılar geri bastırdı.\nYükselişin sonunda görülürse tepe sinyali olabilir. Sonraki mum kırmızı kapanırsa onaylanır."))
 
// ================= SUPPORT / RESISTANCE — DESTEK / DİRENÇ =================
ph = ta.pivothigh(high, pivLen, pivLen)
pl = ta.pivotlow(low, pivLen, pivLen)
var array<line>  resLines  = array.new<line>()
var array<label> resLabels = array.new<label>()
var array<line>  supLines  = array.new<line>()
var array<label> supLabels = array.new<label>()
 
if showSR and not na(ph)
    array.push(resLines, line.new(bar_index - pivLen, ph, bar_index, ph, extend=extend.right, color=color.new(color.red, 30), style=line.style_dashed))
    array.push(resLabels, label.new(bar_index - pivLen, ph, tx("Resistance", "Direnç"), style=label.style_label_down, color=color.new(color.red, 70), textcolor=color.white, size=size.tiny, tooltip=tx("RESISTANCE (ceiling)\nPrice rose to here and turned back; sellers are strong here.\nA clear close above it (breakout) can accelerate the rise, and this level may turn into support.", "DİRENÇ (tavan)\nFiyat buraya kadar çıkıp geri döndü, satıcılar burada güçlü.\nÜstünde net kapanış olursa (kırılım) yükseliş hızlanabilir ve bu çizgi desteğe dönüşür.")))
    if array.size(resLines) > 3
        line.delete(array.shift(resLines))
        label.delete(array.shift(resLabels))
 
if showSR and not na(pl)
    array.push(supLines, line.new(bar_index - pivLen, pl, bar_index, pl, extend=extend.right, color=color.new(color.green, 30), style=line.style_dashed))
    array.push(supLabels, label.new(bar_index - pivLen, pl, tx("Support", "Destek"), style=label.style_label_up, color=color.new(color.green, 70), textcolor=color.white, size=size.tiny, tooltip=tx("SUPPORT (floor)\nPrice fell to here and bounced; buyers are strong here.\nA clear close below it can accelerate the decline, and this level may turn into resistance.", "DESTEK (taban)\nFiyat buraya kadar düşüp geri yükseldi, alıcılar burada güçlü.\nAltında net kapanış olursa düşüş hızlanabilir ve bu çizgi dirence dönüşür.")))
    if array.size(supLines) > 3
        line.delete(array.shift(supLines))
        label.delete(array.shift(supLabels))
 
// ================= LINE NOTES / ÇİZGİ NOTLARI =================
var label nF = na
var label nM = na
var label nS = na
var label nX = na
if barstate.islast
    label.delete(nF)
    label.delete(nM)
    label.delete(nS)
    label.delete(nX)
    if showNotes
        nF := label.new(bar_index + 3, emaF, "EMA" + fL + tx(" · short term", " · kısa vade"), style=label.style_label_left, color=color.new(color.aqua, 20), textcolor=color.black, size=size.small, tooltip=tx("EMA " + fL + " (thin light blue)\nAverage of the last ~" + fL + " candles, reacts quickly.\nPrice above it = buyers lead in the short term. In strong trends price touches it and continues.", "EMA " + fL + " (ince açık mavi)\nSon ~" + fL + " mumun ortalaması, hızlı tepki verir.\nFiyat üstündeyse kısa vadede alıcılar önde. Güçlü trendlerde fiyat buna değip devam eder."))
        nM := label.new(bar_index + 3, emaM, "EMA" + mL + tx(" · medium term", " · orta vade"), style=label.style_label_left, color=color.new(color.orange, 20), textcolor=color.black, size=size.small, tooltip=tx("EMA " + mL + " (orange)\nMedium-term trend. Often acts as support/resistance on pullbacks.\nEMA " + fL + " crossing above it = short term strengthening; crossing below = weakening.", "EMA " + mL + " (turuncu)\nOrta vadeli trend. Geri çekilmelerde sık sık destek/direnç olur.\nEMA " + fL + " bunu yukarı keserse kısa vade güçleniyor, aşağı keserse zayıflıyor."))
        nS := label.new(bar_index + 3, emaS, "EMA" + sL + tx(" · MAIN TREND", " · ANA TREND"), style=label.style_label_left, color=color.new(color.red, 20), textcolor=color.white, size=size.small, tooltip=tx("EMA " + sL + " (thick red)\nThe most important line, watched worldwide.\nPrice ABOVE = bull market, think long side.\nPrice BELOW = bear market, be very careful with buys.", "EMA " + sL + " (kalın kırmızı)\nEn önemli çizgi, tüm dünyada takip edilir.\nFiyat ÜSTÜNDE = boğa piyasası, alım yönlü düşün.\nFiyat ALTINDA = ayı piyasası, alımlarda çok temkinli ol."))
        if showSmma
            nX := label.new(bar_index + 3, smma, "SMMA", style=label.style_label_left, color=color.new(color.purple, 20), textcolor=color.white, size=size.small, tooltip=tx("SMMA (purple)\nSmoothed moving average. Slower than EMA: fewer false signals but more lag.", "SMMA (mor)\nDüzleştirilmiş ortalama. EMA'dan daha yavaş, sahte sinyali daha az ama geç kalır."))
 
// ================= INFO PANEL / BİLGİ PANELİ =================
var table t = table.new(position.top_right, 2, 7, border_width=1, border_color=color.new(color.gray, 60))
tSize = tableSizeS == "Tiny" ? size.tiny : tableSizeS == "Small" ? size.small : size.normal
bgc = color.new(color.black, 15)
 
f_row(r, k, v, c) =>
    table.cell(t, 0, r, k, text_color=color.white, bgcolor=bgc, text_size=tSize, text_halign=text.align_left)
    table.cell(t, 1, r, v, text_color=c, bgcolor=bgc, text_size=tSize, text_halign=text.align_left)
 
if barstate.isfirst
    table.merge_cells(t, 0, 0, 1, 0)
    table.merge_cells(t, 0, 6, 1, 6)
 
if barstate.islast and showTable
    table.cell(t, 0, 0, tx("📘 CHART COACH", "📘 GRAFİK ÖĞRETMENİ"), text_color=color.yellow, bgcolor=bgc, text_size=tSize)
    f_row(1, tx("Main trend", "Ana trend"), close > emaS ? tx("UP ✅ (price above EMA" + sL + ")", "YUKARI ✅ (fiyat EMA" + sL + " üstünde)") : tx("DOWN ❌ (price below EMA" + sL + ")", "AŞAĞI ❌ (fiyat EMA" + sL + " altında)"), close > emaS ? color.lime : color.red)
    f_row(2, tx("Short trend", "Kısa trend"), emaF > emaM ? tx("Strengthening (EMA" + fL + " > EMA" + mL + ")", "Güçleniyor (EMA" + fL + " > EMA" + mL + ")") : tx("Weakening (EMA" + fL + " < EMA" + mL + ")", "Zayıflıyor (EMA" + fL + " < EMA" + mL + ")"), emaF > emaM ? color.lime : color.red)
    rsiTxt = str.tostring(rsi, "#.0") + (rsi > 70 ? tx(" · Overbought: expensive, pullback risk", " · Aşırı alım: pahalı, düşüş riski") : rsi < 30 ? tx(" · Oversold: cheap, bounce possible", " · Aşırı satım: ucuz, tepki gelebilir") : tx(" · Normal zone", " · Normal bölge"))
    f_row(3, "RSI", rsiTxt, rsi > 70 ? color.red : rsi < 30 ? color.lime : color.white)
    f_row(4, tx("Volume", "Hacim"), volSpike ? tx("SPIKE! Strong move", "PATLAMA! Güçlü hareket var") : "Normal", volSpike ? color.yellow : color.white)
    patName = bullEng ? tx("Bullish engulfing", "Yutan boğa (yükseliş)") : bearEng ? tx("Bearish engulfing", "Yutan ayı (düşüş)") : hammer ? tx("Hammer (bottom?)", "Çekiç (dip dönüşü?)") : star ? tx("Shooting star (top?)", "Kayan yıldız (tepe dönüşü?)") : tx("No special pattern", "Özel formasyon yok")
    f_row(5, tx("Last candle", "Son mum"), patName, color.white)
    summary = upTrend ? tx("SUMMARY: Trend up. Pullbacks to EMA" + fL + "/" + mL + " may offer buying opportunities.", "ÖZET: Trend yukarı. Düşüşlerde EMA" + fL + "/" + mL + "'ye gelen tepkiler alım fırsatı olabilir.") : downTrend ? tx("SUMMARY: Trend down. Don't rush to buy; rallies may meet selling pressure.", "ÖZET: Trend aşağı. Alıma acele etme, yükselişler satış baskısıyla karşılaşabilir.") : tx("SUMMARY: Undecided zone. Lines are mixed; waiting is best.", "ÖZET: Kararsız bölge. Çizgiler karışık, beklemek en iyisi.")
    table.cell(t, 0, 6, summary, text_color=color.yellow, bgcolor=bgc, text_size=tSize, text_halign=text.align_left)
 
// ================= ALERTS / ALARMLAR =================
alertcondition(buySig, "EMA cross BUY", "Chart Coach: EMA cross BUY signal")
alertcondition(sellSig, "EMA cross SELL", "Chart Coach: EMA cross SELL signal")
alertcondition(bounceUpOk, "Pullback BUY", "Chart Coach: Pullback BUY from middle EMA")
alertcondition(bounceDnOk, "Pullback SELL", "Chart Coach: Pullback SELL from middle EMA")

← 返回列表