Untitled

 avatar
unknown
plain_text
a month ago
5.2 kB
5
Indexable
//@version=5
indicator("RSN_Kule", overlay = true, max_lines_count = 40)

// INPUTS
length = input.int(28, "Trend")
atr_length = input.int(200, "ATR")  // ATR için parametre

// VARİABLER
var bool trend = na
float trend_value = na

// Colors
color up_color = #06b690
color dn_color = #b60606

// ATR for calculating stop loss and target levels
series float atr_value = ta.sma(ta.atr(atr_length), atr_length) * 0.8  // ATR hesaplamasında atr_length kullanıldı

// Moving averages for trend detection
series float sma_high = ta.sma(high, length) + atr_value
series float sma_low = ta.sma(low, length) - atr_value
color plot_color = color.new(chart.fg_color, 80)

// UDT for managing lines and labels
type TrendTargets
    line[] lines
    label[] labels

// Initialize UDT
var TrendTargets targets_up = TrendTargets.new(array.new_line(), array.new_label())
var TrendTargets targets_down = TrendTargets.new(array.new_line(), array.new_label())

// CÁLCULOS
// Determine trend based on crossovers
if ta.crossover(close, sma_high) and barstate.isconfirmed
    trend := true
if ta.crossunder(close, sma_low) and barstate.isconfirmed
    trend := false

trend_value := switch
    trend => sma_low
    not trend => sma_high

trend_color = trend ? up_color : not trend ? dn_color : na

// Plot candlesticks with trend color
// plotcandle(open, high, low, close,
//            title = 'Title', 
//            color = trend_color,
//            wickcolor = trend_color, 
//            bordercolor = trend_color)

// Plot trailing stops
p1 = plot(trend ? trend_value : na, style = plot.style_linebr, color = plot_color)
p2 = plot(not trend ? trend_value : na, style = plot.style_linebr, color = plot_color)
p0 = plot(hl2, display = display.none, editable = false)

// EMA 8 altındaysa mum rengini kırmızı yap
bar_color_condition = close < ema_8
bar_color = bar_color_condition ? color.red : na

// EMA 8 için parametreler
emaFast_tf = input.timeframe("1W", "EMA 10 Timeframe", inline="ema10")
emaFastLength = input.int(10, "Periyot", inline="ema10")
ema8Color = input.color(#20b725, "Renk", inline="ema10")

// EMA 14 için parametreler
emaSlow_tf = input.timeframe("1W", "EMA 14 Timeframe", inline="ema14")
emaSlowLength = input.int(14, "Periyot", inline="ema14")
ema14Color = input.color(color.orange, "Renk", inline="ema14")

// Günlük EMA 34 için parametreler
emaDaily_tf = input.timeframe("1D", "EMA 34 Timeframe", inline="ema34")
emaDailyLength = input.int(34, "Periyot", inline="ema34")
ema34Color = input.color(#f32121, "Renk", inline="ema34")

// Günlük EMA 610 için parametreler
emaH5_tf = input.timeframe("1W", "EMA 8 Timeframe", inline="Ema8")
emaH5Length = input.int(8, "Periyot", inline="Ema8")
emaH5Color = input.color(color.rgb(10, 243, 255), "Renk", inline="Ema8")

// Günlük EMA 610 için parametreler
ema5144dak_tf = input.timeframe("5", "EMA 610 Timeframe", inline="Ema144")
ema5144dakLength = input.int(610, "Periyot", inline="Ema144")
ema5144Color = input.color(color.rgb(255, 255, 255), "Renk", inline="Ema144")

// Kijun için parametreler
kijun_tf = input.timeframe("1W", "Kijun Timeframe", inline="kijun")
kijunPeriod = input.int(21, "Periyot", inline="kijun")
kijunColor = input.color(#9b27b084, "Renk", inline="kijun", display=display.none)

ghostColor = input.color(color.green, "Ghost Çizgi Rengi", display=display.none)

// EMA hesaplamaları
ema_8 = request.security(syminfo.tickerid, emaFast_tf, ta.ema(close, emaFastLength), barmerge.gaps_off)
ema_14 = request.security(syminfo.tickerid, emaSlow_tf, ta.ema(close, emaSlowLength), barmerge.gaps_off)
ema_34 = request.security(syminfo.tickerid, emaDaily_tf, ta.ema(close, emaDailyLength), barmerge.gaps_off)
ema_5 = request.security(syminfo.tickerid, emaH5_tf, ta.ema(close, emaH5Length), barmerge.gaps_off)
ema_144 = request.security(syminfo.tickerid, ema5144dak_tf, ta.ema(close, ema5144dakLength), barmerge.gaps_off)

// Kijun hesaplaması
kijun = request.security(syminfo.tickerid, kijun_tf, math.avg(ta.lowest(low, kijunPeriod), ta.highest(high, kijunPeriod)), barmerge.gaps_off)

// EMA Ghost hesaplaması
emaGhost = ema_8 * 1.10

// Çizgilerin çizilmesi
plot(ema_8, "EMA H_10", color=ema8Color, linewidth=2)
plot(ema_14, "EMA H_14", color=ema14Color, linewidth=2)
plot(ema_34, "EMA G_34", color=ema34Color, linewidth=2)
plot(ema_5, "EMA H_8", color=emaH5Color, linewidth=2)
plot(ema_144, "EMA 5D_610", color=ema5144Color, linewidth=2)
plot(kijun, "Kijun", color=kijunColor, linewidth=2)
plot(emaGhost, "EMA Ghost", color=ghostColor, linewidth=2, style=plot.style_circles, display=display.none)

// Plot candlesticks with trend color
plotcandle(open, high, low, close,
           title = 'Title', 
           color = bar_color_condition ? color.red : trend_color, // EMA 8 altındaysa kırmızı, aksi takdirde trend renginde
           wickcolor = bar_color_condition ? color.red : trend_color, // Aynı şekilde fitil rengini de ayarlıyoruz
           bordercolor = bar_color_condition ? color.red : trend_color) // Aynı şekilde mumun kenar rengini ayarlıyoruz
Editor is loading...
Leave a Comment