Untitled
//@version=6 indicator('RSN_KALE', overlay = true, max_labels_count = 500, max_boxes_count = 500) // INPUTS // Kısa ve uzun EMA'lar için farklı hareketli ortalama türlerini seçme imkanı short_ma_type = input.string("EMA", title="Kısa MA", options=["Kalman", "EMA", "SMA", "WMA", "RMA", "EMA2", "RMA2"], inline="KISA_Ema", group='HAREKETLİ ORTALAMA') long_ma_type = input.string("EMA", title="Uzun MA", options=["Kalman", "EMA", "SMA", "WMA", "RMA", "EMA2", "RMA2"], inline="UZUN_Ema", group='HAREKETLİ ORTALAMA') // Kısa ve uzun hareketli ortalama length parametreleri int KISA_Ema = input.int(12, title="Kısa MA", inline="KISA_Ema", group='HAREKETLİ ORTALAMA') int UZUN_Ema = input.int(26, title="Uzun MA", inline="UZUN_Ema", group='HAREKETLİ ORTALAMA') bool retest_sig = true bool candle_color = input.bool(true, 'BAR COLOR', inline = 'colors') color upper_col = input.color(#13bd6e, 'up', inline = 'colors') color lower_col = input.color(#b1232f, 'dn', inline = 'colors') // ATR Calculation float atr = ta.atr(55) * 0.5 var lower_box = box(na) var upper_box = box(na) // Kalman filter function kalman_filter(src, length, R = 0.01, Q = 0.1) => var float estimate = na var float error_est = 1.0 var float error_meas = R * length var float kalman_gain = 0.0 var float prediction = na if na(estimate) estimate := src prediction := estimate kalman_gain := error_est / (error_est + error_meas) estimate := prediction + kalman_gain * (src - prediction) error_est := (1 - kalman_gain) * error_est + Q / length estimate // EMA2 Function ema2(src, length) => alpha = 2 / (length + 1) var float result = na result := na(result[1]) ? src : alpha * src + (1 - alpha) * result[1] result // RMA2 Function rma2(src, length) => alpha = 1 / length var float result = na result := na(result[1]) ? src : alpha * src + (1 - alpha) * result[1] result // Calculate the selected moving average for both short and long float short_ma = na float long_ma = na // Kısa dönem hareketli ortalama hesaplaması if short_ma_type == "Kalman" short_ma := kalman_filter(close, KISA_Ema) else if short_ma_type == "EMA" short_ma := ta.ema(close, KISA_Ema) else if short_ma_type == "SMA" short_ma := ta.sma(close, KISA_Ema) else if short_ma_type == "WMA" short_ma := ta.wma(close, KISA_Ema) else if short_ma_type == "RMA" short_ma := ta.rma(close, KISA_Ema) else if short_ma_type == "EMA2" short_ma := ema2(close, KISA_Ema) else if short_ma_type == "RMA2" short_ma := rma2(close, KISA_Ema) // Uzun dönem hareketli ortalama hesaplaması if long_ma_type == "Kalman" long_ma := kalman_filter(close, UZUN_Ema) else if long_ma_type == "EMA" long_ma := ta.ema(close, UZUN_Ema) else if long_ma_type == "SMA" long_ma := ta.sma(close, UZUN_Ema) else if long_ma_type == "WMA" long_ma := ta.wma(close, UZUN_Ema) else if long_ma_type == "RMA" long_ma := ta.rma(close, UZUN_Ema) else if long_ma_type == "EMA2" long_ma := ema2(close, UZUN_Ema) else if long_ma_type == "RMA2" long_ma := rma2(close, UZUN_Ema) // Trend Detection Logic bool trend_up = short_ma > long_ma color trend_col = trend_up ? upper_col : lower_col color trend_col1 = short_ma > short_ma[2] ? upper_col : lower_col color candle_col = candle_color ? trend_up and short_ma > short_ma[2] ? upper_col : not trend_up and short_ma < short_ma[2] ? lower_col : color.rgb(255, 255, 255, 26) : na // PLOTTING if trend_up and not trend_up[1] label.new(bar_index, short_ma, '\n' + str.tostring(math.round(close, 1)), color = color(na), textcolor = upper_col, style = label.style_label_up, size = size.normal) lower_box := box.new(bar_index, low + atr, bar_index, low, border_color = na, bgcolor = color.new(color.green, 80)) lower_box if not ta.change(trend_up) lower_box.set_right(bar_index) if trend_up[1] and not trend_up label.new(bar_index, short_ma, str.tostring(math.round(close, 1)) + '\n', color = color(na), textcolor = lower_col, style = label.style_label_down, size = size.normal) upper_box := box.new(bar_index, high, bar_index, high - atr, border_color = na, bgcolor = color.new(color.red, 80)) upper_box if not ta.change(trend_up) upper_box.set_right(bar_index) if retest_sig if high < upper_box.get_bottom() and high[1] >= upper_box.get_bottom() label.new(bar_index - 1, high[1], '', color = color(na), textcolor = lower_col, style = label.style_label_down, size = size.normal) if low > lower_box.get_top() and low[1] <= lower_box.get_top() label.new(bar_index - 1, low[1], '', color = color(na), textcolor = upper_col, style = label.style_label_up, size = size.normal) // Plot short and long moving averages p1 = plot(short_ma, 'Kısa MA', color = trend_col1, display = display.none) p2 = plot(long_ma, 'Uzun MA', linewidth = 2, color = trend_col, display = display.none) // Plotting candles plotcandle(open, high, low, close, title = 'RSN_KALE', color = candle_col, wickcolor = candle_col, bordercolor = candle_col) // // Fisher Transform // len = input.int(10, minval=1, title='Length') // higherTimeframe = input.timeframe("W", title="Higher Timeframe") // Default higher timeframe set to 1 week // // Retrieve data from the higher timeframe // high_ = request.security(syminfo.tickerid, higherTimeframe, ta.highest(hl2, len)) // low_ = request.security(syminfo.tickerid, higherTimeframe, ta.lowest(hl2, len)) // round_(val) => // val > .99 ? .999 : val < -.99 ? -.999 : val // value = 0.0 // value := round_(.66 * ((hl2 - low_) / (high_ - low_) - .5) + .67 * nz(value[1])) // fish1 = 0.0 // fish1 := .5 * math.log((1 + value) / (1 - value)) + .5 * nz(fish1[1]) // fish2 = fish1[1] // fishfup = ta.crossover(fish1, fish2) // fishdw = ta.crossunder(fish1, fish2) // // Buy and Sell Conditions // buySignal = ta.crossover(fish1, fish2) // Fisher crosses above trigger (buy signal) // sellSignal = ta.crossunder(fish1, fish2) // Fisher crosses below trigger (sell signal) // // // Plot Buy and Sell Labels // if (buySignal) // label.new(bar_index, low, "Fish_Al", color=#09daff2d, style=label.style_label_up, textcolor=color.white, size=size.small) // if (sellSignal) // label.new(bar_index, high, "Fish_Sat", color=color.rgb(7, 54, 241, 80), style=label.style_label_down, textcolor=color.white, size=size.small) // Comparative Relative Strength calculations comparativeTickerId = input.symbol('BIST:XU100', title = 'KOM SYMBOL', inline="group3", group='Komp - RSI Settings') src1 = close baseSymbol = request.security(syminfo.tickerid, timeframe.period, src1) comparativeSymbol = request.security(comparativeTickerId, timeframe.period, src1) crs = baseSymbol / comparativeSymbol rsiLength = input.int(14, minval = 1, title = 'RSI', inline="group3", group='Komp - RSI Settings') higherRSI = ta.rsi(crs, rsiLength) // MACD ayarları fastLength = input.int(12, title='Fast', inline="group1", group='Macd Settings') slowLength = input.int(26, title='Slow', inline="group1", group='Macd Settings') signalSmoothing = input.int(9, title='Signal', inline="group1", group='Macd Settings') [macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalSmoothing) buySignalm = ta.crossover(macdLine, 0) sellSignalm = ta.crossunder(macdLine, 0) macdsart = macdLine > 0 kalmanf = short_ma > long_ma buySignal34 = ta.crossover(macdLine, signalLine) and macdsart and kalmanf sellSignal34 = ta.crossunder(macdLine, signalLine) and macdsart and kalmanf // Çizim koşulları plotshape(buySignal34, location=location.belowbar, style=shape.arrowup, title='TEKRAR AL', text='TEKRAR AL', textcolor=#eac809, size=size.normal, offset=0) plotshape(sellSignal34, location=location.abovebar, style=shape.arrowdown, title='KAR AL', text='KAR AL', textcolor=#00ffbf, size=size.normal, offset=0) // plotshape(buySignal, location=location.belowbar, color=color.green, style=shape.diamond, title='Macd AL', text='M_AL', size=size.small, offset=0, display = display.none) // plotshape(sellSignal, location=location.abovebar, color=color.red, style=shape.diamond, title='Macd Sat', text='M_SAT', size=size.small, offset=0, display = display.none) // Add enable/disable settings for comparative EMAs show_comp_ema34 = input.bool(false, "KOMP EMA 34", group="Comparative EMA Display") show_comp_ema55 = input.bool(false, "KOMP EMA 55", group="Comparative EMA Display") show_comp_ema89 = input.bool(false, "KOMP EMA 89", group="Comparative EMA Display") show_comp_ema233 = input.bool(false, "KOMP EMA 233", group="Comparative EMA Display") show_comp_ema377 = input.bool(false, "KOMP EMA 377", group="Comparative EMA Display") show_comp_ema610 = input.bool(false, "KOMP EMA 610", group="Comparative EMA Display") show_comp_ema987 = input.bool(false, "KOMP EMA 987", group="Comparative EMA Display") show_comp_ema1597 = input.bool(false, "KOMP EMA 1597", group="Comparative EMA Display") show_comp_ema2584 = input.bool(false, "KOMP EMA 2584", group="Comparative EMA Display") show_comp_ema4181 = input.bool(false, "KOMP EMA 4181", group="Comparative EMA Display") showema55_1s = input.bool(true, "EMA 55 1s", group="EMA Values") // Add text size control for comparative EMA labels comp_ema_text_size = input.string("normal", "KOMP EMA Label Size", options=["tiny", "small", "normal", "large"], group="Comparative EMA Display") // Convert text size input to size constant get_text_size() => switch comp_ema_text_size "tiny" => size.tiny "small" => size.small "large" => size.large => size.normal // EMA Length inputs (unchanged) emaLength1 = input.int(12, title = ' EMA 12', group="EMA Values") emaLength2 = input.int(26, title = ' EMA 26', group="EMA Values") emaLength12 = input.int(14, title = ' EMA 14', group="EMA Values") emaLength3 = input.int(34, title = ' EMA 34', group="EMA Values") emaLength4 = input.int(55, title = ' EMA 55', group="EMA Values") emaLength10 = input.int(89, title = ' EMA 89', group="EMA Values") emaLength5 = input.int(144, title = ' EMA 144', group="EMA Values") emaLength6 = input.int(233, title = ' EMA 233', group="EMA Values") emaLength7 = input.int(377, title = ' EMA 377', group="EMA Values") emaLength8 = input.int(610, title = ' EMA 610', group="EMA Values") emaLength9 = input.int(987, title = ' EMA 987', group="EMA Values") emaLength11 = input.int(1597, title = ' EMA 1597', group="EMA Values") emaLength13 = input.int(115, title = ' PIVOT 115', group="EMA Values") // Calculate Regular EMAs ema12 = ta.ema(close, emaLength1) ema26 = ta.ema(close, emaLength2) ema14 = ta.ema(close, emaLength12) ema34 = ta.ema(close, emaLength3) ema55 = ta.ema(close, emaLength4) ema89 = ta.ema(close, emaLength10) ema144 = ta.ema(close, emaLength5) ema233 = ta.ema(close, emaLength6) ema377 = ta.ema(close, emaLength7) ema610 = ta.ema(close, emaLength8) ema987 = ta.ema(close, emaLength9) ema1597 = ta.ema(close, emaLength11) ema115 = ta.ema(close, emaLength13) // Plot Regular EMAs wiith conditional plotting plot(ema12, title = 'EMA 12', color = #368c3c, linewidth = 2, display = display.none) plot(ema26, title = 'EMA 26', color = #e4cb0c, linewidth = 2, display = display.none) plot(ema14, title = 'EMA 14', color = color.rgb(0, 255, 17), linewidth = 2, display = display.none) plot(ema34, title = 'EMA 34', color = color.rgb(253, 0, 0), linewidth = 2) plot(ema55, title = 'EMA 55', color = #f8a407, linewidth = 2) plot(ema89, title = 'EMA 89', color = color.rgb(207, 193, 166), linewidth = 2, display = display.none) plot(ema144, title = 'EMA 144', color = color.rgb(184, 25, 232), linewidth = 2, display = display.none) plot(ema233, title = 'EMA 233', color = color.rgb(0, 203, 254), linewidth = 2, display = display.none) plot(ema377, title = 'EMA 377', color = color.rgb(7, 89, 240), linewidth = 2, display = display.none) plot(ema610, title = 'EMA 610', color = color.rgb(124, 128, 131), linewidth = 2, display = display.none) plot(ema987, title = 'EMA 987', color = #fc009b, linewidth = 2, display = display.none) plot(ema1597, title = 'EMA 1597', color = color.rgb(145, 18, 18), linewidth = 2, display = display.none) plot(ema115, title = 'Pivot 115', color = #ea754b, linewidth = 2, display = display.none) up = ta.rma(math.max(ta.change(src1), 0), rsiLength) down = ta.rma(-math.min(ta.change(src1), 0), rsiLength) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down) // MACD settings higherrsi_CrossUp = ta.crossover(macdLine, 0) // MACD yukarı kesiş higherrsi_Crossdown = ta.crossunder(macdLine, 0) // MACD aşağı kesiş higherrsi_0 = ta.crossunder(rsi, 30) // MACD aşağı kesiş higherrsi_01 = ta.crossover(rsi, 30) // MACD aşağı kesiş emaCrossUp = ta.crossover(ema34, ema55) // EMA34 yukarı kesiş emaCrossDown = ta.crossunder(ema34, ema55) // EMA34 aşağı kesiş // Al ve Sat koşulları buySignal2 = ta.crossover(macdLine, 0) // MACD pozitif oldu sellSignal2 = ta.crossunder(macdLine, 0) // MACD negatif oldu // // Kullanıcı tarafından seçilebilir zaman dilimi parametresi timeframe_input = input.timeframe("60", title="EMA 55 1s", confirm=true) // EMA 55 hesaplama (seçilen zaman dilimine göre) ema55_1s = request.security(syminfo.tickerid, timeframe_input, ta.ema(close, 55)) // Çizgi ve etiket için değişkenler line_color = #10f751 // Çizgi için kullanılan renk var line ema_line = na // Çizgi değişkeni var label ema_label = na // Etiket değişkeni if bar_index > 6 // EMA 55_1s if showema55_1s if na(ema_line) ema_line := line.new(x1=bar_index, y1=ema55_1s, x2=bar_index + 4, y2=ema55_1s, color=line_color, width=2) else line.set_xy1(ema_line, bar_index, ema55_1s) line.set_xy2(ema_line, bar_index + 4, ema55_1s) label_text = "Ema-55_1s: " + str.tostring(ema55_1s, '#.##') if na(ema_label) ema_label := label.new(x=bar_index + 4, y=ema55_1s, text=label_text, style=label.style_label_left, color=color.new(color.white, 100), textcolor=line_color, size=size.normal) else label.set_x(ema_label, bar_index + 4) label.set_y(ema_label, ema55_1s) label.set_text(ema_label, label_text) label.set_textcolor(ema_label, line_color) label.set_size(ema_label, get_text_size()) else if not na(ema_line) line.delete(ema_line) ema_line := na if not na(ema_label) label.delete(ema_label) ema_label := na // XU100 fiyatı ve EMA uzunlukları xu100 = request.security('BIST:XU100', timeframe.period, close) compEmaLength34 = input.int(34, title='KOM EMA 34', group="Kompozit EMA Values") compEmaLength55 = input.int(55, title='KOM EMA 55', group="Kompozit EMA Values") compEmaLength89 = input.int(89, title='KOM EMA 89', group="Kompozit EMA Values") compEmaLength233 = input.int(233, title='KOM EMA 233', group="Kompozit EMA Values") compEmaLength377 = input.int(377, title='KOM EMA 377', group="Kompozit EMA Values") compEmaLength610 = input.int(610, title='KOM EMA 610', group="Kompozit EMA Values") compEmaLength987 = input.int(987, title='KOM EMA 987', group="Kompozit EMA Values") compEmaLength1597 = input.int(1597, title='KOM EMA 1597', group="Kompozit EMA Values") compEmaLength2584 = input.int(2584, title='KOM EMA 2584', group="Kompozit EMA Values") compEmaLength4181 = input.int(4181, title='KOM EMA 4181', group="Kompozit EMA Values") // Mevcut varlığın fiyatı ile XU100 arasındaki oran üzerinden EMA hesaplama comp_ema34 = ta.ema(close / xu100, compEmaLength34) comp_ema55 = ta.ema(close / xu100, compEmaLength55) comp_ema89 = ta.ema(close / xu100, compEmaLength89) comp_ema233 = ta.ema(close / xu100, compEmaLength233) comp_ema377 = ta.ema(close / xu100, compEmaLength377) comp_ema610 = ta.ema(close / xu100, compEmaLength610) comp_ema987 = ta.ema(close / xu100, compEmaLength987) comp_ema1597 = ta.ema(close / xu100, compEmaLength1597) comp_ema2584 = ta.ema(close / xu100, compEmaLength2584) comp_ema4181 = ta.ema(close / xu100, compEmaLength4181) // Çizgi ve etiketler için değişkenler var line ema_line1 = na var label ema_label1 = na var line ema_line2 = na var label ema_label2 = na var line ema_line3 = na var label ema_label3 = na var line ema_line4 = na var label ema_label4 = na var line ema_line5 = na var label ema_label5 = na var line ema_line6 = na var label ema_label6 = na var line ema_line7 = na var label ema_label7 = na var line ema_line8 = na var label ema_label8 = na var line ema_line9 = na var label ema_label9 = na var line ema_line10 = na var label ema_label10 = na // Çizgileri ve etiketleri oluşturma if bar_index > 6 // EMA 34 if na(ema_line1) and show_comp_ema34 ema_line1 := line.new(x1=bar_index, y1=comp_ema34 * xu100, x2=bar_index + 6, y2=comp_ema34 * xu100, color=#ff0303, width=2) ema_label1 := label.new(x=bar_index + 7, y=comp_ema34 * xu100, text=str.tostring(comp_ema34 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=#ff0000, size=size.normal) else if show_comp_ema34 line.set_xy1(ema_line1, bar_index, comp_ema34 * xu100) line.set_xy2(ema_line1, bar_index + 6, comp_ema34 * xu100) label.set_x(ema_label1, bar_index + 6) // Çizginin bitiş noktasına sabitle label.set_y(ema_label1, comp_ema34 * xu100) label.set_text(ema_label1, "KOMP-34: " + str.tostring(comp_ema34 * xu100, '#.##')) label.set_size(ema_label1, get_text_size()) // EMA 55 if na(ema_line2) and show_comp_ema55 ema_line2 := line.new(x1=bar_index, y1=comp_ema55 * xu100, x2=bar_index + 6, y2=comp_ema55 * xu100, color=#dac732, width=2) ema_label2 := label.new(x=bar_index + 7, y=comp_ema55 * xu100, text=str.tostring(comp_ema55 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=#dac732, size=size.normal) else if show_comp_ema55 line.set_xy1(ema_line2, bar_index, comp_ema55 * xu100) line.set_xy2(ema_line2, bar_index + 6, comp_ema55 * xu100) label.set_x(ema_label2, bar_index + 6) label.set_y(ema_label2, comp_ema55 * xu100) label.set_text(ema_label2, "KOMP-55: " + str.tostring(comp_ema55 * xu100, '#.##')) label.set_size(ema_label2, get_text_size()) // EMA 89 if na(ema_line6) and show_comp_ema89 ema_line6 := line.new(x1=bar_index, y1=comp_ema89 * xu100, x2=bar_index + 6, y2=comp_ema89 * xu100, color=#d47210, width=2) ema_label6 := label.new(x=bar_index + 7, y=comp_ema89 * xu100, text=str.tostring(comp_ema89 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=#d47210, size=size.normal) else if show_comp_ema89 line.set_xy1(ema_line6, bar_index, comp_ema89 * xu100) line.set_xy2(ema_line6, bar_index + 6, comp_ema89 * xu100) label.set_x(ema_label6, bar_index + 6) label.set_y(ema_label6, comp_ema89 * xu100) label.set_text(ema_label6, "KOMP-89: " + str.tostring(comp_ema89 * xu100, '#.##')) label.set_size(ema_label6, get_text_size()) // EMA 233 if na(ema_line3) and show_comp_ema233 ema_line3 := line.new(x1=bar_index, y1=comp_ema233 * xu100, x2=bar_index + 6, y2=comp_ema233 * xu100, color=color.rgb(217, 3, 255), width=2) ema_label3 := label.new(x=bar_index + 7, y=comp_ema233 * xu100, text=str.tostring(comp_ema233 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color.rgb(217, 3, 255), size=size.normal) else if show_comp_ema233 line.set_xy1(ema_line3, bar_index, comp_ema233 * xu100) line.set_xy2(ema_line3, bar_index + 6, comp_ema233 * xu100) label.set_x(ema_label3, bar_index + 6) label.set_y(ema_label3, comp_ema233 * xu100) label.set_text(ema_label3, "KOMP-233: " + str.tostring(comp_ema233 * xu100, '#.##')) label.set_size(ema_label3, get_text_size()) // EMA 377 if na(ema_line4) and show_comp_ema377 ema_line4 := line.new(x1=bar_index, y1=comp_ema377 * xu100, x2=bar_index + 6, y2=comp_ema377 * xu100, color=color.rgb(25, 79, 167), width=2) ema_label4 := label.new(x=bar_index + 7, y=comp_ema377 * xu100, text=str.tostring(comp_ema377 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color.rgb(25, 79, 167), size=size.normal) else if show_comp_ema377 line.set_xy1(ema_line4, bar_index, comp_ema377 * xu100) line.set_xy2(ema_line4, bar_index + 6, comp_ema377 * xu100) label.set_x(ema_label4, bar_index + 6) label.set_y(ema_label4, comp_ema377 * xu100) label.set_text(ema_label4, "KOMP-377: " + str.tostring(comp_ema377 * xu100, '#.##')) label.set_size(ema_label4, get_text_size()) // EMA 610 if na(ema_line5) and show_comp_ema610 ema_line5 := line.new(x1=bar_index, y1=comp_ema610 * xu100, x2=bar_index + 6, y2=comp_ema610 * xu100, color=color.rgb(106, 98, 98), width=2) ema_label5 := label.new(x=bar_index + 7, y=comp_ema610 * xu100, text=str.tostring(comp_ema610 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color.rgb(135, 128, 128), size=size.normal) else if show_comp_ema610 line.set_xy1(ema_line5, bar_index, comp_ema610 * xu100) line.set_xy2(ema_line5, bar_index + 6, comp_ema610 * xu100) label.set_x(ema_label5, bar_index + 6) label.set_y(ema_label5, comp_ema610 * xu100) label.set_text(ema_label5, "KOMP-610: " + str.tostring(comp_ema610 * xu100, '#.##')) label.set_size(ema_label5, get_text_size()) // EMA 987 if na(ema_line8) and show_comp_ema987 ema_line8 := line.new(x1=bar_index, y1=comp_ema987 * xu100, x2=bar_index + 6, y2=comp_ema987 * xu100, color=color.rgb(13, 224, 247), width=2) ema_label8 := label.new(x=bar_index + 7, y=comp_ema987 * xu100, text=str.tostring(comp_ema987 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color.rgb(13, 224, 247), size=size.normal) else if show_comp_ema987 line.set_xy1(ema_line8, bar_index, comp_ema987 * xu100) line.set_xy2(ema_line8, bar_index + 6, comp_ema987 * xu100) label.set_x(ema_label8, bar_index + 6) // Çizginin bitiş noktasına sabitle label.set_y(ema_label8, comp_ema987 * xu100) label.set_text(ema_label8, "KOMP-987: " + str.tostring(comp_ema987 * xu100, '#.##')) label.set_size(ema_label8, get_text_size()) // EMA 1597 if na(ema_line7) and show_comp_ema1597 ema_line7 := line.new(x1=bar_index, y1=comp_ema1597 * xu100, x2=bar_index + 6, y2=comp_ema1597 * xu100, color=color.rgb(252, 27, 2), width=2) ema_label7 := label.new(x=bar_index + 7, y=comp_ema1597 * xu100, text="EMA-1597: " + str.tostring(comp_ema1597 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color.rgb(252, 27, 2), size=size.normal) else if show_comp_ema1597 line.set_xy1(ema_line7, bar_index, comp_ema1597 * xu100) line.set_xy2(ema_line7, bar_index + 6, comp_ema1597 * xu100) label.set_x(ema_label7, bar_index + 6) label.set_y(ema_label7, comp_ema1597 * xu100) label.set_text(ema_label7, "KOMP-1597: " + str.tostring(comp_ema1597 * xu100, '#.##')) label.set_size(ema_label7, get_text_size()) // EMA 2584 if na(ema_line9) and show_comp_ema2584 ema_line9 := line.new(x1=bar_index, y1=comp_ema2584 * xu100, x2=bar_index + 6, y2=comp_ema2584 * xu100, color=color.rgb(248, 244, 6), width=2) ema_label9 := label.new(x=bar_index + 7, y=comp_ema2584 * xu100, text=str.tostring(comp_ema2584 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color.rgb(248, 244, 6), size=get_text_size()) else if show_comp_ema2584 line.set_xy1(ema_line9, bar_index, comp_ema2584 * xu100) line.set_xy2(ema_line9, bar_index + 6, comp_ema2584 * xu100) label.set_x(ema_label9, bar_index + 6) label.set_y(ema_label9, comp_ema2584 * xu100) label.set_text(ema_label9, "KOMP-2584: " + str.tostring(comp_ema2584 * xu100, '#.##')) label.set_size(ema_label9, get_text_size()) // EMA 4181 if na(ema_line10) and show_comp_ema4181 ema_line10 := line.new(x1=bar_index, y1=comp_ema4181 * xu100, x2=bar_index + 6, y2=comp_ema4181 * xu100, color=color.rgb(50, 205, 248), width=2) ema_label10 := label.new(x=bar_index + 7, y=comp_ema4181 * xu100, text=str.tostring(comp_ema4181 * xu100, '#.##'), style=label.style_label_left, color=color.new(color.white, 100), textcolor=color.rgb(50, 205, 248), size=size.large) else if show_comp_ema4181 line.set_xy1(ema_line10, bar_index, comp_ema4181 * xu100) line.set_xy2(ema_line10, bar_index + 6, comp_ema4181 * xu100) label.set_x(ema_label10, bar_index + 6) // Çizginin bitiş noktasına sabitle label.set_y(ema_label10, comp_ema4181 * xu100) label.set_text(ema_label10, str.tostring(comp_ema4181 * xu100, '#.##')) // Percentage changes for different timeframes weeklyClose = request.security(syminfo.tickerid, 'D', close[5]) monthlyClose = request.security(syminfo.tickerid, 'D', close[22]) quarterlyClose = request.security(syminfo.tickerid, 'D', close[66]) weeklyChange = (close - weeklyClose) / weeklyClose * 100 monthlyChange = (close - monthlyClose) / monthlyClose * 100 quarterChange = (close - quarterlyClose) / quarterlyClose * 100 highestHigh = ta.highest(high, 2000) distanceFromPeak = (highestHigh - close) / close * 100 getHigherTimeframe() => higherTimeFrame = timeframe.isweekly ? 'M' : timeframe.isdaily ? 'W' : timeframe.isintraday ? 'D' : 'D' higherTimeFrame // Table for displaying percentage changes tablePosition = input.string('bottom_right', title = 'Table Position', options = ['top_right', 'top_left', 'bottom_right', 'bottom_left']) fontSize = input.string('normal', title = 'Font Size', options = ['tiny', 'small', 'normal', 'large']) fontSizeMap = fontSize == 'normal' ? size.normal : fontSize == 'small' ? size.small : fontSize == 'normal' ? size.normal : size.large positionMap = tablePosition == 'bottom_right' ? position.bottom_right : tablePosition == 'top_left' ? position.top_left : tablePosition == 'bottom_right' ? position.bottom_right : position.bottom_left var table tbl = table.new(positionMap, 8, 2, bgcolor = color.new(color.black, 90), border_color = color.new(color.gray, 50), border_width = 1) // Tablo başlıkları if bar_index == 1 table.cell(tbl, 0, 0, syminfo.ticker, text_color = color.orange, text_size = fontSizeMap) table.cell(tbl, 1, 0, 'RSI', text_color = color.orange, text_size = fontSizeMap) table.cell(tbl, 2, 0, 'KOM RSI', text_color = color.orange, text_size = fontSizeMap) table.cell(tbl, 3, 0, 'STOP 34', text_color = color.orange, text_size = fontSizeMap) table.cell(tbl, 4, 0, 'STOP 55', text_color = color.orange, text_size = fontSizeMap) table.cell(tbl, 5, 0, 'Hafta', text_color = color.orange, text_size = fontSizeMap) table.cell(tbl, 6, 0, 'Ay', text_color = color.orange, text_size = fontSizeMap) // table.cell(tbl, 0, 7, '3 Ay', text_color = color.white, text_size = fontSizeMap) table.cell(tbl, 7, 0, 'Dip-Tepe', text_color = color.orange, text_size = fontSizeMap) // EMA 34 değerini tabloya ekleme table.cell(tbl, 0, 1, str.tostring(close, '#.##'), text_color = close >= ema34 ? color.green : color.red, text_size = fontSizeMap) table.cell(tbl, 1, 1, str.tostring(rsi, '#.##'), text_color = rsi >= 50 ? color.green : color.red, text_size = fontSizeMap) table.cell(tbl, 2, 1, str.tostring(higherRSI, '#.##'), text_color = higherRSI >= 50 ? color.green : color.red, text_size = fontSizeMap) table.cell(tbl, 3, 1, str.tostring(ema34, '#.##'), text_color = ema34 >= close ? color.red : color.green, text_size = fontSizeMap) table.cell(tbl, 4, 1, str.tostring(ema55, '#.##'), text_color = ema55 >= close ? color.red : color.green, text_size = fontSizeMap) table.cell(tbl, 5, 1, str.tostring(weeklyChange, '#.##') + '%', text_color = weeklyChange >= 0 ? color.green : color.red, text_size = fontSizeMap) table.cell(tbl, 6, 1, str.tostring(monthlyChange, '#.##') + '%', text_color = monthlyChange >= 0 ? color.green : color.red, text_size = fontSizeMap) // table.cell(tbl, 1, 7, str.tostring(quarterChange, '#.##') + '%', text_color = quarterChange >= 0 ? color.green : color.red, text_size = fontSizeMap) table.cell(tbl, 7, 1, str.tostring(distanceFromPeak, '#.##') + '%', text_color = distanceFromPeak >= 0 ? color.green : color.red, text_size = fontSizeMap) // Alarm ayarları (Enable/Disable) enableEma34Alarm = input.bool(true, title = 'EMA 34 Alarm') enableEma55Alarm = input.bool(true, title = 'EMA 55 Alarm') enablekomp34Alarm = input.bool(true, title = 'KOMP 34 Alarm') enablekomp55Alarm = input.bool(true, title = 'KOMP 55 Alarm') enablekomp89Alarm = input.bool(true, title = 'KOMP 89 Alarm') enablekomp233Alarm = input.bool(true, title = 'KOMP 233 Alarm') // Alarmları etkinleştirme ayarları enableBuyAlarm = input.bool(true, title="TEKRAR AL Alarmını", group="Alarm Ayarları") enableSellAlarm = input.bool(true, title="KAR AL Alarmını", group="Alarm Ayarları") enableTrendAlarm = input.bool(true, title="Trend Alarmını", group="Alarm Ayarları") // EMA 34 Alarm Koşulları ema34CrossUp = ta.crossover(open, ema34) // Fiyat EMA 34'ün üzerine çıkıyor ema34CrossDown = ta.crossunder(open, ema34) // Fiyat EMA 34'ün altına iniyor if enableEma34Alarm if (ema34CrossUp) alert("FİYAT YUKARI KESTİ EMA 34!", alert.freq_once_per_bar) if ema34CrossDown alert('FİYAT AŞAĞI KESTİ EMA 34!', alert.freq_once_per_bar) // EMA 55 Alarm Koşulları ema55CrossUp = ta.crossover(close, ema55) // Fiyat EMA 55'in üzerine çıkıyor ema55CrossDown = ta.crossunder(close, ema55) // Fiyat EMA 55'in altına iniyor if enableEma55Alarm if (ema55CrossUp) alert("FİYAT YUKARI KESTİ EMA 34!", alert.freq_once_per_bar) if ema55CrossDown alert('FİYAT AŞAĞI KESTİ EMA 34!', alert.freq_once_per_bar) komp233CrossUp = ta.crossover(close, comp_ema233) // Fiyat EMA 55'in üzerine çıkıyor komp233CrossDown = ta.crossunder(close, comp_ema233) // Fiyat EMA 55'in altına iniyor if enablekomp233Alarm if (komp233CrossUp) alert("FİYAT YUKARI KESTİ KOMP 233!", alert.freq_once_per_bar) if komp233CrossDown alert('FİYAT AŞAĞI KESTİ KOMP 233!', alert.freq_once_per_bar) komp89CrossUp = ta.crossover(close, comp_ema89) // Fiyat EMA 55'in üzerine çıkıyor komp89CrossDown = ta.crossunder(close, comp_ema89) // Fiyat EMA 55'in altına iniyor if enablekomp89Alarm if (komp89CrossUp) alert("FİYAT YUKARI KESTİ KOMP 89!", alert.freq_once_per_bar) if komp89CrossDown alert('FİYAT AŞAĞI KESTİ KOMP 89!', alert.freq_once_per_bar) komp34CrossUp = ta.crossover(close, comp_ema34) // Fiyat EMA 55'in üzerine çıkıyor komp34CrossDown = ta.crossunder(close, comp_ema34) // Fiyat EMA 55'in altına iniyor if enablekomp34Alarm if (komp34CrossUp) alert("FİYAT YUKARI KESTİ KOMP 34!", alert.freq_once_per_bar) if komp89CrossDown alert('FİYAT AŞAĞI KESTİ KOMP 34!', alert.freq_once_per_bar) komp55CrossUp = ta.crossover(close, comp_ema55) // Fiyat EMA 55'in üzerine çıkıyor komp55CrossDown = ta.crossunder(close, comp_ema55) // Fiyat EMA 55'in altına iniyor if enablekomp55Alarm if (komp55CrossUp) alert("FİYAT YUKARI KESTİ KOMP 55!", alert.freq_once_per_bar) if komp89CrossDown alert('FİYAT AŞAĞI KESTİ KOMP 55!', alert.freq_once_per_bar) // Alarm Koşulları if enableBuyAlarm and buySignal34 alert('TEKRAR AL sinyali oluştu!', alert.freq_once_per_bar) if enableSellAlarm and sellSignal34 alert('KAR AL sinyali oluştu!', alert.freq_once_per_bar) // Trend Alarmı Koşulları if enableTrendAlarm and buySignal34 alert('Trend Alarm: BUY SIGNAL tespit edildi!', alert.freq_once_per_bar) if enableTrendAlarm and sellSignal34 alert('Trend Alarm: SELL SIGNAL tespit edildi!', alert.freq_once_per_bar) // emaFast_tf = input.string("1W", "EMA 8 Timeframe", options=["", "1", "3", "5", "15", "30", "45", "60", "120", "180", "240", "1D", "1W", "1M"], inline="ema8") emaFast_tf = input.timeframe("1W", "EMA 8 Timeframe", inline="ema8") emaFastLength = input.int(8, "Periyot", inline="ema8") ema8Color = input.color(color.green, "Renk", inline="ema8") // emaSlow_tf = input.string("1W", "EMA 14 Timeframe", options=["", "1", "3", "5", "15", "30", "45", "60", "120", "180", "240", "1D", "1W", "1M"], inline="ema14") 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") // kijun_tf = input.string("1W", "Kijun Timeframe", options=["", "1", "3", "5", "15", "30", "45", "60", "120", "180", "240", "1D", "1W", "1M"], inline="kijun") kijun_tf = input.timeframe("1W", "Kijun Timeframe", inline="kijun") kijunPeriod = input.int(26, "Periyot", inline="kijun") kijunColor = input.color(color.purple, "Renk", inline="kijun", display = display.none) ghostColor = input.color(color.green, "Ghost Çizgi Rengi", display = display.none) // Zaman dilimi fonksiyonu // getTimeFrame(timeFrame) => // timeFrame == "" ? timeframe.period : timeFrame // 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) // 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.14 // Çizgilerin çizilmesi plot(ema_8, "EMA 8", color=ema8Color, linewidth=2, display = display.none) plot(ema_14, "EMA 14", color=ema14Color, linewidth=2, display = display.none) plot(kijun, "Kijun", color=kijunColor, linewidth=2, display = display.none) plot(emaGhost, "EMA Ghost", color=ghostColor, linewidth=2, style=plot.style_circles, display = display.none) // Color variables upColor = color.white midColor = color.rgb(104, 118, 136) downColor = #ec17f7 // Source src = input(defval = close, title = 'Source') // Sampling Period // Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters per = input.int(defval = 100, minval = 1, title = 'Sampling Period') // Range Multiplier mult = input.float(defval = 5.0, minval = 0.1, title = 'Range Multiplier') // Smooth Average Range smoothrng(x, t, m) => wper = t * 2 - 1 avrng = ta.ema(math.abs(x - x[1]), t) smoothrng = ta.ema(avrng, wper) * m smoothrng smrng = smoothrng(src, per, mult) // Range Filter rngfilt(x, r) => rngfilt = x rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r rngfilt filt = rngfilt(src, smrng) // Filter Direction upward = 0.0 upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1]) downward = 0.0 downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1]) // Target Bands hband = filt + smrng lband = filt - smrng // Colors filtcolor = upward > 0 ? upColor : downward > 0 ? downColor : midColor barcolor = src > filt and src > src[1] and upward > 0 ? upColor : src > filt and src < src[1] and upward > 0 ? upColor : src < filt and src < src[1] and downward > 0 ? downColor : src < filt and src > src[1] and downward > 0 ? downColor : midColor filtplot = plot(filt, color = filtcolor, linewidth = 2, title = 'Range Filter', display = display.none) // // Target // hbandplot = plot(hband, color = color.new(upColor, 70), title = 'High Target') // lbandplot = plot(lband, color = color.new(downColor, 70), title = 'Low Target') // Fills // fill(hbandplot, filtplot, color = color.new(upColor, 90), title = 'High Target Range') // fill(lbandplot, filtplot, color = color.new(downColor, 90), title = 'Low Target Range') // // Bar Color // barcolor(barcolor) // Break Outs longCond = bool(na) shortCond = bool(na) longCond := src > filt and src > src[1] and upward > 0 or src > filt and src < src[1] and upward > 0 shortCond := src < filt and src < src[1] and downward > 0 or src < filt and src > src[1] and downward > 0 CondIni = 0 CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1] longCondition = longCond and CondIni[1] == -1 shortCondition = shortCond and CondIni[1] == 1 // //Alerts // plotshape(longCondition, title = 'Buy Signal', text = 'Buy', textcolor = color.white, style = shape.labelup, size = size.small, location = location.belowbar, color = color.new(#aaaaaa, 20)) // plotshape(shortCondition, title = 'Sell Signal', text = 'Sell', textcolor = color.white, style = shape.labeldown, size = size.small, location = location.abovebar, color = color.new(downColor, 20)) alertcondition(longCondition, title = 'Buy alert on Range Filter', message = 'Buy alert on Range Filter') alertcondition(shortCondition, title = 'Sell alert on Range Filter', message = 'Sell alert on Range Filter') alertcondition(longCondition or shortCondition, title = 'Buy and Sell alert on Range Filter', message = 'Buy and Sell alert on Range Filter') // For use as a Strategy // ___________________________________________________________________________________________________________ // 1. Replace the word "indicator" on line 2 with the word "strategy" // 2. Uncomment the code below by highlighting it and pressing Ctl + '/' // Settings for 5min BTCUSDT. For other timeframes and assets, adjust the parameters within the settings menu. // ___________________________________________________________________________________________________________ // grp_STRAT = "Strategy settings" // timeInput = input.time(timestamp("1 Nov 2022 00:00 +0000"), title="Start date", group=grp_STRAT) // tpInPips = input.int(400, title="TP (in pips)", group=grp_STRAT) // slInPips = input.int(100, title="SL (in pips)", group=grp_STRAT) // timePeriod = time >= timeInput // notInTrade = strategy.position_size <= 0 // if(longCondition and timePeriod and notInTrade) // strategy.entry("Long", strategy.long) // strategy.exit("Exit long", "Long", loss=slInPips, profit=tpInPips) // if(shortCondition and timePeriod and notInTrade) // strategy.entry("Short", strategy.short) // strategy.exit("Exit short", "Short", loss=slInPips, profit=tpInPips)
Leave a Comment