OPEN-SOURCE SCRIPT
Alım Algoritması (EMA + RSI + MACD + ATR + Pozisyon Takibi)

//version=5
indicator("Alım Algoritması (EMA + RSI + MACD + ATR + Pozisyon Takibi)", overlay=true)
// === INPUTS ===
ema1_len = input.int(21, title="EMA 1")
ema2_len = input.int(50, title="EMA 2")
ema3_len = input.int(100, title="EMA 3")
rsi_len = input.int(14, title="RSI Length")
atr_len = input.int(14, title="ATR Length")
macd_fast = input.int(12, title="MACD Fast")
macd_slow = input.int(26, title="MACD Slow")
macd_signal = input.int(9, title="MACD Signal")
max_distance_pct = input.float(5.0, title="Max EMA Distance %", step=0.1)
// === CALCULATIONS ===
ema1 = ta.ema(close, ema1_len)
ema2 = ta.ema(close, ema2_len)
ema3 = ta.ema(close, ema3_len)
avg_ema = (ema1 + ema2 + ema3) / 3
distance_pct = math.abs(close - avg_ema) / avg_ema * 100
ema_near = distance_pct <= max_distance_pct
basis = ta.sma(close, 20)
dev = ta.stdev(close, 20)
upper = basis + 2 * dev
lower = basis - 2 * dev
width = (upper - lower) / basis
is_range = width < 0.12 // %5'ten dar bant
rsi = ta.rsi(close, rsi_len)
rsi_trend = ta.sma(rsi, 5)
rsi_up = rsi > rsi_trend
[macdLine, signalLine, hist] = ta.macd(close, macd_fast, macd_slow, macd_signal)
ema1_cross = ta.crossover(close, ema1) or ta.crossover(close, ema2) or ta.crossover(close, ema3)
ema_recent_cross = ta.barssince(ema1_cross) < 5
// === BUY SIGNAL ===
//buy_signal = ema_near and ema_recent_cross and
// macdLine > signalLine and hist > 0 and
// rsi > 45 and rsi < 65 and rsi_up
buy_signal = not is_range and ema_near and ema_recent_cross and
macdLine > signalLine and hist > 0 and
rsi > 45 and rsi < 65 and rsi_up
//buy_signal = not is_range and ema_near and ema_recent_cross and
// macdLine > signalLine and hist > 0 and
// rsi > 45 and rsi < 65 and rsi_up
// === POSITION LOGIC ===
var bool in_position = false
var float entry_price = na
var float stop_loss = na
var float take_profit_1 = na
var float take_profit_2 = na
atr = ta.atr(atr_len)
// Koşullar
new_buy = buy_signal and not in_position
// SL ve TP seviyeleri hesaplama
new_sl = close - 1.5 * atr
new_tp1 = close + 2.0 * atr
new_tp2 = close + 3.5 * atr
// Pozisyon açma
if new_buy
in_position := true
entry_price := close
stop_loss := new_sl
take_profit_1 := new_tp1
take_profit_2 := new_tp2
label.new(bar_index, low, "BUY", style=label.style_label_up, color=color.green, textcolor=color.white)
sl_hit = in_position and low <= stop_loss
tp1_hit = in_position and high >= take_profit_1
tp2_hit = in_position and high >= take_profit_2
// Pozisyon kapama sinyali
if sl_hit
in_position := false
//label.new(bar_index, low, "SL", style=label.style_label_down, color=color.red, textcolor=color.white)
if tp2_hit
in_position := false
//label.new(bar_index, high, "TP2", style=label.style_label_down, color=color.rgb(209, 34, 222), textcolor=color.white)
else if tp1_hit
in_position := false
//label.new(bar_index, high, "TP1", style=label.style_label_down, color=color.rgb(209, 34, 222), textcolor=color.white)
// === PLOT ===
// Sadece BUY, SL ve TP seviyeleri çizilir
plot(in_position ? stop_loss : na, title="Stop Loss", color=color.red, style=plot.style_linebr)
//plot(in_position ? take_profit_1 : na, title="TP1", color=color.rgb(209, 34, 222), style=plot.style_linebr)
//plot(in_position ? take_profit_2 : na, title="TP2", color=color.rgb(209, 34, 222), style=plot.style_linebr)
indicator("Alım Algoritması (EMA + RSI + MACD + ATR + Pozisyon Takibi)", overlay=true)
// === INPUTS ===
ema1_len = input.int(21, title="EMA 1")
ema2_len = input.int(50, title="EMA 2")
ema3_len = input.int(100, title="EMA 3")
rsi_len = input.int(14, title="RSI Length")
atr_len = input.int(14, title="ATR Length")
macd_fast = input.int(12, title="MACD Fast")
macd_slow = input.int(26, title="MACD Slow")
macd_signal = input.int(9, title="MACD Signal")
max_distance_pct = input.float(5.0, title="Max EMA Distance %", step=0.1)
// === CALCULATIONS ===
ema1 = ta.ema(close, ema1_len)
ema2 = ta.ema(close, ema2_len)
ema3 = ta.ema(close, ema3_len)
avg_ema = (ema1 + ema2 + ema3) / 3
distance_pct = math.abs(close - avg_ema) / avg_ema * 100
ema_near = distance_pct <= max_distance_pct
basis = ta.sma(close, 20)
dev = ta.stdev(close, 20)
upper = basis + 2 * dev
lower = basis - 2 * dev
width = (upper - lower) / basis
is_range = width < 0.12 // %5'ten dar bant
rsi = ta.rsi(close, rsi_len)
rsi_trend = ta.sma(rsi, 5)
rsi_up = rsi > rsi_trend
[macdLine, signalLine, hist] = ta.macd(close, macd_fast, macd_slow, macd_signal)
ema1_cross = ta.crossover(close, ema1) or ta.crossover(close, ema2) or ta.crossover(close, ema3)
ema_recent_cross = ta.barssince(ema1_cross) < 5
// === BUY SIGNAL ===
//buy_signal = ema_near and ema_recent_cross and
// macdLine > signalLine and hist > 0 and
// rsi > 45 and rsi < 65 and rsi_up
buy_signal = not is_range and ema_near and ema_recent_cross and
macdLine > signalLine and hist > 0 and
rsi > 45 and rsi < 65 and rsi_up
//buy_signal = not is_range and ema_near and ema_recent_cross and
// macdLine > signalLine and hist > 0 and
// rsi > 45 and rsi < 65 and rsi_up
// === POSITION LOGIC ===
var bool in_position = false
var float entry_price = na
var float stop_loss = na
var float take_profit_1 = na
var float take_profit_2 = na
atr = ta.atr(atr_len)
// Koşullar
new_buy = buy_signal and not in_position
// SL ve TP seviyeleri hesaplama
new_sl = close - 1.5 * atr
new_tp1 = close + 2.0 * atr
new_tp2 = close + 3.5 * atr
// Pozisyon açma
if new_buy
in_position := true
entry_price := close
stop_loss := new_sl
take_profit_1 := new_tp1
take_profit_2 := new_tp2
label.new(bar_index, low, "BUY", style=label.style_label_up, color=color.green, textcolor=color.white)
sl_hit = in_position and low <= stop_loss
tp1_hit = in_position and high >= take_profit_1
tp2_hit = in_position and high >= take_profit_2
// Pozisyon kapama sinyali
if sl_hit
in_position := false
//label.new(bar_index, low, "SL", style=label.style_label_down, color=color.red, textcolor=color.white)
if tp2_hit
in_position := false
//label.new(bar_index, high, "TP2", style=label.style_label_down, color=color.rgb(209, 34, 222), textcolor=color.white)
else if tp1_hit
in_position := false
//label.new(bar_index, high, "TP1", style=label.style_label_down, color=color.rgb(209, 34, 222), textcolor=color.white)
// === PLOT ===
// Sadece BUY, SL ve TP seviyeleri çizilir
plot(in_position ? stop_loss : na, title="Stop Loss", color=color.red, style=plot.style_linebr)
//plot(in_position ? take_profit_1 : na, title="TP1", color=color.rgb(209, 34, 222), style=plot.style_linebr)
//plot(in_position ? take_profit_2 : na, title="TP2", color=color.rgb(209, 34, 222), style=plot.style_linebr)
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.