IchimokuBuy Sell With Stoch RSI
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © aliyilmazov

//@version=5
indicator(title="Ichimoku Kumo Cloud Crossover", shorttitle="IKCC", overlay=true)

// Ichimoku Kumo Cloud hesaplama
donchian(length) =>
    h = ta.highest(high, length)
    l = ta.lowest(low, length)
    (h + l) / 2

conversionPeriod = input(9, title="Conversion Line Period")
basePeriod = input(26, title="Base Line Period")
lead1Period = input(52, title="Leading Span 1 Period")
lead2Period = input(104, title="Leading Span 2 Period")

conversionLine = ta.sma(donchian(conversionPeriod), conversionPeriod)
baseLine = ta.sma(donchian(basePeriod), basePeriod)
lead1 = ta.sma(hlc3, lead1Period)
lead2 = donchian(lead2Period)

// MACD göstergesi hesaplamaları
fastLength = input(12, title="Fast EMA Length")
slowLength = input(26, title="Slow EMA Length")
signalSMA = input(9, title="Signal Line SMA Length")

// MACD Osilatör 
[macdLine, signalLine, macdHistogram] = ta.macd(close, fastLength, slowLength, signalSMA)

// MACD Osilatör hesaplaması
macdOscillator = macdLine - signalLine

// EMA 200 hesaplama
lengthEMA200 = input(200, title="EMA 200 Period")
ema200 = ta.ema(close, lengthEMA200)

// RSI hesaplama
lengthRSI = input(14, title="RSI Period")
rsi = ta.rsi(close, lengthRSI)

// Calculate RSI for Stoch RSI
rsiLength = input(14, title="Stoch RSI Length")
rsiStoch = ta.rsi(close, rsiLength)

// Calculate Stoch RSI
stochKLength = input(3, title="Stoch K Length")
stochDLength = input(3, title="Stoch D Length")
k = ta.sma(rsiStoch - ta.lowest(rsiStoch, rsiLength), stochKLength) / ta.sma(ta.highest(rsiStoch, rsiLength) - ta.lowest(rsiStoch, rsiLength), stochKLength)
d = ta.sma(k, stochDLength)

// Kumo Cloud renkleri
cloudColor = baseLine > conversionLine ? color.green : color.red

plot(lead1, title="Leading Span 1", color=color.blue)
plot(lead2, title="Leading Span 2", color=color.orange)
plot(conversionLine, title="Conversion Line", color=color.purple)
plot(baseLine, title="Base Line", color=color.red)
plot(0, title="Zero Line", color=color.gray)

// Kumo Cloud
fill(plot(baseLine, title="Kumo Cloud", color=cloudColor), plot(conversionLine))

// Sinyal üretimi
crossOverUp = ta.crossover(conversionLine, baseLine) and close > ema200 and rsi > 50 and rsi < 70 and macdHistogram > 0 and high >= (ema200 + 0.25 * (high - ema200)) and k < d
crossOverDown = ta.crossunder(conversionLine, baseLine) and close < ema200 and rsi < 50 and rsi > 20 and macdHistogram < 0 and low <= (ema200 + 0.25 * (low - ema200)) and k > d

plotshape(crossOverUp, title="Alış Sinyali", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small, text="Buy")
plotshape(crossOverDown, title="Satış Sinyali", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small, text="Sell")
// EMA 200 çizgisini grafiğe ekleyin
plot(ema200, title="EMA 200", color=color.blue, linewidth=2)
