Untitled
unknown
plain_text
a year ago
5.7 kB
18
Indexable
//@version=6
indicator("ENDEKS BAZLI RSN_LINE", overlay=false)
import TradingView/ta/10
// Kullanıcıdan endeks sesçimi
s2 = input.symbol("XU100", title="Endeks Karşılaştırması")
// Referans endeks seviyesi (örneğin geçmişteki belirli bir seviye)
ref_xu100 = input.float(11288, "Referans XU100 Değeri")
// Haftalık ve Aylık için özel EMA periyodu
weekly_monthly_ema_period = input.int(14, title="Haftalık/Aylık EMA Periyodu", minval=1, maxval=50)
// Hisse ve endeks verileri
[o1, h1, l1, c1] = request.security(syminfo.tickerid, timeframe.period, [open, high, low, close])
[o2, h2, l2, c2] = request.security(s2, timeframe.period, [open, high, low, close])
// Kompozit OHLC
comp_o = (o1 / c2) * ref_xu100
comp_h = (h1 / c2) * ref_xu100
comp_l = (l1 / c2) * ref_xu100
comp_c = (c1 / c2) * ref_xu100
// EMA'lar hesapla
ema8 = ta.ema(comp_c, 8)
ema14 = ta.ema(comp_c, 14)
ema34 = ta.ema(comp_c, 34)
ema55 = ta.ema(comp_c, 55)
ema233 = ta.ema(comp_c, 233)
ema377 = ta.ema(comp_c, 377)
// Haftalık/Aylık için dinamik EMA
weekly_monthly_ema = ta.ema(comp_c, weekly_monthly_ema_period)
// RSI hesapla (sabit 14 periyot)
rsi = ta.rsi(comp_c, 14)
// Zaman dilimine göre referans EMA'yı otomatik seç
var ref_ema = float(na)
if timeframe.isintraday
if timeframe.multiplier <= 15 // 2 dakika, 5 dakika, 15 dakika
ref_ema := ema377
else if timeframe.multiplier <= 120 // 30 dakika, 1 saat, 2 saat
ref_ema := ema233
else // 4 saat
ref_ema := ema55
else // Günlük, 3 günlük, haftalık, aylık ve üzeri
// Haftalık ve aylık için özel EMA kullan
if timeframe.isweekly or timeframe.ismonthly
ref_ema := weekly_monthly_ema
else
ref_ema := ema34
// EMA kesişmelerini tespit et
ema34_above_ref_ema = ema34 > ref_ema
ema34_above_ref_ema_prev = ema34[1] > ref_ema[1]
// EMA kesişme sinyalleri
bullish_cross = not ema34_above_ref_ema_prev and ema34_above_ref_ema // Yukarı kesme
bearish_cross = ema34_above_ref_ema_prev and not ema34_above_ref_ema // Aşağı kesme
// YENI: RSI kesişme sinyalleri
rsi_above_50 = rsi > 50
rsi_above_50_prev = rsi[1] > 50
rsi_bullish_cross = not rsi_above_50_prev and rsi_above_50 // RSI 50 üzerine kesme
rsi_bearish_cross = rsi_above_50_prev and not rsi_above_50 // RSI 50 altına kesme
// Trend durumu (hangi EMA'nın üstte olduğu)
var trend = ema34 > ref_ema ? 1 : -1 // 1: yukarı trend, -1: aşağı trend
// Trend değişimlerini güncelle
if bullish_cross
trend := 1
else if bearish_cross
trend := -1
// GÜNCELLENMIŞ: Mum renklerini belirle
barColor = color.blue // Varsayılan renk
// Önce RSI kesişmeleri kontrol et
if rsi_bullish_cross
barColor := color.yellow // RSI 50 üzerine kesme - SARI
else if rsi_bearish_cross
barColor := color.purple // RSI 50 altına kesme - MOR
else
// Normal EMA bazlı renklendirme
if timeframe.isintraday and timeframe.multiplier >= 240 or not timeframe.isintraday
if timeframe.isweekly or timeframe.ismonthly
barColor := comp_c > weekly_monthly_ema ? color.green : color.red
else
barColor := comp_c > ema34 ? color.green : color.red
else
barColor := trend == 1 ? color.green : color.red
// Mumları çiz
plotcandle(comp_o, comp_h, comp_l, comp_c,
color=barColor,
wickcolor=barColor,
bordercolor=barColor)
// Referans EMA ismini belirle
ref_ema_name = "EMA 34" // Varsayılan değer
if timeframe.isintraday
if timeframe.multiplier <= 15
ref_ema_name := "EMA 377"
else if timeframe.multiplier <= 120
ref_ema_name := "EMA 233"
else
ref_ema_name := "EMA 55"
else
if timeframe.isweekly or timeframe.ismonthly
ref_ema_name := "EMA " + str.tostring(weekly_monthly_ema_period)
else
ref_ema_name := "EMA 34"
// EMA Renkleri - ref_ema trend durumuna göre, ema34 sabit renk
ref_ema_color = trend == 1 ? color.green : color.red
// EMA'ları çiz
plot(ema8, title="EMA 8", color=color.lime, linewidth=2)
plot(ema14, title="EMA 14", color=color.aqua, linewidth=2)
plot(ema34, title="EMA 34", color=color.red, linewidth=2, linestyle=plot.linestyle_dashed)
plot(ema55, title="EMA 55", color=color.orange, linewidth=1, display = display.none)
plot(ema233, title="EMA 233", color=color.rgb(120, 8, 180), linewidth=1, display = display.none)
plot(ema377, title="EMA 377", color=color.rgb(6, 35, 164), linewidth=1, display = display.none)
// Referans EMA çizimi
plot(timeframe.isintraday and timeframe.multiplier <= 15 ? ref_ema : na, title="RSN_LINE", color=ref_ema_color, linewidth=3, display = display.none)
plot(timeframe.isintraday and timeframe.multiplier >= 16 and timeframe.multiplier <= 120 ? ref_ema : na, title="RSN_LINE", display = display.none)
plot(timeframe.isintraday and timeframe.multiplier > 120 ? ref_ema : na, title="RSN_LINE", color=ref_ema_color, linewidth=3, display = display.none)
plot(not timeframe.isintraday ? ref_ema : na, title="RSN_LINE", color=ref_ema_color, linewidth=3, display = display.none)
// RSI çizgisi (opsiyonel - görünür değil)
plot(rsi, title="RSI", color=color.new(color.blue, 70), display=display.none)
// Alış ve satış sinyallerini hesapla
entry_price = bullish_cross ? comp_c : na
exit_price = bearish_cross ? comp_c : na
// Son giriş fiyatını sakla
var float last_entry_price = 0.0
if bullish_cross
last_entry_price := comp_c
// Pozisyon durumu için değişken
var bool in_position = false
// Alış ve satış sinyallerini takip et
if bullish_cross
in_position := true
last_entry_price := comp_c
else if bearish_cross
in_position := falseEditor is loading...
Leave a Comment