Untitled
//@version=5 indicator("Multi-Timeframe SMA/EMA", overlay=true) // Zaman dilimleri için input parametreleri // timeframe string'lerini ayrı ayrı tanımlıyoruz t1 = "5" t2 = "15" t3 = "30" t4 = "60" t5 = "240" t6 = "D" // SMA ve EMA periyotları için input sma_length_1 = input.int(5, "SMA 1 Period", minval=1) sma_length_2 = input.int(20, "SMA 2 Period", minval=1) ema_length_1 = input.int(5, "EMA 1 Period", minval=1) ema_length_2 = input.int(20, "EMA 2 Period", minval=1) // Göstergelerin renklerini özelleştirme sma5_color = input.color(color.blue, "SMA 5 Color") sma20_color = input.color(color.red, "SMA 20 Color") ema5_color = input.color(color.green, "EMA 5 Color") ema20_color = input.color(color.purple, "EMA 20 Color") // Her zaman dilimi için göstergeleri hesaplama f_get_security(_symbol, _res, _src) => request.security(_symbol, _res, _src) // Ana zaman dilimindeki göstergeler sma5 = ta.sma(close, sma_length_1) sma20 = ta.sma(close, sma_length_2) ema5 = ta.ema(close, ema_length_1) ema20 = ta.ema(close, ema_length_2) // Göstergeleri çizme plot(sma5, "SMA 5", color=sma5_color, linewidth=2) plot(sma20, "SMA 20", color=sma20_color, linewidth=2) plot(ema5, "EMA 5", color=ema5_color, linewidth=2) plot(ema20, "EMA 20", color=ema20_color, linewidth=2) // Tablo oluşturma var table indicators = table.new(position.top_right, 7, 6, border_width=1) // Tablo başlıklarını güncelleme if barstate.islast table.cell(indicators, 0, 0, "Timeframe", bgcolor=color.gray, text_color=color.white) table.cell(indicators, 0, 1, "Price", bgcolor=color.gray, text_color=color.white) table.cell(indicators, 0, 2, "SMA 5", bgcolor=color.gray, text_color=color.white) table.cell(indicators, 0, 3, "SMA 20", bgcolor=color.gray, text_color=color.white) table.cell(indicators, 0, 4, "EMA 5", bgcolor=color.gray, text_color=color.white) table.cell(indicators, 0, 5, "EMA 20", bgcolor=color.gray, text_color=color.white) // 5 dakika tf_close = f_get_security(syminfo.tickerid, t1, close) tf_sma5 = f_get_security(syminfo.tickerid, t1, ta.sma(close, sma_length_1)) tf_sma20 = f_get_security(syminfo.tickerid, t1, ta.sma(close, sma_length_2)) tf_ema5 = f_get_security(syminfo.tickerid, t1, ta.ema(close, ema_length_1)) tf_ema20 = f_get_security(syminfo.tickerid, t1, ta.ema(close, ema_length_2)) table.cell(indicators, 1, 0, "5m", text_color=color.gray) table.cell(indicators, 1, 1, str.tostring(tf_close, "#.##"), text_color=color.white) table.cell(indicators, 1, 2, str.tostring(tf_sma5, "#.##"), text_color=tf_close > tf_sma5 ? color.green : color.red) table.cell(indicators, 1, 3, str.tostring(tf_sma20, "#.##"), text_color=tf_close > tf_sma20 ? color.green : color.red) table.cell(indicators, 1, 4, str.tostring(tf_ema5, "#.##"), text_color=tf_close > tf_ema5 ? color.green : color.red) table.cell(indicators, 1, 5, str.tostring(tf_ema20, "#.##"), text_color=tf_close > tf_ema20 ? color.green : color.red) // 15 dakika tf_close := f_get_security(syminfo.tickerid, t2, close) tf_sma5 := f_get_security(syminfo.tickerid, t2, ta.sma(close, sma_length_1)) tf_sma20 := f_get_security(syminfo.tickerid, t2, ta.sma(close, sma_length_2)) tf_ema5 := f_get_security(syminfo.tickerid, t2, ta.ema(close, ema_length_1)) tf_ema20 := f_get_security(syminfo.tickerid, t2, ta.ema(close, ema_length_2)) table.cell(indicators, 2, 0, "15m", text_color=color.gray) table.cell(indicators, 2, 1, str.tostring(tf_close, "#.##"), text_color=color.white) table.cell(indicators, 2, 2, str.tostring(tf_sma5, "#.##"), text_color=tf_close > tf_sma5 ? color.green : color.red) table.cell(indicators, 2, 3, str.tostring(tf_sma20, "#.##"), text_color=tf_close > tf_sma20 ? color.green : color.red) table.cell(indicators, 2, 4, str.tostring(tf_ema5, "#.##"), text_color=tf_close > tf_ema5 ? color.green : color.red) table.cell(indicators, 2, 5, str.tostring(tf_ema20, "#.##"), text_color=tf_close > tf_ema20 ? color.green : color.red) // 30 dakika tf_close := f_get_security(syminfo.tickerid, t3, close) tf_sma5 := f_get_security(syminfo.tickerid, t3, ta.sma(close, sma_length_1)) tf_sma20 := f_get_security(syminfo.tickerid, t3, ta.sma(close, sma_length_2)) tf_ema5 := f_get_security(syminfo.tickerid, t3, ta.ema(close, ema_length_1)) tf_ema20 := f_get_security(syminfo.tickerid, t3, ta.ema(close, ema_length_2)) table.cell(indicators, 3, 0, "30m", text_color=color.gray) table.cell(indicators, 3, 1, str.tostring(tf_close, "#.##"), text_color=color.white) table.cell(indicators, 3, 2, str.tostring(tf_sma5, "#.##"), text_color=tf_close > tf_sma5 ? color.green : color.red) table.cell(indicators, 3, 3, str.tostring(tf_sma20, "#.##"), text_color=tf_close > tf_sma20 ? color.green : color.red) table.cell(indicators, 3, 4, str.tostring(tf_ema5, "#.##"), text_color=tf_close > tf_ema5 ? color.green : color.red) table.cell(indicators, 3, 5, str.tostring(tf_ema20, "#.##"), text_color=tf_close > tf_ema20 ? color.green : color.red) // 1 saat tf_close := f_get_security(syminfo.tickerid, t4, close) tf_sma5 := f_get_security(syminfo.tickerid, t4, ta.sma(close, sma_length_1)) tf_sma20 := f_get_security(syminfo.tickerid, t4, ta.sma(close, sma_length_2)) tf_ema5 := f_get_security(syminfo.tickerid, t4, ta.ema(close, ema_length_1)) tf_ema20 := f_get_security(syminfo.tickerid, t4, ta.ema(close, ema_length_2)) table.cell(indicators, 4, 0, "1h", text_color=color.gray) table.cell(indicators, 4, 1, str.tostring(tf_close, "#.##"), text_color=color.white) table.cell(indicators, 4, 2, str.tostring(tf_sma5, "#.##"), text_color=tf_close > tf_sma5 ? color.green : color.red) table.cell(indicators, 4, 3, str.tostring(tf_sma20, "#.##"), text_color=tf_close > tf_sma20 ? color.green : color.red) table.cell(indicators, 4, 4, str.tostring(tf_ema5, "#.##"), text_color=tf_close > tf_ema5 ? color.green : color.red) table.cell(indicators, 4, 5, str.tostring(tf_ema20, "#.##"), text_color=tf_close > tf_ema20 ? color.green : color.red) // 4 saat tf_close := f_get_security(syminfo.tickerid, t5, close) tf_sma5 := f_get_security(syminfo.tickerid, t5, ta.sma(close, sma_length_1)) tf_sma20 := f_get_security(syminfo.tickerid, t5, ta.sma(close, sma_length_2)) tf_ema5 := f_get_security(syminfo.tickerid, t5, ta.ema(close, ema_length_1)) tf_ema20 := f_get_security(syminfo.tickerid, t5, ta.ema(close, ema_length_2)) table.cell(indicators, 5, 0, "4h", text_color=color.gray) table.cell(indicators, 5, 1, str.tostring(tf_close, "#.##"), text_color=color.white) table.cell(indicators, 5, 2, str.tostring(tf_sma5, "#.##"), text_color=tf_close > tf_sma5 ? color.green : color.red) table.cell(indicators, 5, 3, str.tostring(tf_sma20, "#.##"), text_color=tf_close > tf_sma20 ? color.green : color.red) table.cell(indicators, 5, 4, str.tostring(tf_ema5, "#.##"), text_color=tf_close > tf_ema5 ? color.green : color.red) table.cell(indicators, 5, 5, str.tostring(tf_ema20, "#.##"), text_color=tf_close > tf_ema20 ? color.green : color.red) // Günlük tf_close := f_get_security(syminfo.tickerid, t6, close) tf_sma5 := f_get_security(syminfo.tickerid, t6, ta.sma(close, sma_length_1)) tf_sma20 := f_get_security(syminfo.tickerid, t6, ta.sma(close, sma_length_2)) tf_ema5 := f_get_security(syminfo.tickerid, t6, ta.ema(close, ema_length_1)) tf_ema20 := f_get_security(syminfo.tickerid, t6, ta.ema(close, ema_length_2)) table.cell(indicators, 6, 0, "1D", text_color=color.gray) table.cell(indicators, 6, 1, str.tostring(tf_close, "#.##"), text_color=color.white) table.cell(indicators, 6, 2, str.tostring(tf_sma5, "#.##"), text_color=tf_close > tf_sma5 ? color.green : color.red) table.cell(indicators, 6, 3, str.tostring(tf_sma20, "#.##"), text_color=tf_close > tf_sma20 ? color.green : color.red) table.cell(indicators, 6, 4, str.tostring(tf_ema5, "#.##"), text_color=tf_close > tf_ema5 ? color.green : color.red) table.cell(indicators, 6, 5, str.tostring(tf_ema20, "#.##"), text_color=tf_close > tf_ema20 ? color.green : color.red)
Leave a Comment