Untitled
//@version=6 indicator(' V2 SAT', shorttitle='SİBOŞ V2 SAT', overlay=true, format=format.price, precision=2) // Renk değişkenleri upColor = color.white midColor = #90bff9 downColor = color.blue // Kaynak src = input(defval = close, title = 'Kaynak') // Örnekleme Periyodu per = input.int(defval = 100, minval = 1, title = 'Örnekleme Periyodu') // Aralık Çarpanı mult = input.float(defval = 3.0, minval = 0.1, title = 'Aralık Çarpanı') // Düzgün Ortalama Aralık 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) // Aralık Filtresi 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) // Filtre Yönü var float upward = na var float downward = na upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1]) downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1]) // Hedef Bantlar hband = filt + smrng lband = filt - smrng // Renkler 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 = 'Aralık Filtresi') // Hedef hbandplot = plot(hband, color = color.new(upColor, 70), title = 'Yüksek Hedef') lbandplot = plot(lband, color = color.new(downColor, 70), title = 'Düşük Hedef') // Dolgular fill(hbandplot, filtplot, color = color.new(upColor, 90), title = 'Yüksek Hedef Aralığı') fill(lbandplot, filtplot, color = color.new(downColor, 90), title = 'Düşük Hedef Aralığı') // Bar Rengi barcolor(barcolor) // Break Out'lar var bool longCond = false var bool shortCond = false 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 var int CondIni = 0 CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1] longCondition = longCond and CondIni[1] == -1 shortCondition = shortCond and CondIni[1] == 1 // Alarmlar (Sadece Satış) plotshape(shortCondition, title = 'Satım Sinyali', text = 'Sat', textcolor = color.white, style = shape.labeldown, size = size.small, location = location.abovebar, color = color.rgb(245, 23, 23, 20)) // Sembol ve Adet Bilgileri var string[] sembolListesi = array.new_string(20, "") var float[] pozisyonAdetleri = array.new_float(20, 0) // Sembol ve Adet Bilgilerini Yan Yana Girebilmek İçin Grup ve Inline Kullanımı gr_sy = "Sembol ve Adet Bilgileri" /// Sembol ve Adet Bilgileri (Sabit inline değerleri ile) array.set(sembolListesi, 0, input.symbol("", title="Sembol 1", group=gr_sy, inline="sym1")) array.set(pozisyonAdetleri, 0, input.float(0, title="Adet 1", minval=0, group=gr_sy, inline="sym1")) array.set(sembolListesi, 1, input.symbol("", title="Sembol 2", group=gr_sy, inline="sym2")) array.set(pozisyonAdetleri, 1, input.float(0, title="Adet 2", minval=0, group=gr_sy, inline="sym2")) array.set(sembolListesi, 2, input.symbol("", title="Sembol 3", group=gr_sy, inline="sym3")) array.set(pozisyonAdetleri, 2, input.float(0, title="Adet 3", minval=0, group=gr_sy, inline="sym3")) array.set(sembolListesi, 3, input.symbol("", title="Sembol 4", group=gr_sy, inline="sym4")) array.set(pozisyonAdetleri, 3, input.float(0, title="Adet 4", minval=0, group=gr_sy, inline="sym4")) array.set(sembolListesi, 4, input.symbol("", title="Sembol 5", group=gr_sy, inline="sym5")) array.set(pozisyonAdetleri, 4, input.float(0, title="Adet 5", minval=0, group=gr_sy, inline="sym5")) array.set(sembolListesi, 5, input.symbol("", title="Sembol 6", group=gr_sy, inline="sym6")) array.set(pozisyonAdetleri, 5, input.float(0, title="Adet 6", minval=0, group=gr_sy, inline="sym6")) array.set(sembolListesi, 6, input.symbol("", title="Sembol 7", group=gr_sy, inline="sym7")) array.set(pozisyonAdetleri, 6, input.float(0, title="Adet 7", minval=0, group=gr_sy, inline="sym7")) array.set(sembolListesi, 7, input.symbol("", title="Sembol 8", group=gr_sy, inline="sym8")) array.set(pozisyonAdetleri, 7, input.float(0, title="Adet 8", minval=0, group=gr_sy, inline="sym8")) array.set(sembolListesi, 8, input.symbol("", title="Sembol 9", group=gr_sy, inline="sym9")) array.set(pozisyonAdetleri, 8, input.float(0, title="Adet 9", minval=0, group=gr_sy, inline="sym9")) array.set(sembolListesi, 9, input.symbol("", title="Sembol 10", group=gr_sy, inline="sym10")) array.set(pozisyonAdetleri, 9, input.float(0, title="Adet 10", minval=0, group=gr_sy, inline="sym10")) array.set(sembolListesi, 10, input.symbol("", title="Sembol 11", group=gr_sy, inline="sym11")) array.set(pozisyonAdetleri, 10, input.float(0, title="Adet 11", minval=0, group=gr_sy, inline="sym11")) array.set(sembolListesi, 11, input.symbol("", title="Sembol 12", group=gr_sy, inline="sym12")) array.set(pozisyonAdetleri, 11, input.float(0, title="Adet 12", minval=0, group=gr_sy, inline="sym12")) array.set(sembolListesi, 12, input.symbol("", title="Sembol 13", group=gr_sy, inline="sym13")) array.set(pozisyonAdetleri, 12, input.float(0, title="Adet 13", minval=0, group=gr_sy, inline="sym13")) array.set(sembolListesi, 13, input.symbol("", title="Sembol 14", group=gr_sy, inline="sym14")) array.set(pozisyonAdetleri, 13, input.float(0, title="Adet 14", minval=0, group=gr_sy, inline="sym14")) array.set(sembolListesi, 14, input.symbol("", title="Sembol 15", group=gr_sy, inline="sym15")) array.set(pozisyonAdetleri, 14, input.float(0, title="Adet 15", minval=0, group=gr_sy, inline="sym15")) array.set(sembolListesi, 15, input.symbol("", title="Sembol 16", group=gr_sy, inline="sym16")) array.set(pozisyonAdetleri, 15, input.float(0, title="Adet 16", minval=0, group=gr_sy, inline="sym16")) array.set(sembolListesi, 16, input.symbol("", title="Sembol 17", group=gr_sy, inline="sym17")) array.set(pozisyonAdetleri, 16, input.float(0, title="Adet 17", minval=0, group=gr_sy, inline="sym17")) array.set(sembolListesi, 17, input.symbol("", title="Sembol 18", group=gr_sy, inline="sym18")) array.set(pozisyonAdetleri, 17, input.float(0, title="Adet 18", minval=0, group=gr_sy, inline="sym18")) array.set(sembolListesi, 18, input.symbol("", title="Sembol 19", group=gr_sy, inline="sym19")) array.set(pozisyonAdetleri, 18, input.float(0, title="Adet 19", minval=0, group=gr_sy, inline="sym19")) array.set(sembolListesi, 19, input.symbol("", title="Sembol 20", group=gr_sy, inline="sym20")) array.set(pozisyonAdetleri, 19, input.float(0, title="Adet 20", minval=0, group=gr_sy, inline="sym20")) // APIKEY APIKEY = input.string(title="APIKEY", defval="APIKEY", tooltip="Osmanlı Yatırım API anahtarınızı girin") // Sinyal Değişkeni (Sadece Satış) sat = shortCondition Sinyal = sat ? -1 * close : 0 // Sadece satış sinyali üret // Sinyali tetikleyen fonksiyon (Sadece Satış) alarmTetikle(sembol, sinyal, adet) => durum = request.security(sembol, timeframe.period, Sinyal) mesaj = durum < 0 ? "sell" : "" // Sadece satış durumu if durum < 0 and str.length(sembol) > 1 // Sadece satış sinyali için kontrol // Osmanlı Yatırım için JSON formatında emir mesajı oluştur alarmMesajiJSON = '{"name": "Emir",' + '"symbol": "' + syminfo.ticker(sembol) + '",' + '"orderSide": "' + mesaj + '",' + '"orderType": "mkt",' + '"price": "0",' + '"quantity": "' + str.tostring(adet) + '",' + '"timeInForce": "ioc",' + '"apiKey": "' + APIKEY + '",' + '"goodInOffHours": "0"}' // Osmanlı Yatırım sistemine emir gönderme alert(message = alarmMesajiJSON, freq = alert.freq_once_per_bar_close) // Her sembol için alarmTetikle fonksiyonunu çağır (Sadece Satış) for i = 0 to 19 sembol = array.get(sembolListesi, i) adet = array.get(pozisyonAdetleri, i) if str.length(sembol) > 1 and adet > 0 alarmTetikle(sembol, Sinyal, adet)
Leave a Comment