├── Adaptive Fibonacci Retracement ├── Adaptive Linear Regression ├── AlphaTrend - Screener ├── Any Screener ├── Backtesting Module (Info) ├── BarScope ├── Calculator - Binom Dağılımı ├── Calculator - Financial Math ├── Calculator - Negatif Binom Dağılımı ├── Calculator - PnL Report ├── Calculator - Position Tool (Risk Yönetimi) ├── Degreed Tillson Moving Average ├── EMA - Tuples (10 Degree) ├── FICH (by Anıl Özekşi) ├── Fixed Stop & Profit ├── Koşul Uygulamaları ├── LICENSE ├── Notes - Backtest Değişkenleri ├── Notes - Bar Index ├── OTT Collection (Info) ├── Piramitleme (Çözüm) ├── Pivot Levels [MTF] ├── README.md ├── Trailing Stop & Profit └── VAR (Değişken Ortalama) /Adaptive Fibonacci Retracement: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // Author & Developer : dg_factor [06.08.2023] 3 | 4 | // UYARI 5 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 6 | 7 | // LINK (Video) 8 | // https://twitter.com/dg_factor/status/1688196976779591681 9 | 10 | // TANIM 11 | // Aşağıdaki komut dosyası herhangi bir data serisi üzerinde auto Fibonacci seviyelerinin nasıl çizdirilebileceğine örnek teşkil eder. 12 | // Seviyeler, datanın belirtilen uzunluktaki en yüksek ve en düşük değerlerine göre tanımlanır. 13 | 14 | // GELİŞTİRMELER 15 | // Çoğu indikatör grafikteki bar sayısından daha büyük bir uzunluk değeri girildiğinde hata verir. 16 | // Aşağıdaki x ve n değişkenlerini incelediğinizde bu sorunun basit bir çözümünü bulabilirsiniz. 17 | 18 | // UYARI 19 | // Mevcut bardaki "Yüksek" ve "Düşük" kaynak değeri, belirtilen uzunluktaki en yüksek veya en düşük değere sahipse, seviyeler buna göre değişecektir. 20 | 21 | //@version=5 22 | indicator("Adaptive Fibonacci Retracement") 23 | 24 | // Kaynak Inputs 25 | g1 = "KAYNAK GİRİNİZ" 26 | g2 = "KONFİGÜRASYON" 27 | t0 = "Hesaplamada etkisi yoktur, sadece çizim için kullanılır." 28 | yuksek = input(title="Yüksek", defval=ohlc4, group=g1) 29 | dusuk = input(title="Düşük", defval=ohlc4, group=g1) 30 | data = input(title="Data", defval=ohlc4, group=g1, tooltip=t0) 31 | 32 | // Konfigürasyon Inputs 33 | uzunluk = input.int(title="Uzunluk  ", defval=200, group=g2, inline="0") 34 | 35 | r_0000 = input.color(defval=#ff5252, title="A", group=g2, inline="1") 36 | r_0236 = input.color(defval=#2962ff, title="B", group=g2, inline="2") 37 | r_0382 = input.color(defval=#794100, title="C", group=g2, inline="3") 38 | r_0500 = input.color(defval=#008f6e, title="D", group=g2, inline="4") 39 | r_0618 = input.color(defval=#673ab7, title="E", group=g2, inline="5") 40 | r_0786 = input.color(defval=#8b9600, title="F", group=g2, inline="6") 41 | r_1000 = input.color(defval=#138800, title="G", group=g2, inline="7") 42 | 43 | k_0000 = input.float(defval=0.000, title="", group=g2, inline="1") 44 | k_0236 = input.float(defval=0.236, title="", group=g2, inline="2") 45 | k_0382 = input.float(defval=0.382, title="", group=g2, inline="3") 46 | k_0500 = input.float(defval=0.500, title="", group=g2, inline="4") 47 | k_0618 = input.float(defval=0.618, title="", group=g2, inline="5") 48 | k_0786 = input.float(defval=0.786, title="", group=g2, inline="6") 49 | k_1000 = input.float(defval=1.000, title="", group=g2, inline="7") 50 | 51 | // Hesaplamalar 52 | bool yy = false 53 | bool dd = false 54 | var float _h = na 55 | var float _l = na 56 | if yuksek > nz(_h, 1e-10) 57 | _h := yuksek 58 | yy := true 59 | yu = ta.barssince(yy) 60 | if dusuk < nz(_l, 1e10) 61 | _l := dusuk 62 | dd := true 63 | du = ta.barssince(dd) 64 | bool x = uzunluk >= bar_index + 1 65 | int n = x ? 1 : uzunluk 66 | u_h = ta.highest(yuksek, n) 67 | u_l = ta.lowest(dusuk, n) 68 | u_yu = -ta.highestbars(yuksek, n) 69 | u_du = -ta.lowestbars(dusuk, n) 70 | hd = x ? yu : u_yu 71 | ld = x ? du : u_du 72 | _y = x ? _h : u_h 73 | _d = x ? _l : u_l 74 | y1 = hd < ld ? _d : _y 75 | y2 = hd < ld ? _y : _d 76 | k_lin = y1 - y2 77 | fib_0000 = y2 + k_lin * k_0000 78 | fib_0236 = y2 + k_lin * k_0236 79 | fib_0382 = y2 + k_lin * k_0382 80 | fib_0500 = y2 + k_lin * k_0500 81 | fib_0618 = y2 + k_lin * k_0618 82 | fib_0786 = y2 + k_lin * k_0786 83 | fib_1000 = y2 + k_lin * k_1000 84 | 85 | // Plots 86 | plot(data, title="data", color=color.silver) 87 | plot(fib_0000, title="A", color=r_0000, linewidth=2, offset=-9999, trackprice=true, editable=false) 88 | plot(fib_0236, title="B", color=r_0236, linewidth=2, offset=-9999, trackprice=true, editable=false) 89 | plot(fib_0382, title="C", color=r_0382, linewidth=2, offset=-9999, trackprice=true, editable=false) 90 | plot(fib_0500, title="D", color=r_0500, linewidth=2, offset=-9999, trackprice=true, editable=false) 91 | plot(fib_0618, title="E", color=r_0618, linewidth=2, offset=-9999, trackprice=true, editable=false) 92 | plot(fib_0786, title="F", color=r_0786, linewidth=2, offset=-9999, trackprice=true, editable=false) 93 | plot(fib_1000, title="G", color=r_1000, linewidth=2, offset=-9999, trackprice=true, editable=false) 94 | 95 | // Katsayı hesaplama detayları (sadece dört tanesi yaygın olarak kullanılır) : 96 | // ... 97 | // ✘ 0,090 ⟶ 0,618^5 98 | // ✘ 0,145 ⟶ 0,618^4 99 | // ✔ 0,236 ⟶ 0,618^3 100 | // ✔ 0,382 ⟶ 0,618^2 101 | // ✔ 0,618 ⟶ 0,618^1 102 | // ✔ 0,786 ⟶ 0,618^(1/2) 103 | // ✘ 0,851 ⟶ 0,618^(1/3) 104 | // ✘ 0,886 ⟶ 0,618^(1/4) 105 | // ✘ 0,908 ⟶ 0,618^(1/5) 106 | // ... 107 | 108 | // NOT : 109 | // Real Time Data kullanmak isteyenler aşağıdaki dizi yapısından yararlanabilirler. 110 | // _max & _min değişkenleri datanın bar içinde görülmüş en yüksek ve en düşük değerlerini döndürür. 111 | // Fibonacci seviyeleri bu değişkenlere dayalı olarak yeniden hesaplanabilir. Ve fakat; 112 | // Dizi yapısı geçmişe dönük değer üretmez. Sonuçlar, indikatör grafiğe yüklendikten sonra çizilmeye başlar. 113 | // Kullanmadan önce 1 dakikalık grafikte çalışma mantığının gözlenmesi önerilir. 114 | 115 | // varip float[] dizi = array.new_float(0) 116 | // if barstate.isnew 117 | // array.clear(dizi) 118 | // array.push(dizi, data) 119 | // float _max = array.max(dizi) 120 | // float _min = array.min(dizi) 121 | // plot(_max, title="max", color=color.lime) 122 | // plot(_min, title="min", color=color.red) 123 | 124 | -------------------------------------------------------------------------------- /Adaptive Linear Regression: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // Author & Developer : © dg_factor [13.08.2023] 3 | 4 | // UYARI 5 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 6 | 7 | // LINK (video) 8 | // https://twitter.com/dg_factor/status/1690796984964091905 9 | 10 | // AÇIKLAMA 11 | // Aşağıdaki komut herhangi bir data serisi üzerinde Lineer Regresyon Kanalı'nın çizimine örnek teşkil eder. 12 | // Lineer Regresyon, aralarında neden-sonuç ilişkisi bulunan bağımlı ve bağımsız değişkenlerden; 13 | // bağımsız olanlara dayalı olarak bağımlı değişkeni tahmin etmek için kullanılan bir analiz yöntemidir. 14 | // Bir sebebe bağlı olarak ileriye yönelik tahmin amaçlar. 15 | // Regresyon Kanalı direnç ve destek seviyelerinin belirlenmesi amacıyla; (örneklem) sapma değeri ve onun katlarına dayalı olarak hesaplanır. 16 | 17 | // UYARI (REPAINT) 18 | // Repaint kısaca, bir datanın geçmiş değerlerinin sonraki barlarda değişmesi olarak tanımlanabilir. 19 | // Regresyon kanalı her barda dizinin kaydırılmasıyla hesaplanan dinamik bir göstergedir, dolayısıyla repaint yapar. 20 | // "Statik Kanal" hareket etmez, indikatörü çalıştırıdığınız ana ait seviyeleri "dondurur". 21 | 22 | //@version=5 23 | indicator("Adaptive Linear Regression") 24 | 25 | g1 = "KAYNAK GİRİNİZ" 26 | data = input(title="Data", defval=close, group=g1) 27 | 28 | t1 = "Dinamik kanal sürekli güncellenir ve repaint yapar." 29 | t2 = "Statik kanal repaint yapmaz. İndikatörün çalıştırıldığı an itibariyle oluşmuş seviyeleri çizer ve asla değişmez. " + 30 | "(Açık olan bar hesaplamaya dahil değildir)." 31 | t3 = "Band çizimi dinamiktir ve repaint yapmaz, en güvenilir sonucu gösterir." 32 | g2 = "KONFİGÜRASYON" 33 | uzunluk = input.int(title="Uzunluk", defval=100, group=g2) 34 | katsayi = input.float(title="Katsayı", defval=2.0, step=0.1, group=g2) 35 | c1 = input.color(title="Renk ", defval=#00bcd4, group=g2, inline="c") 36 | c2 = input.color(title="", defval=#00bb00, group=g2, inline="c") 37 | c3 = input.color(title="", defval=#fb0000, group=g2, inline="c") 38 | dinamik = input.bool(title="Dinamik Kanal", defval=true, group=g2, tooltip=t1) 39 | statik = input.bool(title="Statik Kanal", defval=true, group=g2, tooltip=t2) 40 | band = input.bool(title="Band", defval=false, group=g2, tooltip=t3) 41 | uzat = input.bool(title="Uzat", defval=false, group=g2) 42 | _uzat = uzat ? extend.right : extend.none 43 | 44 | // Level Func 45 | f_lvl(r, c) => 46 | var line ln = na, line.delete(ln) 47 | var label lb = na, label.delete(lb) 48 | ln := statik ? line.new(bar_index, r, bar_index+50, r, xloc.bar_index, 49 | uzat ? extend.left : extend.none, c, line.style_dashed) : na 50 | lb := statik ? label.new(bar_index+50, r, str.tostring(r, format.mintick), xloc.bar_index, yloc.price, 51 | #00000000, label.style_label_left, c, size.normal, text.align_right) : na 52 | // 53 | 54 | // Hesaplamalar 55 | x = bar_index 56 | y = data 57 | _x = math.sum(x, uzunluk) 58 | _y = math.sum(y, uzunluk) 59 | _xy = math.sum(x * y, uzunluk) 60 | _xx = math.sum(x * x, uzunluk) 61 | // y = mx + b için; 62 | m = (uzunluk * _xy - _x * _y) / (uzunluk * _xx - _x * _x) 63 | b = (_y - m * _x) / uzunluk 64 | r = ta.correlation(x, y, uzunluk) 65 | dt = math.pow(r, 2) * 100 66 | // Apsis 67 | x1 = x - uzunluk + 1 68 | x2 = x 69 | // Ordinat 70 | y1 = m * x1 + b 71 | y2 = m * x2 + b // ta.linreg(data, uzunluk, 0) 72 | // Sapma (Örneklem) 73 | varyans = 0.0 74 | for i = 0 to uzunluk - 1 75 | varyans += math.pow(y[i] - (m * (x - i) + b), 2) 76 | varyans 77 | sapma = math.sqrt(varyans / uzunluk) * katsayi 78 | // Çizim 79 | reg = dinamik ? line.new(x1, y1, x2, y2, xloc.bar_index, _uzat, c1) : na, line.delete(reg[1]) 80 | ust = dinamik ? line.new(x1, y1 + sapma, x2, y2 + sapma, xloc.bar_index, _uzat, c2) : na, line.delete(ust[1]) 81 | alt = dinamik ? line.new(x1, y1 - sapma, x2, y2 - sapma, xloc.bar_index, _uzat, c3) : na, line.delete(alt[1]) 82 | // Statik Seviyeler 83 | var float md = na 84 | var float up = na 85 | var float dn = na 86 | if barstate.islastconfirmedhistory 87 | md := y2 88 | up := y2 + sapma 89 | dn := y2 - sapma 90 | f_lvl(md, c1) 91 | f_lvl(up, c2) 92 | f_lvl(dn, c3) 93 | 94 | plot(data, title="Data", color=color.silver) 95 | plot(not band ? na : y2 + sapma, "up", c2) 96 | plot(not band ? na : y2, "mid", c1) 97 | plot(not band ? na : y2 - sapma, "down", c3) 98 | plot(r, "Pearson r", precision=2, display=display.data_window) 99 | plot(dt, "Determination %", precision=2, display=display.data_window) 100 | -------------------------------------------------------------------------------- /AlphaTrend - Screener: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | 3 | // UYARI 4 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 5 | 6 | // ALPHATREND SCREENER çoğumuza ilham veren sevgili Kıvanç özbilgiç'e naçizane bir teşekkür için kodlandı. 7 | // Umarım herkese faydası dokunur... 8 | // © dg_factor [04.09.2022, İstanbul] 9 | 10 | // https://twitter.com/dg_factor/status/1661484012236595202?s=20 11 | 12 | // ALPHATREND SCREENER has been coded as a humble thanks to dear Kıvanç Özbilgiç who inspired many of us. 13 | // I hope it helps everyone... 14 | 15 | // Created & Developed by : Kıvanç Özbilgiç (@KivancOzbilgic) 16 | // Screener Panel & Adjustments : @dg_factor 17 | 18 | //@version=5 19 | indicator('AlphaTrend [Screener]', overlay=true, format=format.price, precision=2) 20 | 21 | // AlphaTrend Inputs 22 | src = input.source(title='Source', defval=close, group='ALPHATREND') 23 | AP = input.int(title='Length', defval=14, group='ALPHATREND') 24 | coeff = input.float(title='Multiplier', defval=1.0, step=0.1, group='ALPHATREND') 25 | novolumedata = input.bool(title='Change Calculation (No Volume Data)', defval=false, group='ALPHATREND') 26 | showsignalsk = input(title='Show Signals ', defval=true, group='ALPHATREND') 27 | 28 | // AlphaTrend Calcs 29 | ATR = ta.sma(ta.tr, AP) 30 | upT = low - ATR * coeff 31 | downT = high + ATR * coeff 32 | rsi = ta.rsi(src, AP) 33 | mfi = ta.mfi(hlc3, AP) 34 | filter = novolumedata ? rsi >= 50 : mfi >= 50 35 | AlphaTrend = 0.0 36 | AlphaTrend := filter ? upT < nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : upT : downT > nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : downT 37 | color1 = AlphaTrend > AlphaTrend[2] ? #00E60F : AlphaTrend < AlphaTrend[2] ? #80000B : AlphaTrend[1] > AlphaTrend[3] ? #00E60F : #80000B 38 | buySignalk = ta.crossover(AlphaTrend, AlphaTrend[2]) 39 | sellSignalk = ta.crossunder(AlphaTrend, AlphaTrend[2]) 40 | K1 = ta.barssince(buySignalk) 41 | K2 = ta.barssince(sellSignalk) 42 | O1 = ta.barssince(buySignalk[1]) 43 | O2 = ta.barssince(sellSignalk[1]) 44 | direction = 0 45 | direction := buySignalk and O1 > K2 ? 1 : sellSignalk and O2 > K1 ? -1 : direction[1] 46 | 47 | // Plots 48 | k1 = plot(AlphaTrend, title='AlphaTrend', color=#0022fc, linewidth=3) 49 | k2 = plot(AlphaTrend[2], title='Trigger', color=#fc0400, linewidth=3) 50 | fill(k1, k2, title='Fill Color', color=color1) 51 | 52 | // Shapes 53 | plotshape(showsignalsk and buySignalk and O1 > K2 ? AlphaTrend[2] * 0.9999 : na, title='BUY', text='BUY', location=location.absolute, style=shape.labelup, size=size.tiny, color=#0022FC, textcolor=color.white) 54 | plotshape(showsignalsk and sellSignalk and O2 > K1 ? AlphaTrend[2] * 1.0001 : na, title='SELL', text='SELL', location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.maroon, textcolor=color.white) 55 | 56 | // Screener Inputs 57 | string gr_sc = 'SCREENER' 58 | string gr_sy = 'SYMBOL' 59 | string t00 = 'Alpha Trend Screener' 60 | color c00 = #686868 61 | lb_sh = input.bool(title='Show Label', defval=true, group=gr_sc) 62 | lb_xa = input.int(title='Horizontal Axis', defval=20, group=gr_sc, tooltip='Label Position x Axis') 63 | lb_ya = input.int(title='Vertical Axis', defval=1, group=gr_sc, tooltip='Label Position y Axis') 64 | lb_sz = input.string(title='Label Size', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], defval='Normal', group=gr_sc) 65 | lb_cl = input.color(title='Colours', defval=#00bb00, group=gr_sc, inline='0') 66 | lb_cs = input.color(title='', defval=#ff0000, group=gr_sc, inline='0') 67 | 68 | // Confirm Inputs 69 | sh01 = input.bool(title='01', defval=true, group=gr_sy, inline="01") 70 | sh02 = input.bool(title='02', defval=true, group=gr_sy, inline="02") 71 | sh03 = input.bool(title='03', defval=true, group=gr_sy, inline="03") 72 | sh04 = input.bool(title='04', defval=true, group=gr_sy, inline="04") 73 | sh05 = input.bool(title='05', defval=true, group=gr_sy, inline="05") 74 | sh06 = input.bool(title='06', defval=true, group=gr_sy, inline="06") 75 | sh07 = input.bool(title='07', defval=true, group=gr_sy, inline="07") 76 | sh08 = input.bool(title='08', defval=true, group=gr_sy, inline="08") 77 | sh09 = input.bool(title='09', defval=true, group=gr_sy, inline="09") 78 | sh10 = input.bool(title='10', defval=true, group=gr_sy, inline="10") 79 | sh11 = input.bool(title='11', defval=false, group=gr_sy, inline="11") 80 | sh12 = input.bool(title='12', defval=false, group=gr_sy, inline="12") 81 | sh13 = input.bool(title='13', defval=false, group=gr_sy, inline="13") 82 | sh14 = input.bool(title='14', defval=false, group=gr_sy, inline="14") 83 | sh15 = input.bool(title='15', defval=false, group=gr_sy, inline="15") 84 | sh16 = input.bool(title='16', defval=false, group=gr_sy, inline="16") 85 | sh17 = input.bool(title='17', defval=false, group=gr_sy, inline="17") 86 | sh18 = input.bool(title='18', defval=false, group=gr_sy, inline="18") 87 | sh19 = input.bool(title='19', defval=false, group=gr_sy, inline="19") 88 | sh20 = input.bool(title='20', defval=false, group=gr_sy, inline="20") 89 | 90 | // TimeFrame Inputs 91 | tf01 = input.timeframe(title='', defval='', group=gr_sy, inline="01") 92 | tf02 = input.timeframe(title='', defval='', group=gr_sy, inline="02") 93 | tf03 = input.timeframe(title='', defval='', group=gr_sy, inline="03") 94 | tf04 = input.timeframe(title='', defval='', group=gr_sy, inline="04") 95 | tf05 = input.timeframe(title='', defval='', group=gr_sy, inline="05") 96 | tf06 = input.timeframe(title='', defval='', group=gr_sy, inline="06") 97 | tf07 = input.timeframe(title='', defval='', group=gr_sy, inline="07") 98 | tf08 = input.timeframe(title='', defval='', group=gr_sy, inline="08") 99 | tf09 = input.timeframe(title='', defval='', group=gr_sy, inline="09") 100 | tf10 = input.timeframe(title='', defval='', group=gr_sy, inline="10") 101 | tf11 = input.timeframe(title='', defval='', group=gr_sy, inline="11") 102 | tf12 = input.timeframe(title='', defval='', group=gr_sy, inline="12") 103 | tf13 = input.timeframe(title='', defval='', group=gr_sy, inline="13") 104 | tf14 = input.timeframe(title='', defval='', group=gr_sy, inline="14") 105 | tf15 = input.timeframe(title='', defval='', group=gr_sy, inline="15") 106 | tf16 = input.timeframe(title='', defval='', group=gr_sy, inline="16") 107 | tf17 = input.timeframe(title='', defval='', group=gr_sy, inline="17") 108 | tf18 = input.timeframe(title='', defval='', group=gr_sy, inline="18") 109 | tf19 = input.timeframe(title='', defval='', group=gr_sy, inline="19") 110 | tf20 = input.timeframe(title='', defval='', group=gr_sy, inline="20") 111 | 112 | // Symbol Inputs 113 | s01 = input.symbol(title='', group=gr_sy, inline='01', defval='BINANCE:BTCUSDT') 114 | s02 = input.symbol(title='', group=gr_sy, inline='02', defval='BINANCE:ETHUSDT') 115 | s03 = input.symbol(title='', group=gr_sy, inline='03', defval='BINANCE:BNBUSDT') 116 | s04 = input.symbol(title='', group=gr_sy, inline='04', defval='BINANCE:ADAUSDT') 117 | s05 = input.symbol(title='', group=gr_sy, inline='05', defval='BINANCE:AVAXUSDT') 118 | s06 = input.symbol(title='', group=gr_sy, inline='06', defval='BINANCE:CHZUSDT') 119 | s07 = input.symbol(title='', group=gr_sy, inline='07', defval='BINANCE:DOGEUSDT') 120 | s08 = input.symbol(title='', group=gr_sy, inline='08', defval='BINANCE:SOLUSDT') 121 | s09 = input.symbol(title='', group=gr_sy, inline='09', defval='BINANCE:TRXUSDT') 122 | s10 = input.symbol(title='', group=gr_sy, inline='10', defval='BINANCE:XRPUSDT') 123 | s11 = input.symbol(title='', group=gr_sy, inline='11', defval='NASDAQ:AAPL') 124 | s12 = input.symbol(title='', group=gr_sy, inline='12', defval='NASDAQ:TSLA') 125 | s13 = input.symbol(title='', group=gr_sy, inline='13', defval='NASDAQ:AMZN') 126 | s14 = input.symbol(title='', group=gr_sy, inline='14', defval='NASDAQ:GOOGL') 127 | s15 = input.symbol(title='', group=gr_sy, inline='15', defval='NASDAQ:NVDA') 128 | s16 = input.symbol(title='', group=gr_sy, inline='16', defval='NASDAQ:META') 129 | s17 = input.symbol(title='', group=gr_sy, inline='17', defval='NYSE:C') 130 | s18 = input.symbol(title='', group=gr_sy, inline='18', defval='NASDAQ:NFLX') 131 | s19 = input.symbol(title='', group=gr_sy, inline='19', defval='NYSE:BABA') 132 | s20 = input.symbol(title='', group=gr_sy, inline='20', defval='NASDAQ:ABNB') 133 | 134 | // Functions 135 | f_screener(s) => 136 | int x = na 137 | int y = na 138 | z = color(na) 139 | if s 140 | x := direction 141 | y := ta.barssince(x != x[1]) 142 | z := x == 1 ? lb_cl : x == -1 ? lb_cs : c00 143 | [x, y, z] 144 | // 145 | f_bars(x) => 146 | r = ' [' + str.tostring(x) + '] ' 147 | // 148 | f_size(x) => 149 | x == 'Tiny' ? size.tiny : 150 | x == 'Small' ? size.small : 151 | x == 'Normal' ? size.normal : 152 | x == 'Large' ? size.large : 153 | x == 'Huge' ? size.huge : size.auto 154 | // 155 | f_label(l, t, c) => 156 | r = string(na) 157 | for i = l*2 to 0 158 | r += '\n\n' 159 | r += t 160 | var label lb = na 161 | label.delete(lb) 162 | fix_allign = ta.highest(200) 163 | lb := lb_sh ? label.new( 164 | x=bar_index + lb_xa, 165 | y=bar_index > 200 ? fix_allign * (1 + lb_ya / 1000) : hl2 * (1 + lb_ya / 1000), 166 | text=r, textcolor=c, textalign=text.align_right, 167 | style=label.style_label_left, size=f_size(lb_sz), color=#00000000) : na 168 | // 169 | 170 | // Variables 171 | [a01, b01, c01] = request.security(s01, tf01, f_screener(sh01)) 172 | [a02, b02, c02] = request.security(s02, tf02, f_screener(sh02)) 173 | [a03, b03, c03] = request.security(s03, tf03, f_screener(sh03)) 174 | [a04, b04, c04] = request.security(s04, tf04, f_screener(sh04)) 175 | [a05, b05, c05] = request.security(s05, tf05, f_screener(sh05)) 176 | [a06, b06, c06] = request.security(s06, tf06, f_screener(sh06)) 177 | [a07, b07, c07] = request.security(s07, tf07, f_screener(sh07)) 178 | [a08, b08, c08] = request.security(s08, tf08, f_screener(sh08)) 179 | [a09, b09, c09] = request.security(s09, tf09, f_screener(sh09)) 180 | [a10, b10, c10] = request.security(s10, tf10, f_screener(sh10)) 181 | [a11, b11, c11] = request.security(s11, tf11, f_screener(sh11)) 182 | [a12, b12, c12] = request.security(s12, tf12, f_screener(sh12)) 183 | [a13, b13, c13] = request.security(s13, tf13, f_screener(sh13)) 184 | [a14, b14, c14] = request.security(s14, tf14, f_screener(sh14)) 185 | [a15, b15, c15] = request.security(s15, tf15, f_screener(sh15)) 186 | [a16, b16, c16] = request.security(s16, tf16, f_screener(sh16)) 187 | [a17, b17, c17] = request.security(s17, tf17, f_screener(sh17)) 188 | [a18, b18, c18] = request.security(s18, tf18, f_screener(sh18)) 189 | [a19, b19, c19] = request.security(s19, tf19, f_screener(sh19)) 190 | [a20, b20, c20] = request.security(s20, tf20, f_screener(sh20)) 191 | 192 | // Text 193 | t01 = a01 == 1 ? '▲' + f_bars(b01) + s01 : a01 == -1 ? '▼' + f_bars(b01) + s01 : '■' + f_bars(b01) + s01 194 | t02 = a02 == 1 ? '▲' + f_bars(b02) + s02 : a02 == -1 ? '▼' + f_bars(b02) + s02 : '■' + f_bars(b02) + s02 195 | t03 = a03 == 1 ? '▲' + f_bars(b03) + s03 : a03 == -1 ? '▼' + f_bars(b03) + s03 : '■' + f_bars(b03) + s03 196 | t04 = a04 == 1 ? '▲' + f_bars(b04) + s04 : a04 == -1 ? '▼' + f_bars(b04) + s04 : '■' + f_bars(b04) + s04 197 | t05 = a05 == 1 ? '▲' + f_bars(b05) + s05 : a05 == -1 ? '▼' + f_bars(b05) + s05 : '■' + f_bars(b05) + s05 198 | t06 = a06 == 1 ? '▲' + f_bars(b06) + s06 : a06 == -1 ? '▼' + f_bars(b06) + s06 : '■' + f_bars(b06) + s06 199 | t07 = a07 == 1 ? '▲' + f_bars(b07) + s07 : a07 == -1 ? '▼' + f_bars(b07) + s07 : '■' + f_bars(b07) + s07 200 | t08 = a08 == 1 ? '▲' + f_bars(b08) + s08 : a08 == -1 ? '▼' + f_bars(b08) + s08 : '■' + f_bars(b08) + s08 201 | t09 = a09 == 1 ? '▲' + f_bars(b09) + s09 : a09 == -1 ? '▼' + f_bars(b09) + s09 : '■' + f_bars(b09) + s09 202 | t10 = a10 == 1 ? '▲' + f_bars(b10) + s10 : a10 == -1 ? '▼' + f_bars(b10) + s10 : '■' + f_bars(b10) + s10 203 | t11 = a11 == 1 ? '▲' + f_bars(b11) + s11 : a11 == -1 ? '▼' + f_bars(b11) + s11 : '■' + f_bars(b11) + s11 204 | t12 = a12 == 1 ? '▲' + f_bars(b12) + s12 : a12 == -1 ? '▼' + f_bars(b12) + s12 : '■' + f_bars(b12) + s12 205 | t13 = a13 == 1 ? '▲' + f_bars(b13) + s13 : a13 == -1 ? '▼' + f_bars(b13) + s13 : '■' + f_bars(b13) + s13 206 | t14 = a14 == 1 ? '▲' + f_bars(b14) + s14 : a14 == -1 ? '▼' + f_bars(b14) + s14 : '■' + f_bars(b14) + s14 207 | t15 = a15 == 1 ? '▲' + f_bars(b15) + s15 : a15 == -1 ? '▼' + f_bars(b15) + s15 : '■' + f_bars(b15) + s15 208 | t16 = a16 == 1 ? '▲' + f_bars(b16) + s16 : a16 == -1 ? '▼' + f_bars(b16) + s16 : '■' + f_bars(b16) + s16 209 | t17 = a17 == 1 ? '▲' + f_bars(b17) + s17 : a17 == -1 ? '▼' + f_bars(b17) + s17 : '■' + f_bars(b17) + s17 210 | t18 = a18 == 1 ? '▲' + f_bars(b18) + s18 : a18 == -1 ? '▼' + f_bars(b18) + s18 : '■' + f_bars(b18) + s18 211 | t19 = a19 == 1 ? '▲' + f_bars(b19) + s19 : a19 == -1 ? '▼' + f_bars(b19) + s19 : '■' + f_bars(b19) + s19 212 | t20 = a20 == 1 ? '▲' + f_bars(b20) + s20 : a20 == -1 ? '▼' + f_bars(b20) + s20 : '■' + f_bars(b20) + s20 213 | 214 | // Return 215 | f_label(0, t00, c00) 216 | f_label(1, t01, c01) 217 | f_label(2, t02, c02) 218 | f_label(3, t03, c03) 219 | f_label(4, t04, c04) 220 | f_label(5, t05, c05) 221 | f_label(6, t06, c06) 222 | f_label(7, t07, c07) 223 | f_label(8, t08, c08) 224 | f_label(9, t09, c09) 225 | f_label(10, t10, c10) 226 | f_label(11, t11, c11) 227 | f_label(12, t12, c12) 228 | f_label(13, t13, c13) 229 | f_label(14, t14, c14) 230 | f_label(15, t15, c15) 231 | f_label(16, t16, c16) 232 | f_label(17, t17, c17) 233 | f_label(18, t18, c18) 234 | f_label(19, t19, c19) 235 | f_label(20, t20, c20) 236 | 237 | -------------------------------------------------------------------------------- /Any Screener: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | 3 | // ╔═══════════════════════════════════════════════════════════╗ 4 | // ║ Author & Developer : © dg_factor [18.07.2023, Istanbul] ║ 5 | // ╚═══════════════════════════════════════════════════════════╝ 6 | 7 | // UYARI 8 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 9 | 10 | // Tradingview linki : 11 | // https://www.tradingview.com/script/6pC1ZQdd-Any-Screener-Multiple/ 12 | 13 | // AÇIKLAMALAR 14 | // Kısaca, çoklu tarayıcı komutudur. 15 | // Tanımlı alım-satım koşullarını 15 farklı sembol için tarayıp hangi koşulun kaç bar önce gerçekleştiğini derleyip sunar. 16 | // Kendi koşullarınızı entegre etmenize olanak sağlayan dinamik bir yapısı vardır. Aşağıdaki linklere göz atabilirsiniz. 17 | // GENEL KULLANIM : https://twitter.com/dg_factor/status/1683150600643461121?s=20 18 | // ENTEGRASYON 1 : https://twitter.com/dg_factor/status/1685325255919730689?s=20 19 | // ENTEGRASYON 2 : https://twitter.com/dg_factor/status/1685985262793302016?s=20 20 | 21 | //@version=5 22 | indicator("Any Screener", overlay=true) 23 | 24 | // ╔═══════════════════════════════════════════════════════════════════════════╗ 25 | // ║ SECTION 1 : INDICATORS ║ 26 | // ╚═══════════════════════════════════════════════════════════════════════════╝ 27 | //{ 28 | // ╠═════════════════════════════════ Inputs ══════════════════════════════════╣ 29 | 30 | // Tooltips 31 | string tt_per = 32 | "When the percentage is 0.0,\n" + 33 | "OTT is disabled and the signals are generated by the crossing of the closing price and the selected moving average." 34 | string tt_osc = 35 | "This option disables sequential signals in the same direction.\n" + 36 | "ON : The Scanner shows how many bars have passed since the direction changed.\n" + 37 | "OFF : The Scanner shows how many bars have passed since the last signal." 38 | string tt_volt = 39 | "BANDWIDTH and REGRESSION have been normalized. (For all time chart)" 40 | // 41 | string gr_ott = "╠═══════════════ OTT ═══════════════╣" 42 | mov_type = input.string(title="Type", defval="VAR", options=["SMA", "EMA", "EVWMA", "HULL", "VAR"], group=gr_ott) 43 | ott_len = input.int(title="Length ", defval=50, group=gr_ott) 44 | ott_per = input.float(title="Percent ", defval=2.5, group=gr_ott, tooltip=tt_per) 45 | ott_sign = input.bool(title="Show Signals", defval=false, group=gr_ott) 46 | string gr_sar = "╠══════════════ PSAR ════════════════╣" 47 | sar_start = input.float(title="Start ", defval=0.02, group=gr_sar) 48 | sar_inc = input.float(title="Increment ", defval=0.02, group=gr_sar) 49 | sar_max = input.float(title="Max", defval=0.2, group=gr_sar) 50 | sar_sign = input.bool(title="Show Signals", defval=false, group=gr_sar) 51 | string gr_osc = "╠════════════ OSCILLATOR ════════════╣" 52 | osc_type = input.string(title="Type", defval="MFI", options=["MFI", "RSI", "STOCH"], group=gr_osc) 53 | osc_len = input.int(title="Length ", defval=14, group=gr_osc) 54 | osc_os = input.int(title="Over Sold", defval=30, group=gr_osc) 55 | osc_ob = input.int(title="Over Bought", defval=70, group=gr_osc) 56 | osc_pyr = input.bool(title="Avoid Pyramiding", defval=true, group=gr_osc, tooltip=tt_osc) 57 | osc_sign = input.bool(title="Show Signals", defval=false, group=gr_osc) 58 | string gr_volt = "╠══════════ VOLATILITY & TREND ══════════╣" 59 | volt_type = input.string(title="Type", defval="REG-N", options=["ADX", "BBW-N", "REG-N"], group=gr_volt, tooltip=tt_volt) 60 | volt_len = input.int(title="Length ", defval=14, group=gr_volt) 61 | // 62 | 63 | // ╠════════════════════════════════ Functions ════════════════════════════════╣ 64 | 65 | // Hull Moving Average [HULL] 66 | f_hull(series float x, series int y) => 67 | a = y == 1 ? 1 : y / 2 68 | b = 2 * ta.wma(x, a) - ta.wma(x, y) 69 | r = ta.wma(b, math.round(math.sqrt(y))) 70 | // 71 | 72 | // Elastic Volume Weighted Moving Average [EVWMA] 73 | f_evwma(series float x, series int y) => 74 | a = ta.sma(x, y) 75 | b = math.sum(volume, y) 76 | r = 0.0, r := na(r[1]) ? a : nz(r[1]) * (b - volume) / b + volume * x / b 77 | // 78 | 79 | // Variable Index Dynamic Adaptive Moving Average [VAR] 80 | f_var(series float x, series int y) => 81 | a = ta.sma(x, y) 82 | b = math.abs(ta.change(x, 9)) 83 | c = math.sum(math.abs(ta.change(x)), 9) 84 | d = c != 0 ? b / c : 0 85 | e = 2 / (y + 1) 86 | r = 0.0, r := na(r[1]) ? a : d * e * (x - nz(r[1])) + nz(r[1]) 87 | // 88 | 89 | // Moving Average 90 | f_mov(simple string x, series float y, simple int z) => 91 | x == "SMA" ? ta.sma(y, z) : 92 | x == "EMA" ? ta.ema(y, z) : 93 | x == "EVWMA" ? f_evwma(y, z) : 94 | x == "HULL" ? f_hull(y, z) : 95 | x == "VAR" ? f_var(y, z) : na 96 | // 97 | 98 | // Optimized Trend Tracker 99 | f_ott(series float x, series float y) => 100 | a = y / 100 101 | b = x * a, c = x - b, d = x + b 102 | c := c > nz(c[1]) or x < nz(c[1]) ? c : nz(c[1]) 103 | d := d < nz(d[1]) or x > nz(d[1]) ? d : nz(d[1]) 104 | e = 0.0, e := x > nz(e[1]) ? c : x < nz(e[1]) ? d : nz(e[1]) 105 | f = 1 + a / 2 106 | g = 1 - a / 2 107 | h = x > e ? e * f : e * g 108 | r = nz(h[2]) 109 | // 110 | 111 | // Oscillator 112 | f_osc(simple string x, simple int y) => 113 | x == "MFI" ? ta.mfi(hlc3, y) : 114 | x == "RSI" ? ta.rsi(close, y) : 115 | x == "STOCH" ? ta.stoch(close, high, low, y) : na 116 | // 117 | 118 | // Volatility 119 | f_volt(simple string x, simple int y) => 120 | [_, _, a] = ta.dmi(y, y) 121 | b = ta.bbw(close, y, 2) 122 | c = math.sqrt(ta.sma(math.pow(close - ta.linreg(close, y, 0), 2), y)) 123 | r = 124 | x == "ADX" ? a : 125 | x == "BBW-N" ? (b - ta.min(b)) / (ta.max(b) - ta.min(b)) * 100 : 126 | x == "REG-N" ? (c - ta.min(c)) / (ta.max(c) - ta.min(c)) * 100 : 127 | na 128 | // 129 | 130 | // ╠═══════════════════════════════════ Out ═══════════════════════════════════╣ 131 | 132 | // Return 133 | _sup = f_mov(mov_type, close, ott_len) 134 | _ott = f_ott(_sup, ott_per) 135 | _sar = ta.sar(sar_start, sar_inc, sar_max) 136 | _osc = f_osc(osc_type, osc_len) 137 | osc_l = ta.crossover(_osc, osc_os) 138 | osc_s = ta.crossunder(_osc, osc_ob) 139 | osc_bl = ta.barssince(osc_l) < ta.barssince(osc_s) 140 | osc_bs = ta.barssince(osc_l) > ta.barssince(osc_s) 141 | _volt = f_volt(volt_type, volt_len) 142 | 143 | // ╠════════════════════════════ Data For Screener ════════════════════════════╣ 144 | 145 | // Long Conditions 146 | long_1 = ott_per != 0.0 ? ta.crossover(_sup, _ott) : ta.crossover(close, _sup) 147 | long_2 = ta.crossover(close, _sar) 148 | long_3 = not osc_pyr ? osc_l : ta.cum(osc_l ? 1 : na) == 1 or osc_bl and (osc_bs[1] or not osc_bl[1]) 149 | 150 | // Short Conditions 151 | short_1 = ott_per != 0.0 ? ta.crossunder(_sup, _ott) : ta.crossunder(close, _sup) 152 | short_2 = ta.crossunder(close, _sar) 153 | short_3 = not osc_pyr ? osc_s : ta.cum(osc_s ? 1 : na) == 1 or osc_bs and (osc_bl[1] or not osc_bs[1]) 154 | 155 | // Text Only 156 | text_only = _volt 157 | 158 | // Titles are required for the table 159 | string title_1 = ott_per != 0.0 ? "OTT" : mov_type 160 | string title_2 = "PSAR" 161 | string title_3 = osc_type 162 | string title_4 = volt_type 163 | 164 | // ╠══════════════════════════════ Plot Signals ═══════════════════════════════╣ 165 | 166 | sl = shape.triangleup, ss = shape.triangledown, 167 | ll = location.belowbar, ls = location.abovebar, 168 | sz = size.tiny, cl = #00bb00, cs = #bb0000 169 | 170 | plotshape(ott_sign ? ott_per != 0.0 and long_1 : na, "OTT Long", sl, ll, cl, text="OTT\nLong", textcolor=cl, size=sz) 171 | plotshape(ott_sign ? ott_per != 0.0 and short_1 : na, "OTT Short", ss, ls, cs, text="OTT\nShort", textcolor=cs, size=sz) 172 | plotshape(ott_sign ? ott_per == 0.0 and long_1 : na, "MA Long", sl, ll, cl, text="MA\nLong", textcolor=cl, size=sz) 173 | plotshape(ott_sign ? ott_per == 0.0 and short_1 : na, "MA Short", ss, ls, cs, text="MA\nShort", textcolor=cs, size=sz) 174 | plotshape(sar_sign ? long_2 : na, "PSAR Long", sl, ll, cl, text="PSAR\nLong", textcolor=cl, size=sz) 175 | plotshape(sar_sign ? short_2 : na, "PSAR Short", ss, ls, cs, text="PSAR\nShort", textcolor=cs, size=sz) 176 | plotshape(osc_sign ? long_3 : na, "OSC Long", sl, ll, cl, text="OSC\nLong", textcolor=cl, size=sz) 177 | plotshape(osc_sign ? short_3 : na, "OSC Short", ss, ls, cs, text="OSC\nShort", textcolor=cs, size=sz) 178 | //} 179 | // ╔═══════════════════════════════════════════════════════════════════════════╗ 180 | // ║ SECTION 2 : SCREENER ║ 181 | // ╚═══════════════════════════════════════════════════════════════════════════╝ 182 | //{ 183 | // The "SCREENER" section has been prepared in a way that can adapt to the variables defined above. 184 | // Delete the Section 1 and code your own conditions and titles : 185 | // (long_1, short_1, long_2, short_2, long_3, short_3, text_only) & (title_1, title_2, title_3, title_4) 186 | 187 | // ╠═════════════════════════════════ Inputs ══════════════════════════════════╣ 188 | 189 | string gr_sc = "╠═════════════ SCREENER ═════════════╣" 190 | tb_sh = input.bool(title="Show Table", defval=true, group=gr_sc) 191 | sh_pr = input.bool(title="Show Prefix", defval=false, group=gr_sc) 192 | tb_ps = input.string(title="Position   ", options=["Left", "Right", "Center"], defval="Right", group=gr_sc, inline="p") 193 | tb_sz = input.string(title="Text Size ", options=["Auto", "Small", "Normal", "Large"], defval="Normal", group=gr_sc, inline="s") 194 | col_s = input.color(title="Colours   ", defval=#00a5ba, group=gr_sc, inline="c") // Symbol 195 | col_u = input.color(title="", defval=#00bb00, group=gr_sc, inline="c") // Up (Long) 196 | col_d = input.color(title="", defval=#bb0000, group=gr_sc, inline="c") // Down (Short) 197 | col_n = input.color(title="", defval=#686868, group=gr_sc, inline="c") // Neutral 198 | 199 | string gr_sy = "╠═════════════ SYMBOLS ══════════════╣" 200 | s01 = input.symbol(title="Symbol 01", inline="01", group=gr_sy, defval="BINANCE:BTCUSDT") 201 | s02 = input.symbol(title="Symbol 02", inline='02', group=gr_sy, defval='BINANCE:ETHUSDT') 202 | s03 = input.symbol(title="Symbol 03", inline="03", group=gr_sy, defval="BINANCE:BNBUSDT") 203 | s04 = input.symbol(title="Symbol 04", inline="04", group=gr_sy, defval="BINANCE:ADAUSDT") 204 | s05 = input.symbol(title="Symbol 05", inline="05", group=gr_sy, defval="BINANCE:AVAXUSDT") 205 | s06 = input.symbol(title="Symbol 06", inline="06", group=gr_sy, defval="BINANCE:CHZUSDT") 206 | s07 = input.symbol(title="Symbol 07", inline="07", group=gr_sy, defval="BINANCE:DOGEUSDT") 207 | s08 = input.symbol(title="Symbol 08", inline="08", group=gr_sy, defval="BINANCE:SOLUSDT") 208 | s09 = input.symbol(title="Symbol 09", inline="09", group=gr_sy, defval="BINANCE:TRXUSDT") 209 | s10 = input.symbol(title="Symbol 10", inline="10", group=gr_sy, defval="BINANCE:XRPUSDT") 210 | s11 = input.symbol(title="Symbol 11", inline='11', group=gr_sy, defval='NASDAQ:AAPL') 211 | s12 = input.symbol(title="Symbol 12", inline='12', group=gr_sy, defval='NASDAQ:TSLA') 212 | s13 = input.symbol(title="Symbol 13", inline='13', group=gr_sy, defval='NASDAQ:AMZN') 213 | s14 = input.symbol(title="Symbol 14", inline='14', group=gr_sy, defval='NASDAQ:GOOGL') 214 | s15 = input.symbol(title="Symbol 15", inline='15', group=gr_sy, defval='NASDAQ:NVDA') 215 | 216 | // You can obtain various time frame results by defining inputs equal to the number of symbols to be used in the security function. 217 | string x00 = timeframe.period 218 | 219 | // ╠════════════════════════════════ Functions ════════════════════════════════╣ 220 | 221 | f_data(series bool x, series bool y) => 222 | r1 = 0, r1 := x ? 1 : y ? -1 : r1[1] // direction 223 | r2 = ta.barssince(r1 != nz(r1[1])) // barssince 224 | r3 = r1 == 1 ? col_u : r1 == -1 ? col_d : col_n // color 225 | [r1, r2, r3] 226 | // 227 | 228 | f_screener() => 229 | [x1, y1, z1] = f_data(long_1, short_1) 230 | [x2, y2, z2] = f_data(long_2, short_2) 231 | [x3, y3, z3] = f_data(long_3, short_3) 232 | t = text_only 233 | [x1, x2, x3, y1, y2, y3, z1, z2, z3, t] 234 | // 235 | 236 | // Yön, Bar 237 | f_text(int x, int y) => 238 | r1 = " " 239 | r2 = str.tostring(y) 240 | r3 = x == 1 ? r1 + "▲ [" + r2 + "]" : x == -1 ? r1 + "▼ [" + r2 + "]" : r1 + "■ [" + r2 + "]" 241 | // 242 | 243 | f_prefix(simple string x) => 244 | r = sh_pr ? x : str.substring(x, str.pos(x, ':') + 1) 245 | // 246 | 247 | f_size(simple string x) => 248 | x == "Small" ? size.small : 249 | x == "Normal" ? size.normal : 250 | x == "Large" ? size.large : size.auto 251 | // 252 | 253 | f_position(simple string x) => 254 | x == "Left" ? position.top_left : 255 | x == "Right" ? position.top_right : position.top_center 256 | // 257 | 258 | // ╠════════════════════════════════ Variables ════════════════════════════════╣ 259 | 260 | [a01, b01, c01, d01, e01, f01, g01, h01, i01, j01] = request.security(s01, x00, f_screener()) 261 | [a02, b02, c02, d02, e02, f02, g02, h02, i02, j02] = request.security(s02, x00, f_screener()) 262 | [a03, b03, c03, d03, e03, f03, g03, h03, i03, j03] = request.security(s03, x00, f_screener()) 263 | [a04, b04, c04, d04, e04, f04, g04, h04, i04, j04] = request.security(s04, x00, f_screener()) 264 | [a05, b05, c05, d05, e05, f05, g05, h05, i05, j05] = request.security(s05, x00, f_screener()) 265 | [a06, b06, c06, d06, e06, f06, g06, h06, i06, j06] = request.security(s06, x00, f_screener()) 266 | [a07, b07, c07, d07, e07, f07, g07, h07, i07, j07] = request.security(s07, x00, f_screener()) 267 | [a08, b08, c08, d08, e08, f08, g08, h08, i08, j08] = request.security(s08, x00, f_screener()) 268 | [a09, b09, c09, d09, e09, f09, g09, h09, i09, j09] = request.security(s09, x00, f_screener()) 269 | [a10, b10, c10, d10, e10, f10, g10, h10, i10, j10] = request.security(s10, x00, f_screener()) 270 | [a11, b11, c11, d11, e11, f11, g11, h11, i11, j11] = request.security(s11, x00, f_screener()) 271 | [a12, b12, c12, d12, e12, f12, g12, h12, i12, j12] = request.security(s12, x00, f_screener()) 272 | [a13, b13, c13, d13, e13, f13, g13, h13, i13, j13] = request.security(s13, x00, f_screener()) 273 | [a14, b14, c14, d14, e14, f14, g14, h14, i14, j14] = request.security(s14, x00, f_screener()) 274 | [a15, b15, c15, d15, e15, f15, g15, h15, i15, j15] = request.security(s15, x00, f_screener()) 275 | 276 | // ╠═════════════════════════════════ Return ══════════════════════════════════╣ 277 | 278 | i1_t01 = f_text(a01, d01), i2_t01 = f_text(b01, e01), i3_t01 = f_text(c01, f01), i4_t01 = str.tostring(j01, "#.###") 279 | i1_t02 = f_text(a02, d02), i2_t02 = f_text(b02, e02), i3_t02 = f_text(c02, f02), i4_t02 = str.tostring(j02, "#.###") 280 | i1_t03 = f_text(a03, d03), i2_t03 = f_text(b03, e03), i3_t03 = f_text(c03, f03), i4_t03 = str.tostring(j03, "#.###") 281 | i1_t04 = f_text(a04, d04), i2_t04 = f_text(b04, e04), i3_t04 = f_text(c04, f04), i4_t04 = str.tostring(j04, "#.###") 282 | i1_t05 = f_text(a05, d05), i2_t05 = f_text(b05, e05), i3_t05 = f_text(c05, f05), i4_t05 = str.tostring(j05, "#.###") 283 | i1_t06 = f_text(a06, d06), i2_t06 = f_text(b06, e06), i3_t06 = f_text(c06, f06), i4_t06 = str.tostring(j06, "#.###") 284 | i1_t07 = f_text(a07, d07), i2_t07 = f_text(b07, e07), i3_t07 = f_text(c07, f07), i4_t07 = str.tostring(j07, "#.###") 285 | i1_t08 = f_text(a08, d08), i2_t08 = f_text(b08, e08), i3_t08 = f_text(c08, f08), i4_t08 = str.tostring(j08, "#.###") 286 | i1_t09 = f_text(a09, d09), i2_t09 = f_text(b09, e09), i3_t09 = f_text(c09, f09), i4_t09 = str.tostring(j09, "#.###") 287 | i1_t10 = f_text(a10, d10), i2_t10 = f_text(b10, e10), i3_t10 = f_text(c10, f10), i4_t10 = str.tostring(j10, "#.###") 288 | i1_t11 = f_text(a11, d11), i2_t11 = f_text(b11, e11), i3_t11 = f_text(c11, f11), i4_t11 = str.tostring(j11, "#.###") 289 | i1_t12 = f_text(a12, d12), i2_t12 = f_text(b12, e12), i3_t12 = f_text(c12, f12), i4_t12 = str.tostring(j12, "#.###") 290 | i1_t13 = f_text(a13, d13), i2_t13 = f_text(b13, e13), i3_t13 = f_text(c13, f13), i4_t13 = str.tostring(j13, "#.###") 291 | i1_t14 = f_text(a14, d14), i2_t14 = f_text(b14, e14), i3_t14 = f_text(c14, f14), i4_t14 = str.tostring(j14, "#.###") 292 | i1_t15 = f_text(a15, d15), i2_t15 = f_text(b15, e15), i3_t15 = f_text(c15, f15), i4_t15 = str.tostring(j15, "#.###") 293 | 294 | // ╠═══════════════════════════════ Info Panel ════════════════════════════════╣ 295 | 296 | string sp = " " 297 | var table tb = table.new(position=f_position(tb_ps), columns=6, rows=20) 298 | f_print(x, y, z, p, q) => 299 | table.cell(tb, x, y+1, q, text_color=z, text_halign=p == "" ? text.align_left : text.align_center, text_size=f_size(tb_sz)) 300 | if barstate.islast and tb_sh 301 | 302 | f_print(0, -1, col_s, "", ""), f_print(0, 0, col_s, "", "") 303 | f_print(1, -1, col_s, "", ""), f_print(1, 0, col_s, "c", sp + title_1) 304 | f_print(2, -1, col_s, "", ""), f_print(2, 0, col_s, "c", sp + title_2) 305 | f_print(3, -1, col_s, "", ""), f_print(3, 0, col_s, "c", sp + title_3) 306 | f_print(4, -1, col_s, "", ""), f_print(4, 0, col_s, "c", sp + title_4) 307 | 308 | f_print(0, 1, col_s, "", f_prefix(s01)), f_print(1, 1, g01, "", i1_t01) 309 | f_print(0, 2, col_s, "", f_prefix(s02)), f_print(1, 2, g02, "", i1_t02) 310 | f_print(0, 3, col_s, "", f_prefix(s03)), f_print(1, 3, g03, "", i1_t03) 311 | f_print(0, 4, col_s, "", f_prefix(s04)), f_print(1, 4, g04, "", i1_t04) 312 | f_print(0, 5, col_s, "", f_prefix(s05)), f_print(1, 5, g05, "", i1_t05) 313 | f_print(0, 6, col_s, "", f_prefix(s06)), f_print(1, 6, g06, "", i1_t06) 314 | f_print(0, 7, col_s, "", f_prefix(s07)), f_print(1, 7, g07, "", i1_t07) 315 | f_print(0, 8, col_s, "", f_prefix(s08)), f_print(1, 8, g08, "", i1_t08) 316 | f_print(0, 9, col_s, "", f_prefix(s09)), f_print(1, 9, g09, "", i1_t09) 317 | f_print(0, 10, col_s, "", f_prefix(s10)), f_print(1, 10, g10, "", i1_t10) 318 | f_print(0, 11, col_s, "", f_prefix(s11)), f_print(1, 11, g11, "", i1_t11) 319 | f_print(0, 12, col_s, "", f_prefix(s12)), f_print(1, 12, g12, "", i1_t12) 320 | f_print(0, 13, col_s, "", f_prefix(s13)), f_print(1, 13, g13, "", i1_t13) 321 | f_print(0, 14, col_s, "", f_prefix(s14)), f_print(1, 14, g14, "", i1_t14) 322 | f_print(0, 15, col_s, "", f_prefix(s15)), f_print(1, 15, g15, "", i1_t15) 323 | 324 | f_print(2, 1, h01, "", i2_t01), f_print(3, 1, i01, "", i3_t01), f_print(4, 1, col_n, "", sp + i4_t01) 325 | f_print(2, 2, h02, "", i2_t02), f_print(3, 2, i02, "", i3_t02), f_print(4, 2, col_n, "", sp + i4_t02) 326 | f_print(2, 3, h03, "", i2_t03), f_print(3, 3, i03, "", i3_t03), f_print(4, 3, col_n, "", sp + i4_t03) 327 | f_print(2, 4, h04, "", i2_t04), f_print(3, 4, i04, "", i3_t04), f_print(4, 4, col_n, "", sp + i4_t04) 328 | f_print(2, 5, h05, "", i2_t05), f_print(3, 5, i05, "", i3_t05), f_print(4, 5, col_n, "", sp + i4_t05) 329 | f_print(2, 6, h06, "", i2_t06), f_print(3, 6, i06, "", i3_t06), f_print(4, 6, col_n, "", sp + i4_t06) 330 | f_print(2, 7, h07, "", i2_t07), f_print(3, 7, i07, "", i3_t07), f_print(4, 7, col_n, "", sp + i4_t07) 331 | f_print(2, 8, h08, "", i2_t08), f_print(3, 8, i08, "", i3_t08), f_print(4, 8, col_n, "", sp + i4_t08) 332 | f_print(2, 9, h09, "", i2_t09), f_print(3, 9, i09, "", i3_t09), f_print(4, 9, col_n, "", sp + i4_t09) 333 | f_print(2, 10, h10, "", i2_t10), f_print(3, 10, i10, "", i3_t10), f_print(4, 10, col_n, "", sp + i4_t10) 334 | f_print(2, 11, h11, "", i2_t11), f_print(3, 11, i11, "", i3_t11), f_print(4, 11, col_n, "", sp + i4_t11) 335 | f_print(2, 12, h12, "", i2_t12), f_print(3, 12, i12, "", i3_t12), f_print(4, 12, col_n, "", sp + i4_t12) 336 | f_print(2, 13, h13, "", i2_t13), f_print(3, 13, i13, "", i3_t13), f_print(4, 13, col_n, "", sp + i4_t13) 337 | f_print(2, 14, h14, "", i2_t14), f_print(3, 14, i14, "", i3_t14), f_print(4, 14, col_n, "", sp + i4_t14) 338 | f_print(2, 15, h15, "", i2_t15), f_print(3, 15, i15, "", i3_t15), f_print(4, 15, col_n, "", sp + i4_t15) 339 | //} 340 | // ╠══════════════════════════════════ Bitti ══════════════════════════════════╣ 341 | 342 | plotshape(barstate.isfirst, "@ dg_factor", color=#13172200, editable=false) 343 | -------------------------------------------------------------------------------- /Backtesting Module (Info): -------------------------------------------------------------------------------- 1 | © dg_factor [16.12.2023] 2 | 3 | 📢 'Backtesting Module' Tradingview'da yayınlandı! 4 | 5 | İndikatör Linki : 6 | https://tr.tradingview.com/script/uLY2TQdm/ 7 | 8 | Video : 9 | https://www.youtube.com/watch?v=vFAlz3MgsR4 10 | 11 | Tanım : 12 | Bu script alım-satım sinyallerinize adapte olabilen basit ve etkili bir strategy() komutudur. 13 | Belirttiğiniz giriş ve çıkış inputlarına bağlı olarak backtest raporunuzu oluşturur. 14 | 15 | Ne işe yarar? 16 | Sadece bir sistemi test etmek için kullanılabileceği gibi, birbirinden bağımsız sinyalleri tek bir sistemde birleştirmek için de kullanılabilir! 17 | Böylece karmaşık stratejilerin başarısını raporlamak mümkün hale gelir. 18 | 19 | Nasıl Çalışır? 20 | Test etmek istediğiniz sistemin boolean giriş ve çıkış koşullarını integer türünde tanımlayın ve modülde kaynak olarak kullanın. 21 | 22 | Geliştirmler 23 | Sonraki versiyonlarda filtreler ve risk yönetimi gibi uygulamalar da gelebilir. Çünkü "eat the rich!" 🍺 24 | -------------------------------------------------------------------------------- /BarScope: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // © dg_factor [03.09.2023] 3 | 4 | // UYARI 5 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 6 | 7 | // TANIM 8 | // Aşağıdaki komut dosyası farklı bar kombinasyonlarından doğan sinyallerin üretilmesine örnek teşkil eder. 9 | // "Şu kadar bar düşüşten veya yükselişten sonra, şu kadar bar düşüş veya yükseliş olursa" koşulunu derlemek amacıyla hazırlanmıştır. 10 | 11 | // HESAPLAMA 12 | // math.sum(kosul ? 1 : 0, x) == x 13 | // Yukarıdaki yapı "herhangi bir koşul son kaç ardışık bardır gerçekleşiyor?" sorusunu cevaplar. 14 | // Koşul her gerçekleştiğinde fonksiyon 1 değeri üretir ve bu değerleri toplar. 15 | // Eğer toplam sonuç x ise koşul son x bardır gerçekleşmiş demektir. 16 | 17 | // GELİŞTİRMELER 18 | // İndikatör, iki koşullu kesintisiz yükseliş veya düşüleri kombine eder. Hesaplama mantığı izlenerek koşul sayısı arttırılabilir. 19 | // Üretilen sinyal, giriş veya çıkış koşulu olarak kurgulanabilir. 20 | // Uygun değiştirmeler yapılarak giriş ve çıkış aralığı (koşulun geçerli olduğu bar aralığı) tanımlanabilir. 21 | // Hesaplama doğrudan sinyal olarak ele alınabileceği gibi, sinyal filtreleme için de kullanılabilir. 22 | 23 | // NOT 24 | // Kutular, koşulların ardışık gerçekleşmesi halinde iç-içe geçmiş biçimde görünür. Her bir kutu için max uzunluk (n1+n2)'dir. 25 | 26 | //@version=5 27 | indicator("BarScope", overlay=true, max_boxes_count=499) 28 | 29 | n1 = input.int(title="Bar ", defval=5, minval=0, inline="1") 30 | d1 = input.string(title="   Direction", options=["Up", "Down"], defval="Down", inline="1") 31 | 32 | n2 = input.int(title="Bar ", defval=3, minval=0, inline="2") 33 | d2 = input.string(title="   Direction", options=["Up", "Down"], defval="Up", inline="2") 34 | 35 | c1 = d1 == "Up" ? close > open : close < open 36 | c2 = d2 == "Up" ? close > open : close < open 37 | 38 | sonuc = 39 | d1 == d2 ? math.sum(c1 ? 1 : 0, n1 + n2) == n1 + n2 : 40 | n1 == 0 ? math.sum(c2 ? 1 : 0, n2) == n2 : 41 | n2 == 0 ? math.sum(c1 ? 1 : 0, n1) == n1 : 42 | math.sum(c1 ? 1 : 0, n1 + n2) == n1 and math.sum(c2 ? 1 : 0, n2) == n2 43 | // 44 | 45 | plotshape(sonuc, "sonuc", shape.xcross, location.belowbar, color=#00BCD4, size=size.small) 46 | 47 | // Table 48 | var t = table.new(position.top_right, 1, 2) 49 | s1 = d1 == "Up" ? "yükseliş" : "düşüş" 50 | s2 = d2 == "Up" ? "yükseliş" : "düşüş" 51 | if barstate.islast 52 | table.cell(t, 0, 0, "") 53 | table.cell(t, 0, 1, str.tostring(n1) + " bar " + s1 + " ardından " + str.tostring(n2) + " bar " + s2, text_color=#00BCD4) 54 | // 55 | 56 | // Box 57 | ust = ta.highest(n1 + n2) 58 | alt = ta.lowest(n1 + n2) 59 | gor = sonuc ? box.new(bar_index - n1 - n2 + 1, ust, bar_index, alt, xloc=xloc.bar_index, border_color= na, bgcolor=#00BCD440, border_style=line.style_solid) : na 60 | -------------------------------------------------------------------------------- /Calculator - Binom Dağılımı: -------------------------------------------------------------------------------- 1 | // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // © dg_factor [19.07.2024] 3 | 4 | // AÇIKLAMA 5 | // Diyelim ki iyi getiri sağladığını düşündüğünüz bir alım-satım sisteminiz var. 6 | // Backtesti yaptınız ve sisteminizin başarısını ölçebilen bir metrik elde ettiniz. 7 | // Örneğin bu metrik WinRate olsun. (Başarı Yüzdesi : Başarılı işlem sayısının toplam işlem sayısına oranıdır.) 8 | // Bu strateji ile 100 tane işleme girmeyi düşünüyorsunuz. 9 | // Bu 100 işlemden N tanesindeki minimum ve maksimum başarı olasılığını işlemlere başlamadan önce nasıl hesaplayacaksınız? 10 | // Bu indikatör yukarıdaki soruya cevap verme arayışıyla hazırlanan basit bir hesap makinesidir. 11 | 12 | // NOT 13 | // Stratejinizin genel başarısını farklı metriklerle de ölçebilirsiniz, WinRate sık kullanılan bir argüman olduğu için seçildi. 14 | // Farklı metrikler seçerken 0-100 arasında bir değer almasına dikkat ediniz. 15 | 16 | // KAVRAMLAR 17 | // Bernoulli Deneyi: 18 | // Tek bir denemede sadece iki olası sonucu olan bir olayın gerçekleşmesini ifade eden deney türüdür. 19 | // (Herhangi bir işlem ya başarıyla sonuçlanır ya da başarısız olur. Yüzdesel Win Rate bir backtest çıktısıdır.) 20 | // Binom Dağılımı: 21 | // Bernoulli deneyinin belirli bir sayıda (n defa) tekrarlanması durumunda, başarılı sonuç sayısının olasılık dağılımını gösterir. 22 | // (Yeni bir işlem serisinin başlatılması halinde Win Rate'in bu işlem serisindeki olasılık dağılımını hesaplamak için kullanılır.) 23 | // Kümülatif Binom Dağılımı: 24 | // Binom dağılımının birikimli halidir. 25 | // Bu dağılım, belirli bir sayıda denemede, başarı sayısının belirli bir değere eşit veya küçük (en fazla) ya da eşit veya büyük (en az) olma olasılığını hesaplamak için kullanılır. 26 | // (Bu yöntem, işlem serisindeki olasılık dağılımını minimum ve maksimum değerleri içerecek şekilde hesaplamak için kullanılır.) 27 | 28 | //@version=5 29 | indicator("Calculator - Binom Dağılımı", overlay=true) 30 | 31 | // Factorial 32 | f_factorial(n) => 33 | r = 1 34 | for i = 1 to n 35 | r := n == 0 ? 1 : r * i 36 | r 37 | // 38 | 39 | // Combination 40 | f_combination(n, x) => 41 | f_factorial(n) / (f_factorial(x) * f_factorial(n - x)) 42 | // 43 | 44 | // Binomial Distrubition 45 | f_binom(p, n, k) => 46 | f_combination(n, k) * math.pow(p, k) * math.pow(1 - p, n - k) 47 | // 48 | 49 | tt_p = "Stratejinin backtestinde elde edilen ve başarı olasılığını tanımlayan yüzdesel değerdir. 0-100 arasında değer alabilen herhangi bir metrik kullanılabilir. Örneğin WinRate (Başarılı işlem sayısının toplam işlem sayısına oranıdır)." 50 | tt_n = "Bu strateji ile gelecekte gerçekleştirilmesi planlanan toplam işlem sayısıdır." 51 | tt_k = "Olasılık sonucunun hesaplanacağı (gerçekleştirilmesi hedeflenen) başarılı işlem sayısıdır." 52 | p = input.float(37.5, "Başarı Oranı %", tooltip=tt_p) / 100. 53 | n = input.int(100, "Toplam İşlem Sayısı", maxval=100, tooltip=tt_n) 54 | k = input.int(40, "Hedef İşlem Sayısı", maxval=100, tooltip=tt_k) 55 | 56 | // Başarı Olasılığı 57 | basarili = f_binom(p, n, k) 58 | min_basarili = 0.0 59 | max_basarili = 0.0 60 | for i = 0 to k - 1 61 | min_basarili += f_binom(p, n, i) 62 | min_basarili := 1 - min_basarili 63 | for i = 0 to k 64 | max_basarili += f_binom(p, n, i) 65 | // standart_sapma = math.sqrt(n * p * q) // Ortalama başarıdan sapmayı ifade eder. Varyansın kareköküdür. 66 | 67 | // Text 68 | _k = str.tostring(k) 69 | rate = "Başarı oranı " + "%" + str.tostring(p * 100) + " olan bir stratejinin, " 70 | go = "gerçekleştireceği " + str.tostring(n) + " işlemden;" 71 | win = " ✔ " + _k + " tanesinde başarılı olma olasılığı : %" + str.tostring(basarili * 100, "#.######") 72 | min_win = " ✔ " + "En az " + _k + " tanesinde başarılı olma olasılığı : %" + str.tostring(min_basarili * 100, "#.######") 73 | max_win = " ✔ " + "En fazla " + _k + " tanesinde başarılı olma olasılığı : %" + str.tostring(max_basarili * 100, "#.######") 74 | 75 | txt = 76 | "\n\n" + 77 | rate + "\n\n" + 78 | go + "\n\n" + 79 | win + "\n\n" + 80 | min_win + "\n\n" + 81 | max_win 82 | // 83 | 84 | var tb = table.new(position.top_right, 1, 1) 85 | if barstate.islast 86 | table.cell(tb, 0, 0, txt, text_color=color.aqua, text_halign=text.align_left) 87 | // 88 | -------------------------------------------------------------------------------- /Calculator - Financial Math: -------------------------------------------------------------------------------- 1 | © dg_factor [24.02.2024] 2 | 3 | Financial Math indikatörü girilen inputlara bağlı olarak Basit Getiri, Birleşik Getiri ve Anüite sonuçlarını üreten bir hesap makinesidir. 4 | 5 | İndikatör Linki : 6 | https://tr.tradingview.com/script/TmXRmQkJ/ 7 | -------------------------------------------------------------------------------- /Calculator - Negatif Binom Dağılımı: -------------------------------------------------------------------------------- 1 | // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // © dg_factor [19.07.2024] 3 | 4 | //@version=5 5 | indicator("Calculator - Negatif Binom Dağılımı", overlay=true) 6 | 7 | // AÇIKLAMA 8 | // Diyelim ki iyi getiri sağladığını düşündüğünüz bir alım-satım sisteminiz var. 9 | // Backtesti yaptınız ve sisteminizin başarısını ölçebilen bir metrik elde ettiniz. 10 | // Örneğin bu metrik WinRate olsun. (Başarı Yüzdesi : Başarılı işlem sayısının toplam işlem sayısına oranıdır.) 11 | // Bu strateji ile işlemlere girmeyi düşünüyorsunuz. 12 | // Bu işlemlerden n. başarılı işlemin k. işlem olma olasılığını işlemlere başlamadan önce nasıl hesaplayacaksınız? 13 | // Bu indikatör yukarıdaki soruya cevap verme arayışıyla hazırlanan basit bir hesap makinesidir. 14 | 15 | // Factorial 16 | f_factorial(n) => 17 | r = 1 18 | for i = 1 to n 19 | r := n == 0 ? 1 : r * i 20 | r 21 | // 22 | 23 | // Combination 24 | f_combination(n, x) => 25 | f_factorial(n) / (f_factorial(x) * f_factorial(n - x)) 26 | // 27 | 28 | // Negative Binomial Distrubition 29 | f_nth_win_is_kth(p, n, k) => 30 | f_combination(k - 1, n - 1) * math.pow(p, n) * math.pow(1 - p, k - n) 31 | // 32 | 33 | f_nth_win_is_before_kth(p, n, k) => 34 | x = 0.0 35 | for i = 0 to n - 1 36 | x += f_combination(k - 1, i) * math.pow(p, i) * math.pow(1 - p, k - 1 - i) 37 | r = 1 - x 38 | // 39 | 40 | tt_p = "Stratejinin backtestinde elde edilen ve başarı olasılığını tanımlayan yüzdesel değerdir. 0-100 arasında değer alabilen herhangi bir metrik kullanılabilir. Örneğin WinRate (Başarılı işlem sayısının toplam işlem sayısına oranıdır)." 41 | tt_n = "Girilen tamsayı değeri bir işlem numarasını temsil eder. Başarılı işlemler arasındaki baştan x. işlem anlamını taşır." 42 | tt_k = "Girilen tamsayı değeri bir işlem numarasını temsil eder. Gerçekleştirilen bütün işlemler içindeki baştan x. işlem anlamını taşır." 43 | p = input.float(37.5, "Başarı Oranı %", tooltip=tt_p) / 100. 44 | n = input.int(5, "Başarılı İşlem No", maxval=100, tooltip=tt_n) 45 | k = input.int(12, "Hedef İşlem No", maxval=100, tooltip=tt_k) 46 | 47 | nth_win_is_kth = f_nth_win_is_kth(p, n, k) 48 | nth_win_is_before_kth = f_nth_win_is_before_kth(p, n, k) 49 | nth_win_is_after_kth = 1 - nth_win_is_kth - nth_win_is_before_kth 50 | 51 | // Text 52 | rate = "Başarı oranı " + "%" + str.tostring(p * 100) + " olan bir stratejiyle gerçekleştirilecek olan işlemlerde;" 53 | t_nth_win_is_kth = " ✔ " + str.tostring(n) + ". başarılı işlemin " + str.tostring(k) +". işlem olma olasılığı : %" + str.tostring(nth_win_is_kth * 100, "#.######") 54 | t_nth_win_is_before_kth = " ✔ " + str.tostring(n) + ". başarılı işlemin " + str.tostring(k) +". işlemden önce gerçekleşme olasılığı : %" + str.tostring(nth_win_is_before_kth * 100, "#.######") 55 | t_nth_win_is_after_kth = " ✔ " + str.tostring(n) + ". başarılı işlemin " + str.tostring(k) +". işlemden sonra gerçekleşme olasılığı : %" + str.tostring(nth_win_is_after_kth * 100, "#.######") 56 | 57 | txt = 58 | "\n\n" + 59 | rate + "\n\n" + 60 | t_nth_win_is_kth + "\n\n" + 61 | t_nth_win_is_before_kth + "\n\n" + 62 | t_nth_win_is_after_kth 63 | // 64 | 65 | var tb = table.new(position.top_right, 1, 1) 66 | if barstate.islast 67 | table.cell(tb, 0, 0, txt, text_color=color.aqua, text_halign=text.align_left) 68 | // 69 | -------------------------------------------------------------------------------- /Calculator - PnL Report: -------------------------------------------------------------------------------- 1 | © dg_factor [25.02.2024] 2 | 3 | PnL Report indikatörü girilen inputlara göre herhangi bir işlemdeki PnL raporunuzu oluşturan bir hesap makinesidir. 4 | 5 | İndikatör Linki : 6 | https://tr.tradingview.com/script/9mIFnsvO/ 7 | -------------------------------------------------------------------------------- /Calculator - Position Tool (Risk Yönetimi): -------------------------------------------------------------------------------- 1 | © dg_factor [25.02.2024] 2 | 3 | Position Tool indikatörü risk yönetimi, auto kaldıraç ve hata denetimi üzerine kurulu gelişkin bir uygulamadır. 4 | 5 | NELER YAPABİLİR? 6 | ✔ Klasik R sistemi üzerine kurulu risk yönetimini modeller. 7 | ✔ İşleme gireceğiniz tutarı (marjin) hesaplar. 8 | ✔ Kaldıracı otomatik olarak (beş farklı seviye tercihiyle birlikte) hesaplar. 9 | ✔ Manuel olarak kaldıraç seviyenizi kendiniz de belirleyebilirsiniz. 10 | ✔ İşlem masraflarınızı (komisyon) hesaplar. 11 | ✔ Kâr ve zarar senaryolarının bakiyenize olan etkisini (komisyonu da dahil ederek) hesaplar. 12 | ✔ Hata denetimi yapabilir! Risk yönetiminde üç temel hata türü vardır; Marjin hatası, Maksimum Zarar hatası ve Likidasyon hatası. Bu hatalar kullanıcı kaynaklı yanlış parametre kombinasyonlarından doğar. İndikatör mevcut hataları tespit eder ve nasıl giderebileceğinizi (alternatif çözümleri listeleyerek) raporlar. Hatalar tamamen giderilene kadar sizi yönlendirir. 13 | ✔ Total kârlılık için gereken minimum başarılı işlem yüzdesini hesaplar. 14 | ✔ Ve bütün bunları bir tablo halinde size sunar! 15 | ✔ Bonus : Mevcut pozisyonu isteğe bağlı olarak grafikte çizdirebilirsiniz. Fiyat ve tarih seviyelerini grafik üzerindeki çizgileri kaydırarak kolayca değiştirebilirsiniz. 16 | 17 | İndikatör Linki : 18 | https://tr.tradingview.com/script/lodugQu6/ 19 | -------------------------------------------------------------------------------- /Degreed Tillson Moving Average: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | 3 | // Creator: Tim Tillson (T3 Moving Average) 4 | // Author: © dg_factor [09.12.2021] 5 | 6 | // UYARI 7 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 8 | 9 | // AÇIKLAMALAR 10 | // Orijinal hasaplamalara sadık kalınarak farklı derecelerde (1-5) binom açılımları uygulandı. 11 | // EMA dahil, toplamda yedi farklı hareketli ortalama türü üzerinde çalışabilen dinamik bir yapı inşa edildi. 12 | // Derece ve ortalama türü, opsiyonel birer parametre olarak kullanıcı tercihine sunuldu. 13 | // Diğer detaylar en aşağıda. 14 | 15 | //@version=5 16 | indicator(title='Degreed Tillson Moving Average', overlay=true) 17 | 18 | // Inputs 19 | src = close 20 | length = input(title='Length', defval=200) 21 | factor = input.float(title='Factor', defval=0.7, step=0.1) 22 | degree = input.int(title='Degree', minval=1, maxval=5, defval=3, tooltip='1-5', group="DEGREE & TYPE") 23 | ma_type = input.string(title="Type", defval="EMA", options=["EMA", "RMA", "EVMA", "GAUS", "HULLT", "MCGD", "TSF"], group="DEGREE & TYPE") 24 | 25 | // MA Functions 26 | 27 | // EVMA [Elastic Volume Weighted Moving Average] 28 | f_evma(data, u1) => 29 | x = ta.sma(data, u1) 30 | a = math.sum(volume, u1) 31 | r = 0.0 32 | r := na(r[1]) ? x : nz(r[1]) * (a - volume) / a + volume * data / a 33 | // 34 | 35 | // GAUS [Ehlers - Gaussian Filter] 36 | f_gaus(data, u1) => 37 | a = (1 - math.cos(2 * math.pi / u1)) / (math.sqrt(2) - 1) 38 | b = -a + math.sqrt(math.pow(a, 2) + 2 * a) 39 | r = 0.0 40 | r := na(r[1]) ? data : math.pow(b, 2) * data + 2 * (1 - b) * nz(r[1]) - math.pow(1 - b, 2) * nz(r[2]) 41 | // 42 | 43 | // HULLT [Triple Hull Moving Average] 44 | f_hullt(data, u1) => 45 | a = u1 < 3 ? 1 : u1 / 2 46 | b = u1 < 3 ? 1 : u1 / 3 47 | r = ta.wma(ta.wma(data, b) * 3 - ta.wma(data, a) - ta.wma(data, u1), u1) 48 | // 49 | 50 | // MCGD [McGinley Dynamic Moving Average] 51 | f_mcgd(data, u1) => 52 | a = ta.ema(data, u1) 53 | r = 0.0 54 | r := na(r[1]) ? a : r[1] + (data - r[1]) / (u1 * math.pow(data / r[1], 4)) 55 | // 56 | 57 | // TSF [Time Series Function] 58 | f_tsf(data, u1) => 59 | 2 * ta.linreg(data, u1, 0) - ta.linreg(data, u1, 1) 60 | 61 | // MA Return 62 | f_ma(data, u1) => 63 | ma_type == "EMA" ? ta.ema(data, u1) : 64 | ma_type == "EVMA" ? f_evma(data, u1) : 65 | ma_type == "GAUS" ? f_gaus(data, u1) : 66 | ma_type == "HULLT" ? f_hullt(data, u1) : 67 | ma_type == "MCGD" ? f_mcgd(data, u1) : 68 | ma_type == "RMA" ? ta.rma(data, u1) : 69 | ma_type == "TSF" ? f_tsf(data, u1) : 70 | na 71 | // 72 | 73 | // Variables 74 | x = factor 75 | y = factor + 1 76 | z = f_ma(src, length) 77 | n = f_ma(z, length) 78 | 79 | 80 | // Degreed Tillson MA Functions 81 | 82 | d1(src, length) => 83 | a0 = f_ma(n, length) 84 | a1 = f_ma(a0, length) 85 | b0 = -1 * 1 * math.pow(x, 1) * math.pow(y, 0) 86 | b1 = +1 * 1 * math.pow(x, 0) * math.pow(y, 1) 87 | r = b0 * a1 + b1 * a0 88 | // 89 | 90 | d2(src, length) => 91 | a0 = f_ma(n, length) 92 | a1 = f_ma(a0, length) 93 | a2 = f_ma(a1, length) 94 | b0 = +1 * 1 * math.pow(x, 2) * math.pow(y, 0) 95 | b1 = -1 * 2 * math.pow(x, 1) * math.pow(y, 1) 96 | b2 = +1 * 1 * math.pow(x, 0) * math.pow(y, 2) 97 | r = b0 * a2 + b1 * a1 + b2 * a0 98 | // 99 | 100 | d3(src, length) => 101 | a0 = f_ma(n, length) 102 | a1 = f_ma(a0, length) 103 | a2 = f_ma(a1, length) 104 | a3 = f_ma(a2, length) 105 | b0 = -1 * 1 * math.pow(x, 3) * math.pow(y, 0) 106 | b1 = +1 * 3 * math.pow(x, 2) * math.pow(y, 1) 107 | b2 = -1 * 3 * math.pow(x, 1) * math.pow(y, 2) 108 | b3 = +1 * 1 * math.pow(x, 0) * math.pow(y, 3) 109 | r = b0 * a3 + b1 * a2 + b2 * a1 + b3 * a0 110 | // 111 | 112 | d4(src, length) => 113 | a0 = f_ma(n, length) 114 | a1 = f_ma(a0, length) 115 | a2 = f_ma(a1, length) 116 | a3 = f_ma(a2, length) 117 | a4 = f_ma(a3, length) 118 | b0 = +1 * 1 * math.pow(x, 4) * math.pow(y, 0) 119 | b1 = -1 * 4 * math.pow(x, 3) * math.pow(y, 1) 120 | b2 = +1 * 6 * math.pow(x, 2) * math.pow(y, 2) 121 | b3 = -1 * 4 * math.pow(x, 1) * math.pow(y, 3) 122 | b4 = +1 * 1 * math.pow(x, 0) * math.pow(y, 4) 123 | r = b0 * a4 + b1 * a3 + b2 * a2 + b3 * a1 + b4 * a0 124 | // 125 | 126 | d5(src, length) => 127 | a0 = f_ma(n, length) 128 | a1 = f_ma(a0, length) 129 | a2 = f_ma(a1, length) 130 | a3 = f_ma(a2, length) 131 | a4 = f_ma(a3, length) 132 | a5 = f_ma(a4, length) 133 | b0 = -1 * 1 * math.pow(x, 5) * math.pow(y, 0) 134 | b1 = +1 * 5 * math.pow(x, 4) * math.pow(y, 1) 135 | b2 = -1 * 10 * math.pow(x, 3) * math.pow(y, 2) 136 | b3 = +1 * 10 * math.pow(x, 2) * math.pow(y, 3) 137 | b4 = -1 * 5 * math.pow(x, 1) * math.pow(y, 4) 138 | b5 = +1 * 1 * math.pow(x, 0) * math.pow(y, 5) 139 | r = b0 * a5 + b1 * a4 + b2 * a3 + b3 * a2 + b4 * a1 + b5 * a0 140 | // 141 | 142 | // Out 143 | out = 144 | degree == 1 ? d1(src, length) : 145 | degree == 2 ? d2(src, length) : 146 | degree == 3 ? d3(src, length) : 147 | degree == 4 ? d4(src, length) : 148 | degree == 5 ? d5(src, length) : 149 | na 150 | // 151 | 152 | // Print 153 | plot(out, color=#3081a5, title='Tillson MA') 154 | barcolor(out > out[1] ? #00bb00 : out < out[1] ? #bb0000 : #333333) 155 | 156 | // Bitti 157 | plotshape(barstate.isfirst, title="@ dg_factor", color=#13172200, editable=false) 158 | 159 | // DETAYLAR 160 | 161 | // T3'teki "3" nedir? 162 | // T3 Moving Average, iç içe kurgulanmış üssel hareketli ortalamaların üçüncü dereceden binom açılımı alınarak hesaplanır. 163 | // T3 şeklinde adlandırılmasının nedeni budur. 164 | // Ufak bir matematiksel müdahale ile farklı dereceler kodlanabilir, netekim bu indikatör yöntem olarak çarpanlara ayırma önermektedir. 165 | 166 | // Ömer Hayyam'ın mevzuyla ne ilgisi var? 167 | // Binom açılımı, Pascal Üçgeni olarak bilinen bir tamsayı dizisine dayanır. 168 | // İsmi Pascal'la anılsa da, bu üçgensel sayı dizisinin ilk olarak Ömer Hayyam'ın hesaplamalarında tanımlandığı kabul edilir. 169 | // Pascal üçgeninin kartezyen toplamları kullanılarak Fibonacci dizisini elde etmek de mümkündür. 170 | // Yayılım örüntülerini açıklamadaki gücü bakımından Pascal Üçgeni sıkça kullanılan bir argümandır. 171 | // Özetle finansal algoritmalar Hayyam'a çok şey borçludur. (Hemen şarkısını da açalım : https://www.youtube.com/watch?v=H0JTGAcACuk) 172 | 173 | // Ne işe yarayacak? 174 | // Başıma bir iş gelmeyecekse; 175 | // Trendi genellikle yakalar, ama terste bırakma ihtimali de yüksektir. Risk yönetimi bu yüzden gerekli. 176 | // Farklı dereceler fiyat frekansını üretebilecek yöntemlere katkı sunabilir. 177 | // Hatta ortalamaya ait önceki tepe ve diplerin yeni sinyal yönü için geçerli destek/direnç seviyeleri olarak çalıştığı da oluyor. 178 | // Tabi herhangi bir işe yaramayabilir de :). 179 | 180 | -------------------------------------------------------------------------------- /EMA - Tuples (10 Degree): -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // Author & Developer : © dg_factor [06.11.2022] 3 | 4 | // UYARI 5 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 6 | 7 | // TANIM 8 | // Aşağıdaki komut dosyası Tuple-EMA konseptini 10. dereceye kadar örneklemek için tasarlanmıştır. 9 | // Üssel hareketli ortalama, Pascal üçgeninin katsayılarına dayalı biçimde konfigüre edilir. 10 | // En sık kullanılan çıktılar arasında double EMA (DEMA) ve Triple EMA (TEMA) yer alır. 11 | 12 | // GELİŞTİRMELER 13 | // EMA yerine farklı ortalama türleri de kullanılabilir. 14 | 15 | //@version=5 16 | indicator(title='EMA - Tuples', overlay=true) 17 | 18 | data = close 19 | u = input.int(title="Uzunluk", defval=50) 20 | 21 | // Calcs 22 | r01 = ta.ema(data, u) 23 | r02 = ta.ema(r01, u) 24 | r03 = ta.ema(r02, u) 25 | r04 = ta.ema(r03, u) 26 | r05 = ta.ema(r04, u) 27 | r06 = ta.ema(r05, u) 28 | r07 = ta.ema(r06, u) 29 | r08 = ta.ema(r07, u) 30 | r09 = ta.ema(r08, u) 31 | r10 = ta.ema(r09, u) 32 | 33 | mono = 1 * r01 34 | double = 2 * r01 - 1 * r02 35 | triple = 3 * r01 - 3 * r02 + 1 * r03 36 | quadruple = 4 * r01 - 6 * r02 + 4 * r03 - 1 * r04 37 | pentuple = 5 * r01 - 10 * r02 + 10 * r03 - 5 * r04 + 1 * r05 38 | hextuple = 6 * r01 - 15 * r02 + 20 * r03 - 15 * r04 + 6 * r05 - 1 * r06 39 | septuple = 7 * r01 - 21 * r02 + 35 * r03 - 35 * r04 + 21 * r05 - 7 * r06 + 1 * r07 40 | octuple = 8 * r01 - 28 * r02 + 56 * r03 - 70 * r04 + 56 * r05 - 28 * r06 + 8 * r07 - 1 * r08 41 | nonuple = 9 * r01 - 36 * r02 + 84 * r03 - 126 * r04 + 126 * r05 - 84 * r06 + 36 * r07 - 9 * r08 + 1 * r09 42 | decuple = 10 * r01 - 45 * r02 + 120 * r03 - 210 * r04 + 252 * r05 - 210 * r06 + 120 * r07 - 45 * r08 + 10 * r09 - 1 * r10 43 | 44 | plot(mono , title='EMA' , color=color.maroon) 45 | plot(double , title='D-EMA' , color=color.lime ) 46 | plot(triple , title='T-EMA' , color=color.green ) 47 | plot(quadruple , title='Q-EMA' , color=color.teal ) 48 | plot(pentuple , title='P-EMA' , color=color.aqua ) 49 | plot(hextuple , title='H-EMA' , color=color.blue ) 50 | plot(septuple , title='S-EMA' , color=color.navy ) 51 | plot(octuple , title='O-EMA' , color=color.yellow) 52 | plot(nonuple , title='N-EMA' , color=color.orange) 53 | plot(decuple , title='DEC-EMA' , color=color.red ) 54 | 55 | plotshape(barstate.isfirst, title='dg_factor', color=#13172200, editable=false) 56 | -------------------------------------------------------------------------------- /FICH (by Anıl Özekşi): -------------------------------------------------------------------------------- 1 | // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // © dg_factor 3 | 4 | // UYARI 5 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 6 | 7 | // [29.02.2024] 8 | // Dün yeni bir Anıl Özekşi indikatörüyle daha tanıştık. 9 | // FICH (Fibonacci Channels) indikatörü, trend temelli klasik fibonacci heasplamalarına kıyasla daha sade ve anlaşılır bir yaklaşım getiriyor. 10 | // FICH, trend yönünden bağımsız olarak; 11 | // belli bir uzunluktaki en yüksek ve en düşük fiyatlar arasında fibonacci katsayılarına dayanan kaydırılmış (ötelenmiş) seviyelerden oluşuyor. 12 | 13 | // [13.07.2024] 14 | // Güncelleme : 15 | // Sinyaller için Değişken ortalama ve koşul bloğu eklendi. 16 | // Sinyal yönü barcolor fonksiyonuyla görselleştirildi. 17 | // Çizimler kullanıcı tercihine sunuldu. 18 | 19 | //@version=5 20 | indicator("FICH", overlay=true) 21 | 22 | sup_u = input.int(30, "Support Length ", step=5, tooltip="opt1 : [10, 30]") 23 | fich_u = input.int(2000, "Length ", step=250, tooltip="opt2 : [1000, 2000]") 24 | fich_r = input.int(50, "Referance ", tooltip="[30, 50]") 25 | sh_pl = input.bool(true, "Plots ") 26 | sh_bc = input.bool(true, "Barcolor ") 27 | 28 | // Variable Index Dynamic Adaptive Moving Average - Tushar Chande 29 | f_var(data, length) => 30 | a = ta.sma(data, length) 31 | b = math.abs(ta.change(data, 9)) 32 | c = math.sum(math.abs(ta.change(data)), 9) 33 | d = c != 0 ? b / c : 0 34 | e = 2 / (length + 1) 35 | r = 0.0, r := length == 1 ? data : na(r[1]) ? a : d * e * (data - nz(r[1])) + nz(r[1]) 36 | // 37 | 38 | // Fibonacci Channels - Anıl özekşi 39 | f_fich(x) => 40 | a = ta.highest(fich_u) 41 | b = ta.lowest(fich_u) 42 | r = (a * x + b * (1 - x)) [fich_r] 43 | // 44 | 45 | support = f_var(close, sup_u), plot(sh_pl ? support : na, "Support", #8c00ff) 46 | f_1000 = f_fich(1.000), plot(sh_pl ? f_1000 : na, "[FICH] High", #00bcd450) 47 | f_0854 = f_fich(0.854), plot(sh_pl ? f_0854 : na, "[FICH] 0.854", #00bcd4) 48 | f_0764 = f_fich(0.764), plot(sh_pl ? f_0764 : na, "[FICH] 0.764", #00bcd4) 49 | f_0618 = f_fich(0.618), plot(sh_pl ? f_0618 : na, "[FICH] 0.618", #00bcd4) 50 | f_0500 = f_fich(0.500), plot(sh_pl ? f_0500 : na, "[FICH] 0.500", #787B86) 51 | f_0382 = f_fich(0.382), plot(sh_pl ? f_0382 : na, "[FICH] 0.382", #ff9800) 52 | f_0236 = f_fich(0.236), plot(sh_pl ? f_0236 : na, "[FICH] 0.236", #ff9800) 53 | f_0146 = f_fich(0.146), plot(sh_pl ? f_0146 : na, "[FICH] 0.146", #ff9800) 54 | f_0000 = f_fich(0.000), plot(sh_pl ? f_0000 : na, "[FICH] Low", #ff980050) 55 | 56 | long = 57 | ta.crossover(support, f_0854) or 58 | ta.crossover(support, f_0764) or 59 | ta.crossover(support, f_0618) or 60 | ta.crossover(support, f_0500) or 61 | ta.crossover(support, f_0382) or 62 | ta.crossover(support, f_0236) or 63 | ta.crossover(support, f_0146) 64 | // 65 | 66 | short = 67 | ta.crossunder(support, f_0854) or 68 | ta.crossunder(support, f_0764) or 69 | ta.crossunder(support, f_0618) or 70 | ta.crossunder(support, f_0500) or 71 | ta.crossunder(support, f_0382) or 72 | ta.crossunder(support, f_0236) or 73 | ta.crossunder(support, f_0146) 74 | // 75 | 76 | int dir = 0, dir := long ? 1 : short ? -1 : nz(dir[1]) 77 | barcolor(sh_bc ? dir == 1 ? #00bb00 : dir == -1 ? #bb0000 : #333333 : na) 78 | -------------------------------------------------------------------------------- /Fixed Stop & Profit: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // author & developer : © dg_factor [30.05.2023, Istanbul] 3 | 4 | // UYARI 5 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 6 | 7 | // AÇIKLAMALAR 8 | // Aşağıdaki komut, statik stop ve profit seviyelerinin strategy() komutu üzerinde inşa edilmesine örnek teşkil eder. 9 | // Kendi stratejinize entegre etmek için alım-satım sinyallerini "long" ve "short" değişkenleriyle tanımlayın. 10 | // (Aşağıda örnek olarak hareketli ortalama kesişimi kullanıldı.) 11 | // Stop ve Profit seviyeleri bu iki değişkene ve input tercihlerine bağlı olarak çizilir. 12 | 13 | //@version=5 14 | strategy(title='Fixed Stop & Profit', overlay=true, 15 | initial_capital=100000, 16 | default_qty_type=strategy.percent_of_equity, default_qty_value=100, 17 | commission_type=strategy.commission.percent, commission_value=0.04) 18 | // 19 | 20 | // ━━━━━━━━━━━ 21 | // long = ... 22 | // short = ... 23 | // ━━━━━━━━━━━ 24 | 25 | // ━━━━━━━━━━━ Örnek ━━━━━━━━━━━ 26 | d1 = ta.sma(close, 50) 27 | d2 = ta.sma(close, 200) 28 | long = ta.crossover(d1, d2) 29 | short = ta.crossunder(d1, d2) 30 | // Kontrol (Ortalama Çizimi) 31 | plot(d1, "d1", #2962ff85, display=display.none) 32 | plot(d2, "d2", #ff980085, display=display.none) 33 | // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 34 | 35 | // Giriş ve Çıkış Emirleri 36 | if long 37 | strategy.close(id='SHORT', comment='Short Çıkış') 38 | strategy.entry(id='LONG', direction=strategy.long, comment='Long Giriş') 39 | if short 40 | strategy.close(id='LONG', comment='Long Çıkış') 41 | strategy.entry(id='SHORT', direction=strategy.short, comment='Short Giriş') 42 | // 43 | 44 | // Strateji Data 45 | giris_fiyati = strategy.opentrades.entry_price(strategy.opentrades - 1) // float 46 | islem_yonu = strategy.position_size > 0 ? 1 : strategy.position_size < 0 ? -1 : 0 // int 47 | long_giris = islem_yonu == 1 and (islem_yonu[1] == -1 or islem_yonu[1] == 0) // bool 48 | short_giris = islem_yonu == -1 and (islem_yonu[1] == 1 or islem_yonu[1] == 0) // bool 49 | giris = long_giris or short_giris // bool 50 | 51 | // Stop & Profit Inputs 52 | gr_fsp = "FIXED STOP PROFIT" 53 | stop_yuzde = input.float(title="Stop %", defval=5.0, group=gr_fsp) 54 | R = input.float(title="R", defval = 2.5, tooltip="R = takeprofit% / stoploss%", group=gr_fsp) 55 | 56 | // Stop Fiyatı (fixed) 57 | stop_long = ta.valuewhen(long_giris, giris_fiyati * (1 - stop_yuzde / 100), 0) 58 | stop_short = ta.valuewhen(short_giris, giris_fiyati * (1 + stop_yuzde / 100), 0) 59 | 60 | // Profit Fiyatı 61 | profit_long = ta.valuewhen(long_giris, giris_fiyati + (giris_fiyati - stop_long) * R, 0) 62 | profit_short = ta.valuewhen(short_giris, giris_fiyati - (stop_short - giris_fiyati) * R, 0) 63 | 64 | // Plot Giriş Fiyatı 65 | plot(giris_fiyati, title="Giriş Fiyatı", color=#6200b3, style=plot.style_circles, display=display.none) 66 | 67 | // Plot Long Stop & Profit 68 | plot(islem_yonu==1 ? stop_long : na, title="Long Stop", color=#bb0000, style=plot.style_circles) 69 | plot(islem_yonu==1 ? profit_long : na, title="Long Profit", color=#00bb00, style=plot.style_circles) 70 | 71 | // Plot Short Stop & Profit 72 | plot(islem_yonu==-1 ? stop_short : na, title="Short Stop", color=#bb0000, style=plot.style_circles) 73 | plot(islem_yonu==-1 ? profit_short : na, title="Short Profit", color=#00bb00, style=plot.style_circles) 74 | 75 | // Stop & Profit Emirleri 76 | if islem_yonu == 1 and ta.crossunder(low, stop_long) 77 | strategy.close(id='LONG', comment='Long Stop') 78 | if islem_yonu == 1 and ta.crossover(high, profit_long) 79 | strategy.close(id='LONG', comment='Long Profit') 80 | if islem_yonu == -1 and ta.crossover(high, stop_short) 81 | strategy.close(id='SHORT', comment='Short Stop') 82 | if islem_yonu == -1 and ta.crossunder(low, profit_short) 83 | strategy.close(id='SHORT', comment='Short Profit') 84 | // 85 | 86 | // Bar Renkleri 87 | barcolor(islem_yonu == 1 ? #00bb00 : islem_yonu == -1 ? #bb0000 : #686868) 88 | 89 | // Etiket 90 | etiket_gor = input.bool(title="Etiket", defval=false, group=gr_fsp) 91 | pozisyon = long_giris ? "Long" : short_giris ? "Short" : na 92 | info = 93 | pozisyon + "\n" + 94 | "Giriş : " + str.tostring(giris_fiyati, format.mintick) + "\n" + 95 | "Stop : " + str.tostring(long_giris ? stop_long : short_giris ? stop_short : na, format.mintick) + "\n" + 96 | "Profit : " + str.tostring(long_giris ? profit_long : short_giris ? profit_short : na, format.mintick) 97 | etiket = etiket_gor ? giris ? 98 | label.new(bar_index, giris_fiyati, info, 99 | color=#b2b5be, style=label.style_label_down, textcolor=#000000, textalign=text.align_left) : na : na 100 | // 101 | 102 | // Bitti 103 | plotshape(barstate.isfirst, "@ dg_factor", color=#13172200, editable=false) 104 | 105 | -------------------------------------------------------------------------------- /Koşul Uygulamaları: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // author & developer : © dg_factor [07.05.2023, Istanbul] 3 | 4 | // UYARI 5 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 6 | 7 | // AÇIKLAMALAR 8 | // Aşağıdaki komut, basit koşullu yapıların inşasına örnek olarak hazırlandı. 9 | // Birkaç yerleşik fonksiyonun tanımı da var. 10 | // Mantık anlaşılırsa dili daha etkili kullanmak için yardımcı olabilir. 11 | 12 | //@version=5 13 | indicator("Koşul Uygulamaları", overlay=true) 14 | plotshape(barstate.isfirst, "@ dg_factor", color=#13172200, editable=false) 15 | 16 | // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Dinamik Ortalama Türü ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 17 | 18 | ortalama_turu_1 = input.string(title="Ortalama Türü", options=["SMA", "EMA", "WMA"], defval="EMA", inline="1") 19 | ortalama_turu_2 = input.string(title="Ortalama Türü", options=["SMA", "EMA", "WMA"], defval="SMA", inline="2") 20 | 21 | uzunluk_1 = input.int(title="Uzunluk", defval=50, inline="1") 22 | uzunluk_2 = input.int(title="Uzunluk", defval=200, inline="2") 23 | 24 | a = 25 | ortalama_turu_1 == "SMA" ? ta.sma(close, uzunluk_1) : 26 | ortalama_turu_1 == "EMA" ? ta.ema(close, uzunluk_1) : 27 | ortalama_turu_1 == "WMA" ? ta.wma(close, uzunluk_1) : 28 | na 29 | // 30 | 31 | b = 32 | ortalama_turu_2 == "SMA" ? ta.sma(close, uzunluk_2) : 33 | ortalama_turu_2 == "EMA" ? ta.ema(close, uzunluk_2) : 34 | ortalama_turu_2 == "WMA" ? ta.wma(close, uzunluk_2) : 35 | na 36 | // 37 | 38 | plot(a, "ortalama 1", color.blue) 39 | plot(b, "ortalama 2", color.orange) 40 | 41 | // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ta.crossover() & ta.crossunder() ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42 | 43 | long = a > b and a[1] <= b[1] // ta.crossover(a, b) 44 | short = a < b and a[1] >= b[1] // ta.crossunder(a, b) 45 | kesisim = long or short 46 | int yon = 0 47 | yon := long ? 1 : short ? -1 : nz(yon[1]) 48 | plotshape(long, "Long ", shape.triangleup, location.belowbar, #00ff00, size=size.tiny) 49 | plotshape(short, "Short ", shape.triangledown, location.abovebar, #ff0000, size=size.tiny) 50 | 51 | // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Sinyal Sayısı ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 52 | 53 | sinyal_sayisi = ta.cum(kesisim ? 1 : 0) 54 | renk = yon==1 ? #00bb00 : yon==-1 ? #bb0000 : #686868 // renk = a > b ? #00bb00 : a < b ? #bb0000 : #686868 55 | sinyal_sayisi_etiket = kesisim ? label.new(bar_index, high, str.tostring(sinyal_sayisi), color=#00000000, textcolor=renk, size=size.large) : na 56 | barcolor(sinyal_sayisi < 1 ? na : renk, title="Bar Renklendir", display=display.none) 57 | 58 | // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ta.max() & ta.min() ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 59 | 60 | // Grafikteki En Yüksek ve En Düşük Fiyat (ATH & ATL) 61 | ath = 0.0 62 | atl = 0.0 63 | ath := bar_index == 0 ? high : high > ath[1] ? high : ath[1] 64 | atl := bar_index == 0 ? low : low < atl[1] ? low : atl[1] 65 | plot(ath, "ATH", #00bb00, trackprice=true, offset=-9999, display=display.none) 66 | plot(atl, "ATL", #bb0000, trackprice=true, offset=-9999, display=display.none) 67 | 68 | // ━━━━━━━━━━━━━━━━━━━━━━━━ Ardışık İki Sinyal Arasındaki Max ve Min Fiyat ━━━━━━━━━━━━━━━━━━━━━━━━━ 69 | 70 | var yuksek = 0.0 71 | var dusuk = 0.0 72 | yuksek := sinyal_sayisi != sinyal_sayisi[1] ? high : math.max(high, yuksek) 73 | dusuk := sinyal_sayisi != sinyal_sayisi[1] ? low : math.min(low, dusuk) 74 | plot(sinyal_sayisi < 1 ? na : yuksek, "Yüksek", #00bb00, style=plot.style_circles, display=display.none) 75 | plot(sinyal_sayisi < 1 ? na : dusuk, "Düşük", #bb0000, style=plot.style_circles, display=display.none) 76 | 77 | // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ta.barssince() & ta.valuewhen() ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78 | 79 | // Barssince Fonksiyon Yapısı 80 | var int sinyal_uzakligi = na 81 | sinyal_uzakligi := kesisim ? 0 : sinyal_uzakligi + 1 // sinyal_uzakligi = ta.barssince(kesisim) 82 | 83 | // Data Uygulamaları 84 | long_sinyali_olustugunda_kapanis_fiyati = ta.valuewhen(long, close, 0) 85 | sondan_ikinci_long_sinyali_olustugunda_kapanis_fiyati = ta.valuewhen(long, close, 2) 86 | sondan_ucuncu_long_sinyalinden_bes_bar_sonraki_kapanis_fiyati = ta.valuewhen(ta.barssince(long) == 5, close, 3) 87 | 88 | // Koşul Uygulamaları 89 | ellilik_ortalamanin_uzerinde_iki_kapanis_kosulu = ta.barssince(ta.crossover(close, ta.sma(close, 50))) == 1 and close > ta.sma(close, 50) 90 | long_pozisyondayken_son_on_bardir_min_yuzde_iki_yukselis_kosulu = ta.barssince(long) <= 10 and close >= ta.valuewhen(long, close, 0) * 1.02 91 | 92 | // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ math.sum() Uygulamaları ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 93 | 94 | // math.sum(kosul ? 1 : 0, n) == n 95 | // Yukarıdaki yapı "herhangi bir koşul son kaç ardışık bardır gerçekleşiyor?" sorusunu cevaplar. 96 | // Koşul her gerçekleştiğinde fonksiyon 1 değeri üretir ve bu değerleri toplar. 97 | // Eğer toplam sonuç n ise koşul son n bardır gerçekleşmiş demektir. 98 | 99 | son_bes_bardir_yukselis_kosulu = math.sum(close > close[1] ? 1 : 0, 5) == 5 100 | son_bes_barin_herhangi_dort_tanesinde_yukselis_kosulu = math.sum(close > close[1] ? 1 : 0, 5) == 4 101 | son_bes_bardir_dusus_ve_ardindan_son_uc_bardir_yukselis_kosulu = math.sum(close < close[1] ? 1 : 0, 8) == 5 and math.sum(close > close[1] ? 1 : 0, 3) == 3 102 | son_on_bardir_tek_barda_min_yuzde_iki_yukselis_kosulu = math.sum((close - close[1]) / close[1] * 100 >= 2 ? 1 : 0, 10) == 1 103 | son_uc_bardir_ellilik_ortalamanin_uzerinde_kapanis_kosulu = math.sum(close > ta.sma(close, 50) ? 1 : 0, 3) == 3 and math.sum(close > ta.sma(close, 50) ? 1 : 0, 4) == 3 104 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | -------------------------------------------------------------------------------- /Notes - Backtest Değişkenleri: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // © dg_factor 3 | 4 | //@version=5 5 | strategy("Notes - Backtest Değişkenleri", overlay=true, initial_capital=100000, 6 | default_qty_type=strategy.percent_of_equity, default_qty_value=100, 7 | commission_type=strategy.commission.percent, commission_value=0) 8 | // 9 | 10 | plotshape(barstate.isfirst, "@ dg_factor", shape.flag, location.bottom, #00000000, editable=false) 11 | 12 | // Condition 13 | longCondition = ta.crossover(ta.sma(close, 50), ta.sma(close, 200)) 14 | shortCondition = ta.crossunder(ta.sma(close, 50), ta.sma(close, 200)) 15 | 16 | // Long Giriş 17 | if (longCondition) 18 | strategy.close(id='Short Entry', comment="Short Çıkış") 19 | strategy.entry(id="Long Entry", direction=strategy.long, comment="Long Giriş") 20 | // 21 | 22 | // Short Giriş 23 | if (shortCondition) 24 | strategy.close(id='Long Entry', comment="Long Çıkış") 25 | strategy.entry(id="Short Entry", direction=strategy.short, comment="Short Giriş") 26 | // 27 | 28 | // ╔══════════════════════════════════════════════════════════════════════════════╗ 29 | // ║ NOTLAR ║ 30 | // ╚══════════════════════════════════════════════════════════════════════════════╝ 31 | 32 | // ═════════════════════════════ Bazı Değişkenler ══════════════════════════════ 33 | 34 | // strategy.opentrades // İşlem açıksa 1, kapalıysa 0 döner. (0'dan büyükse açık işlem vardır, değilse açık işlem yoktur) 35 | // strategy.position_size // Quantity değeridir; pozitif ise işlem yönü Long, negatif ise işlem yönü Short'tur. 36 | 37 | baslangic_bakiyesi = strategy.initial_capital // float ($) 38 | guncel_bakiye = strategy.equity // float ($) 39 | brut_kar = strategy.grossprofit // float ($) (+) (karın kümülatif toplamı) 40 | brut_zarar = strategy.grossloss // float ($) (+) (zararın kümülatif toplamı) 41 | gerceklesmis_kar = strategy.netprofit // float ($) (strategy.grossprofit - strategy.grossloss) 42 | gerceklesmis_kar_yuzde = strategy.netprofit / strategy.initial_capital * 100 // float (%) 43 | gerceklesmemis_kar_yuzde = (strategy.equity - strategy.initial_capital) / strategy.initial_capital * 100 // float (%) 44 | pozisyon = strategy.position_size != 0 // bool 45 | long_pozisyon = strategy.position_size > 0 // bool 46 | short_pozisyon = strategy.position_size < 0 // bool 47 | islem_yonu = strategy.position_size > 0 ? 1 : strategy.position_size < 0 ? -1 : 0 // int 48 | long_giris = islem_yonu == 1 and (islem_yonu[1] == -1 or islem_yonu[1] == 0) // bool [süreksiz değişken] 49 | short_giris = islem_yonu == -1 and (islem_yonu[1] == 1 or islem_yonu[1] == 0) // bool [süreksiz değişken] 50 | giris = long_giris or short_giris // bool [süreksiz değişken] 51 | long_cikis = islem_yonu[1] == 1 and (islem_yonu == -1 or islem_yonu == 0) // bool [süreksiz değişken] 52 | short_cikis = islem_yonu[1] == -1 and (islem_yonu == 1 or islem_yonu == 0) // bool [süreksiz değişken] 53 | cikis = long_cikis or short_cikis // bool [süreksiz değişken] 54 | karli_cikis = strategy.wintrades != strategy.wintrades[1] // bool [süreksiz değişken] 55 | zararli_cikis = strategy.losstrades != strategy.losstrades[1] // bool [süreksiz değişken] 56 | giris_fiyati = strategy.opentrades.entry_price(strategy.opentrades - 1) // float ($) (giriş gerçekleştikten sonra tanımlı değer döndürür) 57 | cikis_fiyati = strategy.closedtrades.exit_price(strategy.closedtrades - 1) // float ($) (çıkış gerçekleştikten sonra tanımlı değer döndürür) 58 | acik_islemdeki_kar = strategy.openprofit // float ($) (çıkış komisyonu dahil değildir) 59 | acik_islem_karda = strategy.openprofit > 0 // bool 60 | acik_islem_zararda = strategy.openprofit < 0 // bool 61 | karli_islem_sayisi = strategy.wintrades // int 62 | zararli_islem_sayisi = strategy.losstrades // int 63 | islem_sayisi = ta.cum(giris ? 1 : 0) // int 64 | long_islem_sayisi = ta.cum(long_giris ? 1 : 0) // int 65 | short_islem_sayisi = ta.cum(short_giris ? 1 : 0) // int 66 | islem_uzunlugu = ta.barssince(giris) // int 67 | kazanc_katsayisi = strategy.grossprofit / strategy.grossloss // float (k) profit factor 68 | ortalama_kar = strategy.grossprofit / strategy.wintrades // float ($) 69 | ortalama_zarar = strategy.grossloss / strategy.losstrades // float ($) 70 | ortalama_kar_zarar_orani = ortalama_kar / ortalama_zarar // float (k) 71 | komisyon_acik_islem = strategy.opentrades.commission(strategy.opentrades - 1) // float ($) 72 | komisyon_kapanan_islem = strategy.closedtrades.commission(strategy.closedtrades - 1) // float ($) 73 | komisyon = nz(fixnan(ta.cum(cikis ? komisyon_kapanan_islem : na)) + komisyon_acik_islem) // float ($) 74 | -------------------------------------------------------------------------------- /Notes - Bar Index: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // © dg_factor 3 | 4 | //@version=5 5 | indicator(title='Notes - Bar Index', overlay=false, max_labels_count=500) 6 | 7 | // Bar no tablo 8 | var table bar_tablo = table.new(position.top_right, 1, 4) 9 | if barstate.islast 10 | table.cell(bar_tablo, 0, 0, "", text_color=#696969) 11 | table.cell(bar_tablo, 0, 1, str.tostring(syminfo.tickerid), text_color=#696969) 12 | table.cell(bar_tablo, 0, 2, "# " + str.tostring(bar_index), text_color=#696969) 13 | // 14 | 15 | // Kontrol 16 | plot(bar_index, title="bar_index ⟶", color=color.blue, display=display.data_window) 17 | plot(last_bar_index - bar_index + 1, title="lookback ⟵", color=color.orange, display=display.data_window) 18 | 19 | // Input 20 | n = input.int(title="maxval: bar_index", defval=27) 21 | 22 | // Bar no etiket 23 | barindex = label.new(bar_index, 0, text=str.tostring(bar_index), style=label.style_none, textcolor=color.green) 24 | n_devam = label.new(bar_index + n, 0, text=str.tostring(bar_index + n), style=label.style_none, textcolor=color.red) 25 | label.delete(n_devam[n]) 26 | 27 | // // TANIM 28 | // barindex = ta.cum(1) - 1 29 | // f_bar_index() => 30 | // var int i = 0 31 | // i += 1 32 | // r = i - 1 33 | // // 34 | 35 | // Sinyal oluştuktan sonra üçüncü barın kapanış değeri 36 | // f_deger(sinyal) => 37 | // ta.valuewhen(ta.barssince(sinyal) == 3, close, 0) 38 | 39 | // // 150. bardaki kapanış değeri 40 | // kapanis_150 = ta.valuewhen(bar_index + 1 == 150, close, 0) 41 | 42 | // // Her n barda bir gerçekleşen koşul 43 | // u = input.int(500) 44 | // kosul = bar_index % u == 0 45 | // bgcolor(kosul ? color.new(color.teal, 90) : na) 46 | -------------------------------------------------------------------------------- /OTT Collection (Info): -------------------------------------------------------------------------------- 1 | © dg_factor [15.02.2024] 2 | 3 | ╔═════════════════════════════════════════════╗ 4 | ║ GİRİŞ ║ 5 | ╚═════════════════════════════════════════════╝ 6 | 7 | İndikatör Linki : 8 | https://www.tradingview.com/script/axJIItYE 9 | 10 | Video - Tanıtım : 11 | https://www.youtube.com/watch?v=NeYAbZTFOPM 12 | 13 | Video - Backtest : 14 | https://www.youtube.com/watch?v=vFAlz3MgsR4&t=300s 15 | 16 | Teşekkür : 17 | Mütevazi yaklaşımı ve açık kaynaklı paylaşımlarıyla bana her zaman ilham kaynağı olan Anıl Hoca'ya, yayınlama talebimi kırmadığı için özel teşekkürlerimle... 18 | 19 | ╔═════════════════════════════════════════════╗ 20 | ║ OTT COLLECTION NEDİR? ║ 21 | ╚═════════════════════════════════════════════╝ 22 | 23 | OTT Collection, Tradingview'da yayınlanmış dinamik bir "indikatör birleştirme" örneğidir. 24 | Anıl Özekşi tarafından geliştirilen Optimized Trend Tracker indikatörünün farklı uygulamalarını tek bir komut dosyasında modelleme fikri üzerine kuruludur. 25 | 26 | ╠════════════ Anıl Özekşi Library ════════════╣ 27 | 28 | 1) OTT [31.05.2019] Optimized Trend Tracker 29 | 2) TOTT [01.05.2020] Twin Ott (Ott Bands) 30 | 3) OTT CHANNEL [19.03.2021] Ott Channel (Half Channel & Fibonacci Channel) 31 | 4) RISOTTO [16.04.2021] Rsi-Ott 32 | 5) SOTT [18.04.2021] Stochastic-Ott 33 | 6) HOTT-LOTT [06.03.2022] Highest-Lowest Ott & Sum Version [07.04.2022] 34 | 7) ROTT [19.05.2022] Relative Ott 35 | 8) FT [24.06.2022] Fırsatçı Trend 36 | 9) RTR [26.09.2022] Relative True Range (Bonus Volatility Tool) 37 | 10) MOTT [14.02.2024] Multiple Ott 38 | 11) BOOTS [14.02.2024] Bollinger Ott Spread 39 | 40 | ╔═════════════════════════════════════════════╗ 41 | ║ OTT COLLECTION NE DEĞİLDİR? ║ 42 | ╚═════════════════════════════════════════════╝ 43 | 44 | Yukarıdaki indikatörler bir alım-satım stratejisinin parçası olabilirler, ama stratejinin kendisi yerine ikame edilemezler. 45 | Sistem inşası için Anıl Özekşi'nin yayınladığı EĞİTİMLER belirleyici tek kaynaktır. 46 | OTT Collection, yukarıdaki 'araçları' derli toplu sunmak amacıyla hazırlandı. 47 | Tradingview da dahil olmak üzere pek çok platformda envai çeşit OTT türevi bulmak mümkün olsa da, sinyallerin DOĞRU kodlandığı bir örnek pek yoktur. 48 | Koleksiyon bu sorunu köklü biçimde çözme iddiası taşır. 49 | Bununla beraber, OTT uygulamalarının birbiriyle etkileşimi ayrı bir çalışmanın konusudur. 50 | Eğer fırsat bulursam parametrik filtre mekanizmalarına dayanan "Progressive Algo-Trade System" başlıklı bir komut yayınlamayı da düşünüyorum. 51 | 52 | ╔═════════════════════════════════════════════╗ 53 | ║ NEDEN OTT? BAŞKA İNDİKATÖR MÜ YOK? ║ 54 | ╚═════════════════════════════════════════════╝ 55 | 56 | Türkiye'de finansal algoritmalar ile ilgili devasa bir literatür ve birikim var; 57 | Yaşar Erdinç, Kıvanç Özbilgiç, Anıl Özekşi, Ali Perşembe, Cem Tutar... 58 | Bu isimlere bakıldığında bile 'yaşayan bir kütüphane'ye sahip olduğumuz söylenebilir. 59 | Sosyal medyadaki bilgi çöplüğü ve intihal bir yana, söz konusu birikime doğru adresten ulaşmanın imkanları da var. 60 | Şüphesiz, Anıl Özekşi bu adresler arasında en üretken ve en yaratıcı örneklerden biri. 61 | Öte yandan, OTT gibi trend takip sistemlerinin tarihsel olarak birbirlerine model teşkil ettiği de bilinen bir gerçek. 62 | Sadece aşağıdaki listede yer alan indikatörlerin hesaplamaları incelendiğinde bile, kronolojik bir 'tutarlılık' ve etkileşim gözlemlenir. 63 | 64 | Envelope Band [?] 65 | Keltner Channel [Chester Keltner, 1960s] 66 | Donchian Channel [Richard Donchian, 1960s] 67 | Bollinger Band [John Bollinger, 1983] 68 | Trailing Reverse [Konstantin Kopyrkin, 2001] 69 | SuperTrend [Olivier Seban, 2001] 70 | Chandelier Exit [Chuck LeBeau, 2002] 71 | Most [Anıl Özekşi, 2003] 72 | Trend Magic [# Metatrader, 2016] 73 | Ott [Anıl Özekşi, 2018] 74 | Pmax [Kıvanç Özbilgiç, 2020] 75 | AlphaTrend [Kıvanç Özbilgiç, 2022] 76 | 77 | Değişen piyasa koşullarına adaptasyon iddiası hepsinin ortak noktası olmasına rağmen OTT'yi özel kılan şey farklı uygulama biçimlerine sahip olmasıdır. 78 | Yukarıdaki hiçbir indikatör OTT kadar fazla sayıda uygulama türüne sahip değildir :) 79 | Daha da önemlisi, OTT'nin uygulama türleri yukarıdaki indikatörlerin hepsi için uyarlanabilir niteliktedir. 80 | 'OTT Collection' isminde bir koleksiyon hazırlamamın temel sebebi OTT'nin bu benzersiz özelliğidir. 81 | Umarım herkese fayda sağlar... 82 | 83 | ╔═════════════════════════════════════════════╗ 84 | ║ KAYNAK & REFERANSLAR ║ 85 | ╚═════════════════════════════════════════════╝ 86 | 87 | Aşağıda indikatör yaratıcısı Anıl Özekşi'ye ait Twitter/X ve Youtube referans linklerini bulabilirsiniz. 88 | 89 | OTT (Optimized Trend Tracker) 90 | https://www.youtube.com/watch?v=f4v46irHKaY 91 | 92 | TOTT (Twin OTT) 93 | https://www.youtube.com/watch?v=mG8lB585fus 94 | https://twitter.com/Anil_Ozeksi/status/1256151708272603138?s=20 95 | https://twitter.com/Anil_Ozeksi/status/1390414093912322051 96 | 97 | OTT CHANNEL 98 | https://www.youtube.com/watch?v=jI0QEyLXYxQ 99 | https://twitter.com/Anil_Ozeksi/status/1694272344527671455 100 | 101 | RISOTTO (RSI-OTT) 102 | https://twitter.com/Anil_Ozeksi/status/1382991344600297472 103 | 104 | SOTT (Stochastic OTT) 105 | https://www.youtube.com/watch?v=btottc_nonew_YP9w 106 | https://twitter.com/Anil_Ozeksi/status/1383721897251065857 107 | 108 | HOTT & LOTT (Highest & Lowest OTT) 109 | https://twitter.com/Anil_Ozeksi/status/1500218858505916419 110 | https://twitter.com/Anil_Ozeksi/status/1512012384919072774 111 | 112 | ROTT (Relative OTT) 113 | https://twitter.com/Anil_Ozeksi/status/1527231922224652289 114 | https://twitter.com/Anil_Ozeksi/status/1527939707887357953 115 | https://twitter.com/Anil_Ozeksi/status/1527946455331348481 116 | https://twitter.com/Anil_Ozeksi/status/1527968511506751488 117 | https://twitter.com/Anil_Ozeksi/status/1527984151722446848 118 | https://twitter.com/Anil_Ozeksi/status/1528008539502833665 119 | https://twitter.com/Anil_Ozeksi/status/1528645476504961025 120 | https://twitter.com/Anil_Ozeksi/status/1542884012473081856 121 | https://twitter.com/Anil_Ozeksi/status/1667577125157601282 122 | 123 | FT (Fırsatçı Trend) 124 | https://twitter.com/Anil_Ozeksi/status/1540354846129364994 125 | https://twitter.com/Anil_Ozeksi/status/1540679336197378048 126 | https://twitter.com/Anil_Ozeksi/status/1540679972938973184 127 | https://twitter.com/Anil_Ozeksi/status/1553622261759868928 128 | 129 | RTR (Relative True Range) 130 | https://twitter.com/Anil_Ozeksi/status/1574432868457029634 131 | 132 | BONUS LINKLER 133 | 3K 🙂 : https://twitter.com/Anil_Ozeksi/status/1493614901159415817 134 | 3G 🔨 : https://twitter.com/Anil_Ozeksi/status/1494016391980236807 135 | Crypto 🍺 : https://twitter.com/Anil_Ozeksi/status/1667435982184914946 136 | TOTTO 🚫 : https://twitter.com/Anil_Ozeksi/status/1513496966415716352 137 | TOTTO (error) 🤦‍♂️ : https://twitter.com/Anil_Ozeksi/status/1513598693320052743 138 | OTTO 🚫 : https://twitter.com/Anil_Ozeksi/status/1500448581777559556 139 | 140 | Kıvanç Özbilgiç'in Tradingview'da Yayınladığı Örnekler 141 | VAR : https://tradingview.com/script/64ynXU2e 142 | OTT : https://tradingview.com/script/zVhoDQME 143 | TOTT : https://tradingview.com/script/eENf7NpJ 144 | OTT Channels : https://tradingview.com/script/jD7ioJ1Y 145 | SOTT : https://tradingview.com/script/BK45kYNB 146 | HOTT & LOTT : https://tradingview.com/script/5qkKOlVg 147 | MOTT (Sinyal belirtilmemiş) : https://tradingview.com/script/UXwYKQ5u 148 | BOOTS (Sinyal belirtilmemiş) : https://tradingview.com/script/hynBgzIQ 149 | 150 | -------------------------------------------------------------------------------- /Piramitleme (Çözüm): -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // author & developer : © dg_factor [06.07.2023, Istanbul] 3 | 4 | // UYARI 5 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 6 | 7 | // AÇIKLAMALAR 8 | // Aşağıdaki komut, aynı yönde ardışık sinyallerin filtrelenmesine örnek teşkil eder. 9 | // Örnek strateji close ve ATR Bandı (Keltner Channel) kesişimi üzerine kuruludur. 10 | // Sistem sadece işlem yönü değiştiğinde sinyal üretir. 11 | // Kendi stratejinize entegre etmek için; 12 | // i) Tekrarlayan sinyalleri "long" ve "short" değişkenleriyle tanımlayınız. 13 | // ii) "ÇÖZÜM" kısmındaki yapıyı kullanınız. 14 | 15 | //@version=5 16 | indicator("Piramitleme (Çözüm)", overlay=true) 17 | 18 | // PROBLEM : Long ya da Short yönünde sinyalleri tekrarlanan (aynı yönde ardışık sinyal üreten) örnek bir stratejimiz olsun. 19 | u = input.int(20, "uzunluk") 20 | k = input.float(3.0, "katsayi") 21 | 22 | ort = ta.sma(close, u) 23 | ust = ort + k * ta.atr(u) 24 | alt = ort - k * ta.atr(u) 25 | 26 | long = ta.crossover(close, alt) 27 | short = ta.crossunder(close, ust) 28 | 29 | plot(ort, color=#FF980050) 30 | plot(ust, color=#2962ff50) 31 | plot(alt, color=#2962ff50) 32 | 33 | plotshape(long, "tekrarlayan long", shape.triangleup, location.belowbar, #00bb0070, size=size.tiny) 34 | plotshape(short, "tekrarlayan short", shape.triangledown, location.abovebar, #bb000070, size=size.tiny) 35 | 36 | // ÇÖZÜM : Recursive bir yön değişkeni tanımlayarak sinyalleri üretebiliriz. 37 | int yon = 0 38 | yon := long ? 1 : short ? -1 : nz(yon[1]) 39 | yeni_long = yon == 1 and yon[1] != 1 40 | yeni_short = yon == -1 and yon[1] != -1 41 | 42 | plotshape(yeni_long, "tekrarlamayan long", shape.triangleup, location.top, #00ff00, size=size.tiny) 43 | plotshape(yeni_short, "tekrarlamayan short", shape.triangledown, location.top, #ff0000, size=size.tiny) 44 | 45 | // // Alternatif Yöntem : Sinyallerin birbirine olan uzaklıklarından yararlanarak tekrarlamalarını önleyebiliriz. 46 | // l = ta.barssince(long) < ta.barssince(short) 47 | // s = ta.barssince(long) > ta.barssince(short) 48 | // i_long = ta.cum(long ? 1 : na) == 1 49 | // i_short = ta.cum(short ? 1 : na) == 1 50 | // yeni_long = i_long or l and (s[1] or not l[1]) 51 | // yeni_short = i_short or s and (l[1] or not s[1]) 52 | 53 | // NOT: Karmaşık alım satım sinyalleri için farklı uygulamalar gerekebilir. 54 | 55 | // Bitti 56 | plotshape(barstate.isfirst, "@ dg_factor", shape.flag, location.bottom, #00000000, editable=false) 57 | 58 | -------------------------------------------------------------------------------- /Pivot Levels [MTF]: -------------------------------------------------------------------------------- 1 | // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // © dg_factor [18.01.2024] 3 | //@version=5 4 | indicator("Pivot Levels [MTF]", max_lines_count=500, max_labels_count=500, overlay=true) 5 | time_frame = input.timeframe("1D", "Time Frame") 6 | pvt_type = input.string("Traditional", "Pivot Türü", options=["Traditional", "Fibonacci", "Woodie", "Classic", "DM", "Camarilla"]) 7 | lb = input.bool(true, "Etiket") 8 | ln = input.bool(true, "Çizim") 9 | tf_change = timeframe.change(time_frame) 10 | duration = timeframe.in_seconds(time_frame) * 1000 11 | pvt = ta.pivot_point_levels(pvt_type, tf_change) 12 | string [] ars = array.from("P", "R1", "S1", "R2", "S2", "R3", "S3", "R4", "S4", "R5", "S5") 13 | if tf_change 14 | for i = 0 to pvt.size() - 1 15 | if ln 16 | line.new(time, pvt.get(i), time + duration, pvt.get(i), 17 | xloc.bar_time, extend.none, color.from_gradient(i, 0, 10, #ffaa00, #2b00ff)) 18 | if lb 19 | label.new(time, pvt.get(i), "[" + ars.get(i) + "] " + str.tostring(pvt.get(i), format.mintick), xloc.bar_time, 20 | yloc.price, #00000000, label.style_label_right, color.from_gradient(i, 0, 10, #ffaa00, #2b00ff), size.normal, text.align_left) 21 | // 22 | 23 | // Bitti :) 24 | 25 | // ╠═══════════════════════════════ Açıklamalar ═══════════════════════════════╣ 26 | 27 | // UYARI 28 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 29 | 30 | // TANIM 31 | // Bakınız Pivot çizimi için 200 satırlık komut kullanmanıza gerek yok 🤦‍♂ Onun yerleşik bir dizi fonksiyonu var :) 32 | // Yukarıdaki script herhangi bir sembolde Multiple Time Frame Pivot seviyelerinin nasıl çizdirilebileceğine örnek teşkil eder. 33 | // Pivot noktaları fiyatın destek veya dirençle karşılaşabileceği seviyeleri bulmak için kullanılan teknik bir göstergedir. 34 | // Seçilen timeframe'in bir önceki yüksek, düşük ve kapanış fiyatlarına dayalı olarak hesaplanır. 35 | 36 | // ╠════════════════════════════ Alternatif Metod ═════════════════════════════╣ 37 | 38 | // Aşağıdaki komut da aynı sonuçları üretir. 39 | // Çıktıları line.new() fonksiyonuyla istediğiniz şekilde konfigüre edebilirsiniz. 40 | 41 | // //@version=5 42 | // indicator("Pivot - Alternatif", overlay=true) 43 | // time_frame = input.timeframe("1D", "Time Frame") 44 | // pvt_type = input.string("Traditional", "Pivot Türü", options=["Traditional", "Fibonacci", "Woodie", "Classic", "DM", "Camarilla"]) 45 | // ln = input.bool(true, "Çizim") 46 | // pvt = ta.pivot_point_levels(pvt_type, timeframe.change(time_frame)) 47 | // // Out 48 | // plot(ln ? pvt.get(9) : na, "+p5", color=#00e676) 49 | // plot(ln ? pvt.get(7) : na, "+p4", color=#4caf50) 50 | // plot(ln ? pvt.get(5) : na, "+p3", color=#00897b) 51 | // plot(ln ? pvt.get(3) : na, "+p2", color=#4cc7fe) 52 | // plot(ln ? pvt.get(1) : na, "+p1", color=#3081a5) 53 | // plot(ln ? pvt.get(0) : na, "pvt", color=#194255) 54 | // plot(ln ? pvt.get(2) : na, "-p1", color=#8c00ff) 55 | // plot(ln ? pvt.get(4) : na, "-p2", color=#8b0c84) 56 | // plot(ln ? pvt.get(6) : na, "-p3", color=#6b6c00) 57 | // plot(ln ? pvt.get(8) : na, "-p4", color=#ffeb3b) 58 | // plot(ln ? pvt.get(10) : na, "-p5", color=#ff9800) 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PineScript 2 | The repository contains unique, independent open source scripts. 3 | It aims to offer an educational perspective on the interplay of design, architecture and ad-hoc functions. 4 | The use of the script does not constitute professional and/or financial advice. The responsibility for risks associated with the use of the script is solely owned by the user. [dg_factor] 5 | 6 | Dosyalar özgün, birbirinden bağımsız açık kaynak kodlarını içerir. 7 | Tasarım, mimari ve bazı pratik fonksiyonların etkileşimiyle ilgili eğitici bir perspektif sunma amacıyla hazırlanmıştır. 8 | Herhangi bir mali/yatırım tavsiyesi içermez. Kullanımından doğacak sonuçlar sadece kullanıcının tasarrufunda ve sorumluluğundadır. [dg_factor] 9 | 10 | -------------------------------------------------------------------------------- /Trailing Stop & Profit: -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // author & developer : © dg_factor [07.06.2023, Istanbul] 3 | 4 | // UYARI 5 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 6 | 7 | // TANIM : 8 | // Aşağıdaki komut, dinamik stop-loss ve sabit profit seviyelerinin strategy() komutu üzerinde nasıl inşa edilebileceğine örnek teşkil eder. 9 | // Trailing-Stop sinyal yönünüze bağlı olarak fiyatı (aşağıdan veya yukarıdan) belli bir mesafe ile takip eden stop-loss mekanizmasıdır. 10 | // Fiyatın sinyal yönünün tersinde hareket etmesi halinde Trailing-Stop "ölü taklidi" yaparak yatay bir çizgi haline gelir. 11 | // Bu anlamıyla zararı minimize etmek üzerine kuruludur. 12 | 13 | // YÖNTEM : 14 | // Kendi stratejinize entegre etmek için alım-satım sinyallerini "long" ve "short" değişkenleriyle tanımlayın. 15 | // (Aşağıda örnek olarak hareketli ortalama kesişimi kullanıldı.) 16 | // Stop ve Profit seviyeleri bu iki değişkene ve input tercihlerine bağlı olarak çizilir. 17 | 18 | // NOT : 19 | // Daha önce yayınladığım "Fixed Stop & Profit" komut dosyasında bulunan etiket opsiyonu, Stop'un dinamik karakteri nedeniyle bu komut dosyasına eklenmedi. 20 | 21 | //@version=5 22 | strategy(title='Trailing Stop & Profit', overlay=true, 23 | initial_capital=100000, 24 | default_qty_type=strategy.percent_of_equity, default_qty_value=100, 25 | commission_type=strategy.commission.percent, commission_value=0.04) 26 | // 27 | 28 | // ━━━━━━━━━━━ 29 | // long = ... 30 | // short = ... 31 | // ━━━━━━━━━━━ 32 | 33 | // ━━━━━━━━━━━ Örnek ━━━━━━━━━━━ 34 | d1 = ta.sma(close, 50) 35 | d2 = ta.sma(close, 200) 36 | long = ta.crossover(d1, d2) 37 | short = ta.crossunder(d1, d2) 38 | // Kontrol (Ortalama) 39 | plot(d1, "d1", #2962ff85, display=display.none) 40 | plot(d2, "d2", #ff980085, display=display.none) 41 | // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42 | 43 | // Giriş ve Çıkış Emirleri 44 | if long 45 | strategy.close(id='SHORT', comment='Short Çıkış') 46 | strategy.entry(id='LONG', direction=strategy.long, comment='Long Giriş') 47 | if short 48 | strategy.close(id='LONG', comment='Long Çıkış') 49 | strategy.entry(id='SHORT', direction=strategy.short, comment='Short Giriş') 50 | // 51 | 52 | // Strateji Data 53 | giris_fiyati = strategy.opentrades.entry_price(strategy.opentrades - 1) // float 54 | islem_yonu = strategy.position_size > 0 ? 1 : strategy.position_size < 0 ? -1 : 0 // int 55 | long_giris = islem_yonu == 1 and (islem_yonu[1] == -1 or islem_yonu[1] == 0) // bool 56 | short_giris = islem_yonu == -1 and (islem_yonu[1] == 1 or islem_yonu[1] == 0) // bool 57 | 58 | // Stop & Profit Inputs 59 | gr_tsp = "TRAILING STOP & PROFIT" 60 | stop_yuzde = input.float(title="Stop %", defval=5.0, group=gr_tsp) 61 | R = input.float(title="R", defval = 2.5, group=gr_tsp, tooltip="R = takeprofit% / stoploss%") 62 | kaynak = open 63 | 64 | // Trailing Stop 65 | long_stop = kaynak * (1 - stop_yuzde / 100) 66 | short_stop = kaynak * (1 + stop_yuzde / 100) 67 | pls = nz(long_stop[1], long_stop) 68 | pss = nz(short_stop[1], short_stop) 69 | long_stop := islem_yonu == 1 ? math.max(long_stop, pls) : na 70 | short_stop := islem_yonu == -1 ? math.min(short_stop, pss) : na 71 | 72 | // Take Profit 73 | var tlp = float(na) 74 | var tsp = float(na) 75 | pbl = kaynak * (1 + stop_yuzde / 100 * R) 76 | pbs = kaynak * (1 - stop_yuzde / 100 * R) 77 | if long_giris 78 | tlp := pbl 79 | if short_giris 80 | tsp := pbs 81 | long_profit = islem_yonu == 1 ? tlp : na 82 | short_profit = islem_yonu == -1 ? tsp : na 83 | 84 | // Stop & Profit Emirleri 85 | if islem_yonu == 1 and ta.crossunder(low, long_stop) 86 | strategy.close(id='LONG', comment='Long Stop') 87 | if islem_yonu == 1 and ta.crossover(high, long_profit) 88 | strategy.close(id='LONG', comment='Long Profit') 89 | if islem_yonu == -1 and ta.crossover(high, short_stop) 90 | strategy.close(id='SHORT', comment='Short Stop') 91 | if islem_yonu == -1 and ta.crossunder(low, short_profit) 92 | strategy.close(id='SHORT', comment='Short Profit') 93 | // 94 | 95 | // Plot Giriş Fiyatı 96 | plot(giris_fiyati, title="Giriş Fiyatı", color=#6200b3, style=plot.style_circles, display=display.none) 97 | 98 | // Plot Long Stop & Profit 99 | plot(long_stop, title="Long Stop", color=#bb0000, linewidth=2, style=plot.style_linebr) 100 | plot(long_profit, title="Long Profit", color=#00bb00, linewidth=2, style=plot.style_linebr) 101 | 102 | // Plot Short Stop & Profit 103 | plot(short_stop, title="Short Stop", color=#bb0000, linewidth=2, style=plot.style_linebr) 104 | plot(short_profit, title="Short Profit", color=#00bb00, linewidth=2, style=plot.style_linebr) 105 | 106 | // Bar Renkleri 107 | barcolor(islem_yonu == 1 ? #00bb00 : islem_yonu == -1 ? #bb0000 : #686868) 108 | 109 | // Bitti 110 | plotshape(barstate.isfirst, "@ dg_factor", color=#13172200, editable=false) 111 | -------------------------------------------------------------------------------- /VAR (Değişken Ortalama): -------------------------------------------------------------------------------- 1 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 2 | // author : © dg_factor [16.06.2023, Istanbul] 3 | 4 | // UYARI 5 | // Geliştirme amaçlıdır, doğrudan alım-satım stratejisi yerine ikame edilemez. 6 | 7 | // AÇIKLAMALAR 8 | // Aşağıdaki komut, VAR/VIDYA hareketli ortalama türünü bir fonksiyon şeklinde sunar. 9 | // Tradingview'da yayınlanmış VAR (değişken ortalama) versiyonlarının hepsi grafiğin ilk barında sıfır değeri ile başlar, ilerleyen barlarda fiyata yaklaşır. 10 | // Bu durum backtestlerde anlamsız sonuçlar doğurabilir. 11 | // Sorunsuz versiyonu aşağıda 🧐 12 | 13 | // NOT 14 | // VAR/VIDYA Tushar S. Chande'nin 1994'te 'The New Technical Trader' kitabında yayınladığı üssel bir hareketli ortalama türüdür. 15 | // Veri terminallerinde yaygın olarak kullanılır, aşağıda basit bir düzenleme yaptım sadece. 16 | // İleri okuma : 17 | // https://adaptrade.com/Newsletter/NL-AdaptIndicators.htm 18 | // Bonus : 19 | // https://twitter.com/dg_factor/status/1655957870276657153 20 | 21 | //@version=5 22 | indicator("VAR (Değişken Ortalama)", overlay=true) 23 | 24 | kaynak = close 25 | uzunluk = input.int(200) 26 | 27 | // VAR - Variable Index Dynamic Adaptive Moving Average [Tushar S. Chande] 28 | f_var(data, u) => 29 | x = ta.sma(data, u) 30 | a = 9 31 | b = data > data[1] ? data - data[1] : 0 32 | c = data < data[1] ? data[1] - data : 0 33 | d = math.sum(b, a) 34 | e = math.sum(c, a) 35 | f = nz((d - e) / (d + e)) 36 | g = math.abs(f) 37 | k = 2 / (u + 1) 38 | r = 0.0 39 | r := u == 1 ? data : na(r[1]) ? x : g * k * (data - nz(r[1])) + nz(r[1]) 40 | // 41 | 42 | plot(f_var(kaynak, uzunluk), title="VAR") 43 | 44 | --------------------------------------------------------------------------------