Untitled
unknown
plain_text
2 months ago
6.9 kB
7
Indexable
//@version=5 indicator("ALPHATREND - Tablo Örneği (Güncellenmiş)", shorttitle="Table", overlay=true) //----------------------------------------------------- // KULLANICI AYARLARI //----------------------------------------------------- // 1) Tablo Boyutu Seçimi tableSize = input.string(title="Tablo Boyutu", defval="Normal", options=["Küçük", "Normal"]) // Seçime göre PineScript'in metin boyutu sabitini belirleyelim f_getTextSize(sz) => sz == "Küçük" ? size.small : size.normal // Metin boyutunu bir değişkene kaydedelim var textSize = f_getTextSize(tableSize) // 2) Tablo Konumu Seçimi tablePosition = input.string(title="Tablo Konumu", defval="Sağ Üst", options=["Sağ Üst", "Sağ Orta", "Sağ Alt", "Sol Üst", "Sol Orta", "Sol Alt", "Orta Üst", "Orta Alt"]) // Seçime göre PineScript'in position.* sabitini belirleyelim f_getTablePosition(pos) => if pos == "Sağ Üst" position.top_right else if pos == "Sağ Orta" position.middle_right else if pos == "Sağ Alt" position.bottom_right else if pos == "Sol Üst" position.top_left else if pos == "Sol Orta" position.middle_left else if pos == "Sol Alt" position.bottom_left else if pos == "Orta Üst" position.top_center else position.bottom_center // "Orta Alt" // (C) Her zaman dilimi için SMA periyodu ayarı smaLen1M = input.int(5, title="SMA Periyodu (1 Dakika)") smaLen3M = input.int(5, title="SMA Periyodu (3 Dakika)") smaLen5M = input.int(5, title="SMA Periyodu (5 Dakika)") smaLen15M = input.int(5, title="SMA Periyodu (15 Dakika)") smaLen30M = input.int(5, title="SMA Periyodu (30 Dakika)") smaLen1H = input.int(5, title="SMA Periyodu (1 Saat)") smaLen2H = input.int(5, title="SMA Periyodu (2 Saat)") smaLen4H = input.int(5, title="SMA Periyodu (4 Saat)") smaLen8H = input.int(5, title="SMA Periyodu (8 Saat)") smaLen1D = input.int(5, title="SMA Periyodu (Günlük)") smaLen1W = input.int(5, title="SMA Periyodu (Haftalık)") smaLen1MO = input.int(5, title="SMA Periyodu (Aylık)") //----------------------------------------------------- // 2) Her periyottaki sinyali ayrı hesaplayan fonksiyonlar // (SMA uzunluğunu parametre olarak alıyor) //----------------------------------------------------- f_signal_1M(sLen) => c = request.security(syminfo.tickerid, "1", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_3M(sLen) => c = request.security(syminfo.tickerid, "3", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_5M(sLen) => c = request.security(syminfo.tickerid, "5", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_15M(sLen) => c = request.security(syminfo.tickerid, "15", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_30M(sLen) => c = request.security(syminfo.tickerid, "30", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_1H(sLen) => c = request.security(syminfo.tickerid, "60", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_2H(sLen) => c = request.security(syminfo.tickerid, "120", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_4H(sLen) => c = request.security(syminfo.tickerid, "240", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_8H(sLen) => c = request.security(syminfo.tickerid, "480", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_1D(sLen) => c = request.security(syminfo.tickerid, "D", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_1W(sLen) => c = request.security(syminfo.tickerid, "W", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" f_signal_1MO(sLen) => c = request.security(syminfo.tickerid, "M", close) smaV = ta.sma(c, sLen) isAl = c > smaV isAl ? "AL" : "SAT" //----------------------------------------------------- // 3) Sinyalleri Çağır (Her periyot için ayrı fonksiyon ve ayrı SMA ayarı) //----------------------------------------------------- sig1M = f_signal_1M(smaLen1M) sig3M = f_signal_3M(smaLen3M) sig5M = f_signal_5M(smaLen5M) sig15M = f_signal_15M(smaLen15M) sig30M = f_signal_30M(smaLen30M) sig1H = f_signal_1H(smaLen1H) sig2H = f_signal_2H(smaLen2H) sig4H = f_signal_4H(smaLen4H) sig8H = f_signal_8H(smaLen8H) sig1D = f_signal_1D(smaLen1D) sig1W = f_signal_1W(smaLen1W) sig1MO = f_signal_1MO(smaLen1MO) //----------------------------------------------------- // 4) Tablo oluşturma //----------------------------------------------------- var table myTable = table.new( f_getTablePosition(tablePosition), // Seçilen konum 5, 5) //----------------------------------------------------- // Başlık satırı (arka plan gri, metin beyaz) //----------------------------------------------------- if barstate.isfirst table.cell(myTable, 0, 0, text="Alpha Finans v1", text_halign=text.align_center, text_valign=text.align_center, text_color=color.white, text_size=textSize, bgcolor=color.rgb(0, 252, 231, 100)) // Bu hücreyi 3 sütunu kaplayacak şekilde birleştir table.merge_cells(myTable, 0, 0, 2, 0 ) //----------------------------------------------------- // 5) Hücreleri doldurmak için fonksiyon //----------------------------------------------------- f_fillCell(row, col, tfStr, signal) => // Hücrede görünecek metin, sadece zaman periyodu cellText = tfStr // Metin rengi AL ise yeşil, SAT ise kırmızı textColor = signal == "AL" ? color.new(color.lime, 0) : color.new(color.red, 0) // Arkaplanı saydam (örnek: #7084ce00 → alpha = 00) bgColor = #7084ce00 // Hücreyi oluştur table.cell(myTable, row, col, text=cellText, text_halign=text.align_center, text_valign=text.align_center, text_size=textSize, text_color=textColor, bgcolor=bgColor) //----------------------------------------------------- // 6) Zaman dilimi + sinyal kombinasyonlarını tabloya yerleştir //----------------------------------------------------- // 1. satır f_fillCell(0, 1, "1 Dk", sig1M) f_fillCell(1, 1, "30 Dk", sig30M) f_fillCell(2, 1, "8 Saat", sig8H) // 2. satır f_fillCell(0, 2, "3 Dk", sig3M) f_fillCell(1, 2, "1 Saat", sig1H) f_fillCell(2, 2, "Günlük", sig1D) // 3. satır f_fillCell(0, 3, "5 Dk", sig5M) f_fillCell(1, 3, "2 Saat", sig2H) f_fillCell(2, 3, "Haftalık", sig1W) // 4. satır f_fillCell(0, 4, "15 Dk", sig15M) f_fillCell(1, 4, "4 Saat", sig4H) f_fillCell(2, 4, "Aylık", sig1MO)
Editor is loading...
Leave a Comment