// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © Coded by Batuhan ULUDAĞ - Dağıtılması ve paylaşılması yasaktır. //@version=5 // indicator("ATLAS TREND", shorttitle='Atlas Trend🌖',overlay=true,max_lines_count=500,max_labels_count=500,max_bars_back=500) ////RMA//// Stuaneeded theme = input.string(title='Tradingview Teması', defval='Aydınlık', options=['Aydınlık', 'Karanlık']) tablo=input.bool(title='Bilgi Panosu',defval=true,tooltip='Bilgi panosunu gizler veya gösterir') ato4=input.bool(title='Atlas Long/Short Sinyali📶',defval=true,tooltip='ATLAS sistemine göre formüle edilmiş özel bir matematik hesabına dayanarak sinyal verir',group='Kondisyonlar') ato3=input.bool(title='Atlas Bulut⛅️',defval=false,tooltip='Bulut çizgileri destek,direnç ve olası dönüş kademelerini gösterir,bulutun rengi ise ana akım trendi belirlemede yardımcı olur',group='Trend Takipçilerinden Sadece Birini Seçin', inline='') ato5=input.bool(title='Atlas Mum Renkleri📊',defval=true,tooltip='Hacim ve momentuma göre renk değiştirir',group='Kondisyonlar',group='Kondisyonlar') ato2=input.bool(title='Atlas Lupus💥',defval=false,tooltip='Hızlı ortalama ile erken sinyal tespiti yapılabilir. Daha olgunlaşmamış ama erken trend tespiti yapar',group='Trend Takipçilerinden Sadece Birini Seçin', inline='') //ato1=input.bool(title='Atlas Lycaon Ortalama☄️',defval=false,tooltip='Yavaş ortalama ile güçlü sinyal tespiti yapılabilir. Daha olgunlaşmış ama geç trend sinyali verir.') //devam= input.bool(title='Devam Formasyonu 🐂/🐻',defval=false,tooltip='Geriçekilme ve devam etme ihtimallerini gösterir') ato7=input.bool(title='Gap/Açılış boşluğu',defval=false,tooltip='Açılışlar arasında gap denilen boşluklar oluşabilir, mum tekrar o boşluğu doldurmak için geri dönüş yaşaması beklenir') fibos=input.bool(title='Atlas Kademeleri🧮',defval=false,tooltip='Atlas Sayılarına göre Giriş,Çıkış ve Kâr al seviyelerini göstermektedir.',group='Kondisyonlar') harmo=input.bool(title='Harmonik Formasyonlar🆎',defval=false,tooltip='Fibonacci oranlarına göre harmonik formasyon tespitinde bulunur.',group='Kondisyonlar') //harmo=false verim=input.bool(title='Verimsiz Zaman⏳',defval=false,tooltip='Kriptolarda hacimsiz zamanları kırmızı\nVerimli zamanları yeşil ile renklendirir.') panelss=input.bool(title='Tarama Paneli 📓',defval=false,tooltip='Bir varlığı incelerken tarama panelinde aynı anda 4 farklı varlığı inceleyerek size long short sinyali verebilecek. 1 Ekran 4 Farklı enstrüman.',group='Kondisyonlar') show_chop = input.bool(title="Yatay Piyasa🧬",defval=false,tooltip='Piyasa yatay pozisyona geçtiğinde,mum renkleri siyah olur ve piyasanın belirsiz olduğu anlamına gelir',group='Kondisyonlar') yada2= input.bool(title='Geleceği Tahmin Et (AI) (Test Aşamasında)🧠',defval=false,tooltip='Sadece Teknik ve Temel veriler ışığında bir tahmin olduğunu unutmayın.Kritpo varlıklardan ziyade, En az günlük zaman dilimi ve hisselerde kullanmanız önerilir.', group='Kondisyonlar') //yada2=false retest= input.bool(title='Retest♻️', defval=false, tooltip='Destek ya da Direnç tekrar test edilir ve test harekete devam kondisyonunu tespit eder', group='Kondisyonlar') thema = (theme == "Aydınlık") ? 1 : (theme == "Karanlık") ? 2 : na // ato3 true ise ato2 false olsun/ if ato3 ato2 := false // ato2 true ise ato3 false olsun if ato2 ato3 := false // Eğer ikisi de true ise, her ikisini de false yap if ato3 and ato2 ato3 := true ato2 := false h_rma_8 = ta.rma(high, 8) h_rma_13 = ta.rma(high, 13) h_rma_21 = ta.rma(high, 21) h_rma_34 = ta.rma(high, 34) h_rma_55 = ta.rma(high, 55) h_rma_89 = ta.rma(high, 89) h_rma_avg = (h_rma_8 + h_rma_13 + h_rma_21 + h_rma_34 + h_rma_55+ h_rma_89) / 6 l_rma_8 = ta.rma(low, 8) l_rma_13 = ta.rma(low, 13) l_rma_21 = ta.rma(low, 21) l_rma_34 = ta.rma(low, 34) l_rma_55 = ta.rma(low, 55) l_rma_89 = ta.rma(low, 89) l_rma_avg = (l_rma_8 + l_rma_13 + l_rma_21 + l_rma_34 + l_rma_55 + l_rma_89) / 6 Atlas = (h_rma_avg + l_rma_avg) / 2 ////TRAILING SIMPLE UMA i_uma_trail = 'RMA' t_uma_bull_color = color.new(#5ee37c, 0) t_uma_bear_color = color.new(#fc52a7, 0) uma_trail = i_uma_trail == 'RMA' ? Atlas : na t_uma_89 = ta.vwma(uma_trail, 89) t_uma_55 = ta.vwma(uma_trail, 55) t_uma_34 = ta.vwma(uma_trail, 34) t_uma_21 = ta.vwma(uma_trail, 21) t_uma_13 = ta.vwma(uma_trail, 13) t_uma_8 = ta.vwma(uma_trail, 8) t_uma_avg = (t_uma_8 + t_uma_13 + t_uma_21 + t_uma_34 + t_uma_55 + t_uma_89) / 6 //p_uma_trail = plot(ato1?t_uma_avg:na, color=uma_trail > t_uma_avg ? t_uma_bull_color : t_uma_bear_color, linewidth=2, title='ATLAS MA',editable=false) // //barcolor ////BASELINE bline_on_off = true bline_src = close bline_type = 'RMA' Batuhan = 41 //Batuhan = input.int(title='Length', defval=41, group='Mum Renkleri',tooltip='Sabit bırakılması önerilir (41)') ////MOVING AVERAGES CALCULATIONS bline_ma(bline_type, bline_src, Batuhan) => float result = 0 if bline_type == 'RMA' result := ta.rma(bline_src, Batuhan) result baseline = bline_ma(bline_type, bline_src, Batuhan) ////////////////////////////////////////////////////////////////////////////////// ////MOVING AVERAGE src = ohlc4 ma_type = 'RMA' lkbk =8 ////MOVING AVERAGES CALCULATIONS ma(type, src, lkbk) => float result = 0 if type == 'RMA' result := ta.rma(src, lkbk) result moving_avg = ma(ma_type, src, lkbk) //////////////////////////////////////////////////////////////////////////////// ////AWESOME OSCILLATORS //fast moving average ao_ma = src - moving_avg //baseline ao_baseline = bline_src - baseline //awesome oscillator of fast moving average vs. baseline ao = moving_avg - baseline //RSI len = 14 up = ta.rma(math.max(ta.change(src), 0), len) down = ta.rma(-math.min(ta.change(src), 0), len) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) plotshape(rsi <15,style=shape.triangleup, location=location.belowbar, color=(thema==1?color.new(#32ff39, 0):color.new(#53f5da, 0)), size=size.tiny,editable=false) plotshape(rsi >88,style=shape.triangledown, location=location.abovebar, color=(thema==1?color.new(#ff4444, 0):color.new(#ff4894, 0)), size=size.tiny,editable=false) yorgunayi=rsi <15 yorgunboga=rsi >88 //RSIEND //CHOPSTART cae_len = 21 cae_src = hlcc4 ch_ut=55 ch_lt=34 cae_up = ta.rma(math.max(ta.change(cae_src), 0), cae_len) cae_down = ta.rma(-math.min(ta.change(cae_src), 0), cae_len) cae_rsi = cae_down == 0 ? 100 : cae_up == 0 ? 0 : 100 - (100 / (1 + cae_up / cae_down)) var is_chop = false var float chop_beg_h = na var float chop_beg_l = na var box chop_box = na var chop_cond = false chop_cond:= cae_rsi >= ch_lt and cae_rsi <= ch_ut if chop_cond and not is_chop[1] is_chop := true chop_beg_h:=high chop_beg_l:=low //chop_box := show_chop? box.new(bar_index, chop_beg_h, bar_index, chop_beg_l, bgcolor=color.new(#4b9ed4, 70), border_color=color.black):na else if chop_cond and is_chop[1] and is_chop box.set_right(chop_box, bar_index) if high>chop_beg_h box.set_top(chop_box, high) chop_beg_h:=high if low= 50 : ta.mfi(hlc3, AP) >= 50) ? upT < nz(AtlasT[1]) ? nz(AtlasT[1]) : upT : downT > nz(AtlasT[1]) ? nz(AtlasT[1]) : downT color1 = AtlasT > AtlasT[2] ? #00E60F : AtlasT < AtlasT[2] ? #80000B : AtlasT[1] > AtlasT[3] ? #00E60F : #80000B buySignalk = ta.crossover(AtlasT, AtlasT[2]) sellSignalk = ta.crossunder(AtlasT, AtlasT[2]) K1 = ta.barssince(buySignalk) K2 = ta.barssince(sellSignalk) O1 = ta.barssince(buySignalk[1]) O2 = ta.barssince(sellSignalk[1]) //PZT = dayofweek == dayofweek.tuesday and time(timeframe.period, "2000-2400") wk = ((dayofweek == dayofweek.monday and not time(timeframe.period, "0000-0300"))or dayofweek == dayofweek.tuesday or dayofweek == dayofweek.wednesday or dayofweek == dayofweek.thursday or dayofweek == dayofweek.friday) wknd = (dayofweek == dayofweek.saturday or dayofweek == dayofweek.sunday or dayofweek == dayofweek.monday and time(timeframe.period, "0000-0300")) //bgcolor(wk and verim ? color.new(#92ff52, 100) : wknd and verim?color.new(color.red,90):na) ////CANDLE COLOR/ i_cc_selection = 'Baseline | Center Line' cc_bline_up = color.new(#95ff00, 0) cc_ao_up = color.new(#00bcd4, 0) cc_neut = color.new(#787b86, 0) cc_bline_down = color.new(#ff0000, 0) cc_ao_down = color.new(#e91e63, 0) cc_1 = rsi>40 and rsi<60?color.gray:ao_baseline > 0 ? cc_bline_up : ao_baseline < 0 ? cc_bline_down : cc_neut cc_2 =ao_baseline > 0 ? cc_bline_up : ao_baseline < 0 ? cc_bline_down :cc_neut //barcolor(ato5 ? cc_1 : na, title='Colored Candles',editable=false) // inputs // //{ trailType = 'modified' //ATRPeriod = input(21, 'Period',group='HTF/LTF Ayarları', tooltip='15 Dakika : 13\n1 Saat : 21\n4 Saat : 21\n1 Gün : 7\n1 Hafta : 7\n1 Ay : 1') //ATRFactor = input.float(7, 'Bulut Çarpanı',step=0.1,group='HTF/LTF Ayarları',tooltip='15 Dakika : 8\n1 Saat : 6\n4 Saat : 7\n1 Gün : 6\n1 Hafta : 1\n1 Ay : 0.8') ATRPeriod = 55 ATRFactor = 7 norm_o = request.security(ticker.new(syminfo.prefix, syminfo.ticker), timeframe.period, open) norm_h = request.security(ticker.new(syminfo.prefix, syminfo.ticker), timeframe.period, high) norm_l = request.security(ticker.new(syminfo.prefix, syminfo.ticker), timeframe.period, low) norm_c = request.security(ticker.new(syminfo.prefix, syminfo.ticker), timeframe.period, close) //} //////// FUNCTIONS ////////////// //{ // Wilders ma // Wild_ma(_src, _malength) => _wild = 0.0 _wild := nz(_wild[1]) + (_src - nz(_wild[1])) / _malength _wild /////////// TRUE RANGE CALCULATIONS ///////////////// HiLo = math.min(norm_h - norm_l, 1.5 * nz(ta.vwma(norm_h - norm_l, ATRPeriod))) HRef = norm_l <= norm_h[1] ? norm_h - norm_c[1] : norm_h - norm_c[1] - 0.5 * (norm_l - norm_h[1]) LRef = norm_h >= norm_l[1] ? norm_c[1] - norm_l : norm_c[1] - norm_l - 0.5 * (norm_l[1] - norm_h) trueRange = trailType == 'modified' ? math.max(HiLo, HRef, LRef) : math.max(norm_h - norm_l, math.abs(norm_h - norm_c[1]), math.abs(norm_l - norm_c[1])) //} /////////// TRADE LOGIC //////////////////////// //{ loss = ATRFactor * Wild_ma(trueRange, ATRPeriod) Up = norm_c - loss Dn = norm_c + loss TrendUp = Up TrendDown = Dn Trend = 1 TrendUp := norm_c[1] > TrendUp[1] ? math.max(Up, TrendUp[1]) : Up TrendDown := norm_c[1] < TrendDown[1] ? math.min(Dn, TrendDown[1]) : Dn Trend := norm_c > TrendDown[1] ? 1 : norm_c < TrendUp[1] ? -1 : nz(Trend[1], 1) trail = Trend == 1 ? TrendUp : TrendDown ex = 0.0 ex := ta.crossover(Trend, 0) ? norm_h : ta.crossunder(Trend, 0) ? norm_l : Trend == 1 ? math.max(ex[1], norm_h) : Trend == -1 ? math.min(ex[1], norm_l) : ex[1] //} // //////// PLOT TP and SL ///////////// //{ plot(ato3?trail:na, style=plot.style_line, color=Trend == 1 ? color.green : Trend == -1 ? color.red : na,editable=false) plot(ato3?ex:na, style=plot.style_circles, color=Trend == 1 ? color.lime : Trend == -1 ? color.fuchsia : na,editable=false) //} ////// FIBONACCI LEVELS /////////// //{ state = Trend == 1 ? 'long' : 'short' fib1Level = 76.8 fib2Level = 88.6 fib3Level = 100 f1 = ex + (trail - ex) * fib1Level / 100 f2 = ex + (trail - ex) * fib2Level / 100 f3 = ex + (trail - ex) * fib3Level / 100 l100 = trail + 0 Fib1 = plot(ato3?f1:na, style=plot.style_line,color=(thema==1?color.new(#7d59ff, 0):color.new(#ffc444, 0)),editable=false) Fib2 = plot(ato3?f2:na,style=plot.style_line, color=thema==1?color.new(color.black, 0):color.new(color.lime,0),editable=false) Fib3 = plot(ato3?f3:na, style=plot.style_line, color=color.new(color.aqua, 0),linewidth=2,editable=false) L100 = plot(ato3?l100:na, style=plot.style_line, color=thema==1?color.new(color.black, 0):color.new(color.lime,0),editable=false) fill(Fib1, Fib2, color=state == 'long' ? thema==1?color.new(#61e6e6, 55):color.new(color.green,85): state == 'short' ? thema==1?color.new(#e66161, 55):color.new(#af4c89, 85): na,editable=false) fill(Fib2, Fib3, color=state == 'long' ? color.new(color.green, 75) : state == 'short' ? color.new(color.red, 75) : na,editable=false) fill(Fib3, L100, color=state == 'long' ? color.new(color.green, 65) : state == 'short' ? color.new(color.red, 65) : na,editable=false) l1 = state[1] == 'long' and ta.crossunder(norm_c, f1[1]) l2 = state[1] == 'long' and ta.crossunder(norm_c, f2[1]) l3 = state[1] == 'long' and ta.crossunder(norm_c, f3[1]) s1 = state[1] == 'short' and ta.crossover(norm_c, f1[1]) s2 = state[1] == 'short' and ta.crossover(norm_c, f2[1]) s3 = state[1] == 'short' and ta.crossover(norm_c, f3[1]) atr = ta.rma(trueRange, 13) /////////// FIB PLOTS /////////////////. //alertcondition(fixnan(f1) != fixnan(f1[1]), title='Trend Değişimi', message='Trend Değişti') //----------------------------------------------------------------------------------------------------------------------------------------------------------------- // //Range Size Function rng_size(x, qty, n) => // AC = Cond_EMA(abs(x - x[1]), 1, n) wper = n * 2 - 1 avrng = ta.ema(math.abs(x - x[1]), n) AC = ta.ema(avrng, wper) * qty rng_size = AC rng_size //Range Filter Function rng_filt(x, rng_, n) => r = rng_ var rfilt = array.new_float(2, x) array.set(rfilt, 1, array.get(rfilt, 0)) if x - r > array.get(rfilt, 1) array.set(rfilt, 0, x - r) if x + r < array.get(rfilt, 1) array.set(rfilt, 0, x + r) rng_filt1 = array.get(rfilt, 0) hi_band = rng_filt1 + r lo_band = rng_filt1 - r rng_filt = rng_filt1 [hi_band, lo_band, rng_filt] //----------------------------------------------------------------------------------------------------------------------------------------------------------------- //Definitions //----------------------------------------------------------------------------------------------------------------------------------------------------------------- siglen=ATRPeriod sigatr=7.2 //Range Filter Values [h_band, l_band, filt] = rng_filt(src, rng_size(src, sigatr, siglen), siglen) //Direction Conditions var fdir = 0.0 fdir := filt > filt[1] ? 1 : filt < filt[1] ? -1 : fdir upward = fdir == 1 ? 1 : 0 downward = fdir == -1 ? 1 : 0 //Trading Condition longCond = src > filt and src > src[1] and upward > 0 or src > filt and src < src[1] and upward > 0 shortCond = src < filt and src < src[1] and downward > 0 or src < filt and src > src[1] and downward > 0 CondIni = 0 CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1] //atlasteyit dlen = 13 dchannel(len) => float hh = ta.highest(len) float ll = ta.lowest(len) int trenda = 0 trenda := hlc3 > hh[1] ? 1 : hlc3 < ll[1] ? -1 : nz(trenda[1]) trenda dchannelalt(len, maintrend) => float hh = ta.highest(len) float ll = ta.lowest(len) int trenda = 0 trenda := hlc3 > hh[1] ? 1 : hlc3 < ll[1] ? -1 : nz(trenda[1]) maintrend == 1 ? trenda == 1 ? #95ff00 : #5d9f00 : maintrend == -1 ? trenda == -1 ? #FF0000ff : #8c0101 : na maintrend = dchannel(dlen) //TEYİT //atlasteyitbitti //HARMONİKLER import reees/TA/85 as t import reees/Draw/27 as draw import reees/Utilities/5 as u import reees/Pattern/1 as p import reees/Obj_XABCD_Harmonic/10 as h //import reees/Algebra/3 as alg //----------------------------------------- // inputs and vars //----------------------------------------- // Pattern Type Inputs var bullOn = true var bearOn = true var incOn = false var hsOn = true var i_lb = true var i_lbn = 55 var gartOn = true var gart_t1 = ".618 AD" var gart_t2 = "1.272 AD" var batOn = true var bat_t1 = ".618 AD" var bat_t2 = "1.272 AD" var bflyOn = true var bfly_t1 = ".618 AD" var bfly_t2 = "1.272 AD" var crabOn = true var crab_t1 = ".618 AD" var crab_t2 = "1.618 AD" var sharkOn = false var shark_t1 = ".382 AD" var shark_t2 = "C" var cyphOn = true var cyph_t1 = ".618 CD" var cyph_t2 = "1.618 XA" // Entry/Stop Inputs var e_afterC = true var e_lvlc = "Nearest confluent PDB level" var e_aboveC = 96 var e_afterD = true var e_lvldPct = 0.5 var e_aboveD = 96 var e_tLimit =0.5 var stopPct = 2 var stopB ="% of distance to target 1, beyond entry" // Pattern Inputs var t_b = 1 var pctErr = 15 var pctAsym = 250 var w_e = 4.0 //var w_a = input.float(0.0,"Weight",step=.1,minval=0.0,group = "Harmonik Formasyonlar",inline="asym",tooltip="A leg is considered valid if its length (ΔX/number of bars) is within this % of the average length of the other legs in the pattern. Weight determines the weight of length asymmetry in the total score calculation for a pattern.") var tLimitMult = 1 var w_p = 2.0 var w_d = 3.0 // Alert Inputs //var a_on = input.bool(true, "Alert", inline="alert", group="Alerts") var a_type = "Both" // Display Inputs var c_bline = color.new(#6aff00,20) var c_beline = color.new(#ff0000,20) var c_blab = color.new(#6aff00,55) var c_belab = color.new(#ff0000,55) var l_txt = color.new(color.white,0) var int[] includeTps = array.new_int() if barstate.isfirst and harmo if gartOn and harmo array.push(includeTps,1) if batOn and harmo array.push(includeTps,2) if bflyOn and harmo array.push(includeTps,3) if crabOn and harmo array.push(includeTps,4) if sharkOn and harmo array.push(includeTps,5) if cyphOn and harmo array.push(includeTps,6) var h.harmonic_params params = h.init_params(pctErr,pctAsym,includeTps,w_e,w_p,w_d) // scoring and validation parameters for xabcd_harmonic objects // xabcd_harmonic object pointers var h.xabcd_harmonic[] bullGart = array.new() var h.xabcd_harmonic[] bullBat = array.new() var h.xabcd_harmonic[] bullBfly = array.new() var h.xabcd_harmonic[] bullCrab = array.new() var h.xabcd_harmonic[] bullShark = array.new() var h.xabcd_harmonic[] bullCyph = array.new() var h.xabcd_harmonic[] bearGart = array.new() var h.xabcd_harmonic[] bearBat = array.new() var h.xabcd_harmonic[] bearBfly = array.new() var h.xabcd_harmonic[] bearCrab = array.new() var h.xabcd_harmonic[] bearShark = array.new() var h.xabcd_harmonic[] bearCyph = array.new() // var int[] lastX = array.new_int(5,0) // temp/last/incomplete pattern structures var h.xabcd_harmonic[] pending = array.new() var label[] fullIpL = array.new_label(0) var line[] fullIpLn = array.new_line(0) var linefill[] fullIpLf = array.new_linefill(0) var h.xabcd_harmonic[] inc = array.new() var int[] inc_lastX = array.new_int(4,0) // Stat totals var int[] pTot = array.new_int(0) var int[] tTot = array.new_int(0) var float[] t1Tot = array.new_float(0) var float[] t2Tot = array.new_float(0) var float[] arTot = array.new_float(0) var float[] trTot = array.new_float(0) //----------------------------------------- // functions //----------------------------------------- // Type of harmonic pat // Assumes pattern is complete, and therefore only one can be true tp(h1,h2,h3,h4,h5,h6) => switch h1 => 1 h2 => 2 h3 => 3 h4 => 4 h5 => 5 => 6 nToArray(n) => switch n "a1" => bullGart "a2" => bullBat "a3" => bullBfly "a4" => bullCrab "a5" => bullShark "a6" => bullCyph "b1" => bearGart "b2" => bearBat "b3" => bearBfly "b4" => bearCrab "b5" => bearShark "b6" => bearCyph typeToArray(t,tp) => n = (t ? "a" : "b") + str.tostring(tp) nToArray(n) t1(tp) => switch tp 6 => cyph_t1 5 => shark_t1 4 => crab_t1 3 => bfly_t1 2 => bat_t1 => gart_t1 t2(tp) => switch tp 6 => cyph_t2 5 => shark_t2 4 => crab_t2 3 => bfly_t2 2 => bat_t2 => gart_t2 // get target targets(tp) => [t1(tp),t2(tp)] harmonic_xabcd_targets(tp,xY,aY,bY,cY,dY) => tgt1 = t1(tp) tgt2 = t2(tp) [t1,t2,_] = t.harmonic_xabcd_targets(xY,aY,bY,cY,dY,tgt1,tgt2) [t1,t2] // Timeout period tLimit(xX,dX) => int((dX - xX)*tLimitMult) incTLimit(xX,cX) => avg = (cX-xX)/3 int(avg * (1 + pctAsym/100)) // time out after max possible bars based on asymmetry parameter // Entry has timed out eTimeout(xX,dX) => bar_index - dX > int((dX - xX)*e_tLimit) // Pattern still active within timeout period stillActive(xX,dX) => bar_index - tLimit(xX,dX) <= dX and eTimeout(xX,dX) == false // make sure score is high enough to enter a trade noEntry(h.xabcd_harmonic p) => not na(p.d.x) ? p.score < (e_aboveD/100) : p.score < (e_aboveC/100) entry(p) => if noEntry(p) and harmo [na,na,na] else t.harmonic_xabcd_entry(p.bull,p.tp,p.x.y,p.a.y,p.b.y,p.c.y,p.d.y,e_afterC,e_lvlc,e_afterD,e_lvldPct) // Determine if entry level was reached entryHit(p) => if p.eHit or p.eHit == false and harmo [p.eHit,p.e.x,p.e.y] else if (not na(p.d.x) and eTimeout(p.x.x,p.d.x)) or noEntry(p) and harmo [false,na,na] else [_,afterC,afterD] = entry(p) [eH,eX,eY] = t.xabcd_entryHit(p.bull, afterC, afterD, p.d.x, e_afterC, e_afterD, t_b) if not na(eY) and ((p.bull and p.t1eY)) and harmo [na,na,na] else [eH==false?na:eH,eX,eY] // Determine if pattern has succeeded or failed, or neither (na) success(p) => // if stop or target 2 already hit, nothing to check if p.sHit or p.t2Hit and harmo [p.t1Hit,p.t2Hit,p.sHit,na,na,na,na] // if within time limit and trade active / entry hit, check targets/stop else if bar_index <= (p.d.x + tLimit(p.x.x,p.d.x)) and p.eHit and harmo t.tradeClosed(p.e.x,p.e.y,p.stop,p.t1Hit,p.t2Hit,p.t1,p.t2) // else nothing to update else [p.t1Hit,p.t2Hit,p.sHit,na,na,na,na] alertMsg(p) => if na(p.d.x) and harmo "Potansiyel " + h.get_name(p) + " oluşumu gözlendi." else h.get_name(p) + " oluştu." deleteFip() => for lbl in fullIpL label.delete(lbl) array.clear(fullIpL) // for ln in fullIpLn line.delete(ln) array.clear(fullIpLn) // for lf in fullIpLf linefill.delete(lf) array.clear(fullIpLf) removePending(pid) => if array.size(pending) > 0 for i=0 to array.size(pending)-1 p = array.get(pending,i) if p.pid == pid if i == array.size(pending)-1 deleteFip() array.remove(pending,i) break successTxt(p) => if p.t2Hit and harmo " (🎯Ulaşılan Seviye - Hedef 1, Hedef 2✅✅)" else if p.t1Hit and harmo " (🎯Ulaşılan Seviye - Hedef 1✅)" else if p.sHit and harmo " (Başarısız / Stop❌)" else if noEntry(p) and stillActive(p.x.x,p.d.x) and harmo " (Giriş Yok⛔)" else if (p.eHit==false or na(p.eHit)) and stillActive(p.x.x,p.d.x) == false and harmo " (Kaçırılan giriş⛔)" else if na(p.eHit) and stillActive(p.x.x,p.d.x) and harmo " (Giriş bekleniyor⌛️)" else if na(p.t1Hit) and stillActive(p.x.x,p.d.x) and harmo " (Hedefe ulaşması bekleniyor)" else " (Giriş Zamanı geçti⛔)" ratToStr(r) => na(r) ? "NA " : str.tostring(r, "0.000") reToStr(r) => na(r) ? "NA " : str.tostring(r, "0.0") + "%" // Pattern tooltip ttTxt(p) => [rb,rc,rd1,rd2] = t.harmonic_xabcd_fibDispTxt(p.tp) [_,_,e] = entry(p) l1 = h.get_name(p) + successTxt(p) + "\n\n" l2 = (p.invalid_d?"Tamamlanmamış":"Toplam") + " Skor: " + str.tostring(p.score*100,"#.##") + "\n" l3 = "Bacak geri çekilme doğruluğu: " + str.tostring((1-p.score_eAvg)*100, "#.##") + "%\n" //l42 = "Potansiyel Dönüş Bölgesi seviyesi birleşimi: " + (p.tp==6 ? "NA" : (str.tostring(p.score_prz*100, "#.##") + "%")) + "\n" //l43 = "D noktasının Potansiyel Dönüş Bölgesi ile kesişmesi: " + (p.invalid_d?"D doğrulanmadı":str.tostring((1-p.score_eD)*100, "#.##") + "%") +"\n" //l5 = "\n Gerçekleşen Oran % Sapma Oranı Teorik\n" //l6 = "AB/XA " + str.tostring(p.r_xb, "0.000") + " " + (p.tp==5 ? "NA " : (str.tostring(p.re_xb*100, "00.0")+"%")) + " " + rb + "\n" //l7 = "BC/AB " + str.tostring(p.r_ac, "0.000") + " " + str.tostring(p.re_ac*100, "00.0") + "% " + rc + "\n" //l8 = "CD/BC " + ratToStr(p.r_bd) + " " + (p.tp==6 ? "NA " : reToStr(p.re_bd*100)) + " " + rd1 + "\n" //l9 = (p.tp==6 ? "CD/XC " : "AD/XA ") + ratToStr(p.r_xd) + " " + reToStr(p.re_xd*100) + " " + rd2 + "\n" l91 = "\n✅Hedef 1: " + str.tostring(p.t1,"#.##") + "\n✅Hedef 2: " + str.tostring(p.t2,"#.##") l92 = "\n🚪Giriş: " + str.tostring(na(p.e.y)?e:p.e.y,"#.##") l93 = na(p.stop) ? "" : "\n❌Stop: " + str.tostring(p.stop,"#.##") l1 + l2 + l3 + l92 + l93 + l91 // status(p) => if p.t2Hit and harmo " ✅✅" else if p.t1Hit and harmo " ✅" else if p.sHit and harmo " ❌" else if stillActive(p.x.x,p.d.x) == false and (p.eHit == false or na(p.eHit)) and harmo " ⛔" else if stillActive(p.x.x,p.d.x) and noEntry(p) and harmo " ⛔" else if stillActive(p.x.x,p.d.x) and harmo " ⏳" else " 🕝🏃" lbTxt(p,status) => t.harmonic_xabcd_symbol(p.tp) + " " + str.tostring(math.round(p.score,3)*100) + status incLbTxt(p) => "Potansiyel " + t.harmonic_xabcd_symbol(p.tp) + " (" + str.tostring(p.score*100,"#.##") + ")" erasePattern(p) => h.erase_pattern(p) h.erase_label(p) deleteInc(string pid) => n = array.size(inc) if not na(pid) and n > 0 for j=0 to n-1 p = array.get(inc,j) if pid == p.pid array.remove(inc,j) erasePattern(p) break drawPattern(p) => if incOn or not na(p.d.x) and harmo status = status(p) lbTxt = not na(p.d.x) ? lbTxt(p,status) : incLbTxt(p) [_,e,_] = entry(p) tt = not na(p.d.x) ? ttTxt(p) : draw.incTtTxt(p.tp,h.get_name(p),p.r_xb,p.re_xb,p.r_ac,p.re_ac,p.prz_bN,p.prz_bF,p.prz_xN,p.prz_xF,p.score,e) h.draw_pattern(p, p.bull?c_bline:c_beline) if p.invalid_d line.set_style(array.get(p.pLines,3),line.style_dashed) h.draw_label(p, p.bull?c_blab:c_belab, l_txt, lbTxt, tt) lowest(n, o=0) => if n >= o v = low[o] for i=o to n if low[i] < v v := low[i] v highest(n, o=0) => if n >= o v = high[o] for i=o to n if high[i] > v v := high[i] v notLast(p) => // check if not same pattern as last completed pattern of same type comp = typeToArray(p.bull,p.tp) h.xabcd_harmonic last = array.size(comp) == 0 ? na : array.get(comp,array.size(comp)-1) na(last) ? true : last.x.x!=p.x.x or last.a.x!=p.a.x or last.b.x!=p.b.x addIncompletePattern(t,h1,h2,h3,h4,h5,h6,xX,xY,aX,aY,bX,bY,cX,cY) => btps = array.from(h1,h2,h3,h4,h5,h6) tps = u.boolToIntArr(btps) lowest = lowest(bar_index-cX) highest = highest(bar_index-cX) int dX = na float dY = na // check if pattern already exists (incomplete or pending) exists = false iN = array.size(inc) iP = array.size(pending) if iN > 0 and harmo for i=0 to iN-1 p = array.get(inc,iN-1-i) // more likely to find it at top of stack if p.x.x==xX and p.a.x==aX and p.b.x==bX if p.c.x == cX exists := true else // if new point C, delete the old inc pattern in favor of this one array.remove(inc,iN-1-i) erasePattern(p) break if exists==false and iP > 0 and harmo for i=0 to iP-1 p = array.get(pending,iP-1-i) if p.x.x==xX and p.a.x==aX and p.b.x==bX and p.c.x==cX exists := true break if exists == false and harmo // add separate incomplete pattern for each potential harmonic type for tpe in tps tp = tpe+1 if exists == false pat = h.init(xX,xY,aX,aY,bX,bY,cX,cY,dX,dY,params,tp) if not na(pat) [_,eC,_] = entry(pat) if na(eC) or (not na(eC) and ((t and eC < lowest) or (t==false and eC > highest))) if notLast(pat) array.push(inc,pat) if incOn and (not na(eC) or not e_afterC) drawPattern(pat) if a_type == "Potansiyel patterns" or a_type == "Both" alert(alertMsg(pat),alert.freq_once_per_bar_close) // temporarily changing to fire on bar close until real-time bar multiple alert issue is resolved setTargets(p) => [t1,t2] = targets(p.tp) h.set_target(p,1,calc_target=t1) h.set_target(p,2,calc_target=t2) incPid(p) => str.tostring(p.tp) + "_" + str.tostring(p.x.x) + "_" + str.tostring(p.a.x) + "_" + str.tostring(p.b.x) + "_" + str.tostring(p.c.x) + "_" + str.tostring(na) // Draw completed pattern and update data structures addCompleted(p,force=false) => if hsOn==false or noEntry(p)==false and harmo a = typeToArray(p.bull,p.tp) array.push(a,p) // add pattern // check if we need to delete incomplete pattern, only if not already adding from an incomplete pattern and allowing entry after D // (otherwise keep incomplete pattern to continue checking for entry after C) if force == false if e_afterD deleteInc(incPid(p)) p.invalid_d := false setTargets(p) drawPattern(p) [upper,lower] = t.harmonic_xabcd_przRange(p.prz_bN,p.prz_bF,p.prz_xN,p.prz_xF) p.stop := t.harmonic_xabcd_stop(stopB,stopPct,p.bull,p.x.y,p.d.y,upper,lower,p.t1,p.e.y) if noEntry(p)==false array.push(pending,p) // fire alert if appropriate if a_type == "Complete patterns" or a_type == "Both" alert(alertMsg(p),alert.freq_once_per_bar_close) // temporarily changing to fire on bar close until real-time bar multiple alert issue is resolved // Add pattern to completed pattern structures addValidPattern(p,force=false) => bool lasteH = na float lastScore = na h.xabcd_harmonic pat = na a = typeToArray(p.bull,p.tp) if array.size(a) > 0 and harmo // check last pattern of same type last = array.get(a,array.size(a)-1) lastScore := last.score // if A, B or C is different = new pattern if p.a.x!=last.a.x or p.b.x!=last.b.x or p.c.x!=last.c.x addCompleted(p,force) pat := p // if ABC are same but D is beyond last pattern's D, replace it with this one. We want to draw the // new/updated pattern and calculate its updated score, but maintain any entry/targets that have // already been hit. else if (p.bull and p.d.y < last.d.y) or (p.bull==false and p.d.y > last.d.y) if (last.score <= p.score) or force or last.invalid_d // update if new pattern has a higher score, last pattern had invalid D, or forcing from entry After Point C if last.eHit // IF last pattern entry was already hit, use the last pattern lasteH := true if force==false last.invalid_d := false h.init(last.x.x,last.x.y,last.a.x,last.a.y,last.b.x,last.b.y,last.c.x,last.c.y,p.d.x,p.d.y,params,last.tp,last) [upper,lower] = t.harmonic_xabcd_przRange(last.prz_bN,last.prz_bF,last.prz_xN,last.prz_xF) last.stop := t.harmonic_xabcd_stop(stopB,stopPct,last.bull,last.x.y,last.d.y,upper,lower,last.t1,last.e.y) drawPattern(last) // redraw with new D setTargets(last) // reset targets for new D pat := last else // ELSE, replace last pattern with the new pattern removePending(last.pid) erasePattern(array.pop(a)) addCompleted(p,force) pat := p else addCompleted(p,force) pat := p // Update newly added pattern if not na(pat) and harmo // update entry, if necessary if lasteH draw.eHitLbl(pat.e.x,pat.e.y,pat.d.x,pat.d.y,p.bull,true) else [eHit,eX,eY] = entryHit(p) if eHit pat.eHit := true pat.e.x := eX pat.e.y := eY draw.eHitLbl(eX,eY,pat.d.x,pat.d.y,pat.bull) h.draw_label(p, p.bull?c_blab:c_belab, l_txt, lbTxt(p,status(p)), ttTxt(p)) "" updatePendingPatterns() => h.xabcd_harmonic[] new = array.new() if array.size(pending) > 0 and harmo for i=0 to array.size(pending)-1 ip = array.get(pending,i) [eH,eHx,eHy] = entryHit(ip) tLimit = tLimit(ip.x.x,ip.d.x) expired = bar_index == (ip.d.x + tLimit + 1) or eH==false [t1h,t2h,sH,t1x,t1y,t2x,t2y] = success(ip) // if time has expired or there's nothing left to update, no longer pending if not (expired or (eH and (not na(t2h) or t1h == false or sH))) array.push(new,ip) // if anything to update, update completed array entry and label if necessary if expired or (eH and ((not na(t1h) and na(ip.t1Hit)) or (not na(t2h) and na(ip.t2Hit)))) or (eH != ip.eHit) or (eH and na(ip.eHit)) or (eH==false and na(ip.eHit)) or sH if (eH or eH==false) and na(ip.eHit) ip.eHit := eH ip.e.x := eHx ip.e.y := eHy draw.eHitLbl(eHx,eHy,ip.d.x,ip.d.y,ip.bull) // targets will be na if eH==false, so no need to also check eH if t1h and na(ip.t1Hit) ip.t1Hit := true draw.tHitLbl(t1x,t1y,eHx,eHy,ip.bull) else if t1h == false ip.t1Hit := false draw.sHitLbl(t1x,t1y,eHx,eHy,ip.bull) // only draw stop X if no target was already hit if sH ip.sHit := true //draw.sHitLbl(bar_index,ip.stop,eHx,eHy,ip.bull) if t2h ip.t2Hit := true draw.tHitLbl(t2x,t2y,eHx,eHy,ip.bull) h.draw_label(ip, ip.bull?c_blab:c_belab, l_txt, lbTxt(ip,status(ip)), ttTxt(ip)) new updateIncompletePatterns() => h.xabcd_harmonic[] new = array.new() if array.size(inc) > 0 and harmo for p in inc [upper,lower] = t.harmonic_xabcd_przRange(p.prz_bN,p.prz_bF,p.prz_xN,p.prz_xF) tLimit = incTLimit(p.x.x,p.c.x) [eH,eHx,eHy] = entryHit(p) if eH and e_afterC if notLast(p) p.d.x := eHx p.d.y := eHy p.invalid_d := true erasePattern(p) addValidPattern(p,true) else erasePattern(p) // Don't keep incomplete pattern if it's timed out or has been invalidated else if bar_index == (p.c.x + tLimit + 1) or (p.bull and (high > p.c.y or low < lower)) or (p.bull==false and (low < p.c.y or high > upper)) erasePattern(p) else array.push(new,p) new drawFullInProgress() => if array.size(pending) > 0 and harmo last = array.get(pending,array.size(pending)-1) if not na(last.d.x) bb = last_bar_index - last.d.x tLimit = tLimit(last.x.x,last.d.x) // Only draw if... if bb <= tLimit // within pattern time limit and and noEntry(last)==false // entry is possible and and (eTimeout(last.x.x,last.d.x)==false or last.eHit) // entry has not timed out and //and (na(last.t1Hit) or (last.t1Hit and na(last.t2Hit))) and not last.t2Hit // targets remain to be hit and and not last.sHit // stop has not been hit deleteFip() // delete previously drawn completed pattern in progress [highest,lowest] = t.harmonic_xabcd_przRange(last.prz_bN,last.prz_bF,last.prz_xN,last.prz_xF) [bcNt,_] = harmonic_xabcd_targets(last.tp,last.x.y,last.a.y,last.b.y,last.c.y,last.prz_bN) [bcFt,_] = harmonic_xabcd_targets(last.tp,last.x.y,last.a.y,last.b.y,last.c.y,last.prz_bF) [xaNt,_] = harmonic_xabcd_targets(last.tp,last.x.y,last.a.y,last.b.y,last.c.y,last.prz_xN) [xaFt,_] = harmonic_xabcd_targets(last.tp,last.x.y,last.a.y,last.b.y,last.c.y,last.prz_xF) stop = last.stop [e,_,_] = entry(last) entry = na(last.e.y) ? e : last.e.y [ln,lb,lf] = draw.xabcd_inProgress(last.bull,last.tp,tLimit>500?500:tLimit,entry,stop,last.t1,last.t2,bcNt,bcFt,xaNt,xaFt, last.x.x,last.x.y,last.a.y,last.b.x,last.b.y,last.c.y,last.d.x,last.d.y,c_bline,c_beline,l_txt) for l in ln array.push(fullIpLn,l) for l in lb array.push(fullIpL,l) for l in lf array.push(fullIpLf,l) else deleteFip() else deleteFip() rowValues(tp) => a1 = typeToArray(true,tp) a2 = typeToArray(false,tp) float[] ra = array.new_float(0) t1_tot = 0 t2_tot = 0 closed = 0 if array.size(a1) > 0 and harmo for p in a1 if (not na(p.t1Hit) or p.sHit) and p.eHit if p.t2Hit r = (p.t2/p.e.y) - 1 array.push(ra,r) t2_tot+=1 t1_tot+=1 closed+=1 else if p.t1Hit r = (p.t1/p.e.y) - 1 array.push(ra,r) t1_tot+=1 closed+=1 else if p.sHit r = (p.stop/p.e.y) - 1 array.push(ra,r) closed+=1 //for p in a2 if array.size(a2) > 0 and harmo for p in a2 if (not na(p.t1Hit) or p.sHit) and p.eHit if p.t2Hit r = (p.e.y/p.t2) - 1 array.push(ra,r) t2_tot+=1 t1_tot+=1 closed+=1 else if p.t1Hit r = (p.e.y/p.t1) - 1 array.push(ra,r) t1_tot+=1 closed+=1 else if p.sHit r = (p.e.y/p.stop) - 1 array.push(ra,r) closed+=1 tot = array.size(a1) + array.size(a2) array.push(pTot,tot) array.push(tTot,closed) if closed > 0 array.push(t1Tot,(t1_tot/closed)*100) array.push(t2Tot,(t2_tot/closed)*100) if not na(array.avg(ra)) array.push(arTot,array.avg(ra)*100) if not na(array.sum(ra)) array.push(trTot,array.sum(ra)*100) st1 = closed>0 ? str.tostring((t1_tot/closed)*100,"#.##")+"%" : "NA" st2 = closed>0 ? str.tostring((t2_tot/closed)*100,"#.##")+"%" : "NA" ravg = not na(array.avg(ra)) ? str.tostring(array.avg(ra)*100,"#.##")+"%" : "NA" rtot = not na(array.sum(ra)) ? str.tostring(array.sum(ra)*100,"#.##")+"%" : "NA" [str.tostring(tot),str.tostring(closed),st1,st2,ravg,rtot] printStats() => if barstate.islast and harmo nR = array.size(includeTps) + 3 r = 0 for tp in includeTps r+=1 [tot,trd,st1,st2,ar,tr] = rowValues(tp) r+=1 t1Total = not na(array.avg(t1Tot)) ? (str.tostring(array.avg(t1Tot),"#.##") + "%") : "NA" t2Total = not na(array.avg(t2Tot)) ? (str.tostring(array.avg(t2Tot),"#.##") + "%") : "NA" arTotal = not na(array.avg(arTot)) ? (str.tostring(array.avg(arTot),"#.##") + "%") : "NA" trTotal = not na(array.sum(trTot)) ? (str.tostring(array.sum(trTot),"#.##") + "%") : "NA" r+=1 keyTxt = "✅ = Başarılı | ❌ = Başarısız | 🕝 = Süresi doldu* | ⛔ = Giriş Yapılmadı* | ⏳ = Devam ediyor* \n*Başarı Oranı/Getiri Yüzdesi istatistiklerine dahil değil" validD(p,dX,dY) => // If CD has valid length symmetry... if dX <= (incTLimit(p.x.x,p.c.x) + p.c.x) and harmo if t.pat_xabcd_testSym(p.a.x-p.x.x, p.b.x-p.a.x, p.c.x-p.b.x, p.d.x-p.c.x, pctAsym) highest = highest(bar_index-p.c.x,1) lowest = lowest(bar_index-p.c.x,1) // If no intermediate high/low invalidates the CD leg... if ((p.bull and dY <= lowest) or (p.bull==false and dY >= highest)) and ((p.bull and p.c.y >= highest) or (p.bull==false and p.c.y <= lowest)) // validate CD retracement for this pattern type xa = math.abs(p.x.y - p.a.y) bc = math.abs(p.b.y - p.c.y) cd = math.abs(p.c.y - dY) ad = math.abs(p.a.y - dY) xc = math.abs(p.x.y - p.c.y) tp = p.tp p_types = switch tp 1 => array.from(true,false,false,false,false,false) 2 => array.from(false,true,false,false,false,false) 3 => array.from(false,false,true,false,false,false) 4 => array.from(false,false,false,true,false,false) 5 => array.from(false,false,false,false,true,false) 6 => array.from(false,false,false,false,false,true) [t1,t2,t3,t4,t5,t6] = t.test_cd(cd,bc,xa,xc,ad,pctErr,p_types) t1 or t2 or t3 or t4 or t5 or t6 else false else false else false // Check for a valid pivot point D based on the pattern confirmation length parameter (i.e. checking bar_index[t_b]) checkForValidD() => x = bar_index[t_b] // bar of interest bool isLow = true bool isHigh = true l = low h = high // Validate pivot for i=0 to t_b-1 // check bars after potential pivot point if l[i] < l[t_b] isLow := false break if isLow // check bars before potential pivot point for i=t_b+1 to t_b+3 // need at least 3 bars before if l[i] < l[t_b] isLow := false break for i=0 to t_b-1 if h[i] > h[t_b] isHigh := false break if isHigh for i=t_b+1 to t_b+3 if h[i] > h[t_b] isHigh := false break // Validate pattern (CD leg) if isLow or isHigh h.xabcd_harmonic[] new = array.new() // Check incomplete patterns for p in inc if isLow and p.bull if validD(p, x, l[t_b]) array.push(new, h.init(p.x.x, p.x.y, p.a.x, p.a.y, p.b.x, p.b.y, p.c.x, p.c.y, x, l[t_b], params, p.tp)) if isHigh and p.bull==false if validD(p, x, h[t_b]) array.push(new, h.init(p.x.x, p.x.y, p.a.x, p.a.y, p.b.x, p.b.y, p.c.x, p.c.y, x, h[t_b], params, p.tp)) // Check completed pending patterns for p2 in pending if isLow and p2.bull if validD(p2, x, l[t_b]) array.push(new, h.init(p2.x.x, p2.x.y, p2.a.x, p2.a.y, p2.b.x, p2.b.y, p2.c.x, p2.c.y, x, l[t_b], params, p2.tp)) if isHigh and p2.bull==false if validD(p2, x, h[t_b]) array.push(new, h.init(p2.x.x, p2.x.y, p2.a.x, p2.a.y, p2.b.x, p2.b.y, p2.c.x, p2.c.y, x, h[t_b], params, p2.tp)) for n in new if not na(n) addValidPattern(n) // find new XABC (potential) pattern find_pattern(pl,t=true) => if ((t and bullOn) or (t==false and bearOn)) and harmo [f,xX,xY,aX,aY,bX,bY,cX,cY] = t.pat_xabcdIncomplete(t,pl) if f and (i_lb==false or bar_index >= last_bar_index-i_lbn) [h,h1,h2,h3,h4,h5,h6] = t.harmonic_xabcd_validateIncomplete(xX,xY,aX,aY,bX,bY,cX,cY,pctErr,pctAsym,gartOn,batOn,bflyOn,crabOn,sharkOn,cyphOn) if h addIncompletePattern(t,h1,h2,h3,h4,h5,h6,xX,xY,aX,aY,bX,bY,cX,cY) // Find XABCD patterns of various pivot lengths find(bull=true) => // Could probably do this more efficiently with recursion, but Pine prohibits it. Loops are all // top-tested though, so it's probably not as expensive as it looks. find_pattern(3,bull) find_pattern(4,bull) find_pattern(5,bull) find_pattern(6,bull) find_pattern(7,bull) find_pattern(8,bull) find_pattern(9,bull) find_pattern(10,bull) find_pattern(11,bull) find_pattern(12,bull) find_pattern(13,bull) find_pattern(14,bull) find_pattern(15,bull) find_pattern(16,bull) find_pattern(17,bull) find_pattern(18,bull) find_pattern(19,bull) find_pattern(20,bull) //----------------------------------------- // Main //----------------------------------------- // update patterns in progress inc := updateIncompletePatterns() // update potential/incomplete pattern pending := updatePendingPatterns() // update any completed patterns pending results // find new patterns find() // find bullish patterns find(false) // find bearish patterns checkForValidD() // last bar business if barstate.islast and harmo drawFullInProgress() // draw most recent complete pattern, if still in progress printStats() // compile stats and draw results table //HARMONİKLERBİTTİ ////SRZONES // ExtendLines1 = true ext_active = true ShowLabel = true label_loc ='Right' label_offset = 15 show_HL = true show_close = true LineStyleHLInput = 'Dotted' LineWidthHLInput = 1 LineStyleCloseInput = 'Dotted' LineWidthCloseInput = 1 var string LineStyleHL = na LineStyleHL := if LineStyleHLInput == 'Solid' line.style_solid else if LineStyleHLInput == 'Dotted' line.style_dotted else if LineStyleHLInput == 'Dashed' line.style_dashed var string LineStyleClose = na LineStyleClose := if LineStyleCloseInput == 'Solid' line.style_solid else if LineStyleCloseInput == 'Dotted' line.style_dotted else if LineStyleCloseInput == 'Dashed' line.style_dashed // Time Frame 1 = TF1 TF1_Menu = input.string(title='Göster/Gizle', defval='Kapalı', options=['Açık', 'Kapalı'], group='Destek/Direnç Alanı') TF1_input = input.string(title='Zaman Dilimi', defval='Chart', options=['Chart', '3d', '5d', '15d', '30d', '45d', '1s', '2s', '3s', '4s', '6s', '8s', '12s', 'GUNLUK', '3 GUN', 'HAFTA', '2 HAFTA', 'AYLIK'], group='Destek/Direnç Alanı') TF1_VolMA1Input = 6 TF1_NumZones = 30 TF1_extRight = false TF1_ResLinesColor = thema==2?color.new(#c03b3b, 0):color.new(#000000, 0) TF1_ResZoneColor = thema==2?color.new(color.red, 85):color.new(color.red, 70) TF1_SupLinesColor = thema==2?color.new(#00e61f, 0):color.new(#000000, 0) TF1_SupZoneColor = thema==2?color.new(color.lime, 85):color.new(color.lime, 70) // Time Frame 2 = TF2 TF2_Menu = 'Kapalı' TF2_input = '4h' TF2_VolMA1Input = 6 TF2_NumZones = 30 TF2_extRight = false TF2_ResLinesColor =color.new(color.fuchsia, 20) TF2_ResZoneColor =color.new(color.fuchsia, 90) TF2_SupLinesColor = color.new(color.green, 20) TF2_SupZoneColor = color.new(color.green, 90) TF2_Alerts = 'Kapalı' TF3_Menu = 'Kapalı' TF3_input = '4h' TF3_VolMA1Input = 6 TF3_NumZones = 30 TF3_extRight = false TF3_ResLinesColor =color.new(color.fuchsia, 20) TF3_ResZoneColor =color.new(color.fuchsia, 90) TF3_SupLinesColor = color.new(color.green, 20) TF3_SupZoneColor = color.new(color.green, 90) TF3_Alerts = 'Kapalı' TF4_Menu = 'Kapalı' TF4_input = '4h' TF4_VolMA1Input = 6 TF4_NumZones = 30 TF4_extRight = false TF4_ResLinesColor =color.new(color.fuchsia, 20) TF4_ResZoneColor =color.new(color.fuchsia, 90) TF4_SupLinesColor = color.new(color.green, 20) TF4_SupZoneColor = color.new(color.green, 90) TF4_Alerts = 'Kapalı' f_TFx(_TF_input) => if _TF_input == 'Chart' timeframe.period else if _TF_input == '3d' '3' else if _TF_input == '5d' '5' else if _TF_input == '15d' '15' else if _TF_input == '30d' '30' else if _TF_input == '45d' '45' else if _TF_input == '1s' '60' else if _TF_input == '2s' '120' else if _TF_input == '3s' '180' else if _TF_input == '4s' '240' else if _TF_input == '6s' '360' else if _TF_input == '8s' '480' else if _TF_input == '12s' '720' else if _TF_input == 'GUNLUK' 'D' else if _TF_input == '3 GUN' '3D' else if _TF_input == 'HAFTA' 'W' else if _TF_input == '2 HAFTA' '2W' else if _TF_input == 'AYLIK' '1M' TF1 = f_TFx(TF1_input) TF2 = f_TFx(TF2_input) TF3 = f_TFx(TF3_input) TF4 = f_TFx(TF4_input) //vol_check = na(volume) or volume==0 //var table vol_check_table = na //if barstate.islast and vol_check // table.delete(vol_check_table) // vol_check_table := table.new(position=position.middle_right, columns=1, rows=1, frame_color=color.red, frame_width=1) // table.cell(vol_check_table, column=0, row=0, text='Bu enstruman için hacim verisi mevcut değil' + ' (' + syminfo.tickerid + ')' + '\n Destek Direnç tespiti için lütfen başka bir işlem çifti seçin.', text_color=color.red) // // --------- This ensures that no plots from lower time frames will be plotted on higher time frames. // ————— Converts current chart resolution into a float minutes value. f_resInMinutes() => _resInMinutes = timeframe.multiplier * (timeframe.isseconds ? 1. / 60 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60. * 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na) _resInMinutes // ————— Returns the float minutes value of the string _res. f_tfResInMinutes(_res) => // _res: resolution of any TF (in "timeframe.period" string format). // Dependency: f_resInMinutes(). request.security(syminfo.tickerid, _res, f_resInMinutes()) // —————————— Determine if current timeframe is smaller that higher timeframe selected in Inputs. // Get higher timeframe in minutes. TF1InMinutes = f_tfResInMinutes(TF1) TF2InMinutes = f_tfResInMinutes(TF2) TF3InMinutes = f_tfResInMinutes(TF3) TF4InMinutes = f_tfResInMinutes(TF4) // Get current timeframe in minutes. currentTFInMinutes = f_resInMinutes() // Compare current TF to higher TF to make sure it is smaller, otherwise our plots don't make sense. chartOnLowerTF1 = currentTFInMinutes <= TF1InMinutes chartOnLowerTF2 = currentTFInMinutes <= TF2InMinutes chartOnLowerTF3 = currentTFInMinutes <= TF3InMinutes chartOnLowerTF4 = currentTFInMinutes <= TF4InMinutes chartEqualTF2 = currentTFInMinutes == TF2InMinutes and TF2_Menu != 'Kapalı' chartEqualTF3 = currentTFInMinutes == TF3InMinutes and TF3_Menu != 'Kapalı' chartEqualTF4 = currentTFInMinutes == TF4InMinutes and TF4_Menu != 'Kapalı' TF1_inH = str.tostring(TF1InMinutes / 60) TF1_text = TF1InMinutes >= 60 and TF1InMinutes < 1440 ? TF1_inH + 's' : TF1InMinutes < 60 ? TF1 + 'd' : TF1 //--- In order to get the left side of SR zone on higher time frames to line up directly on the bar with the fractal high or fractal low, we need to perform //--- a series of calculations to find the pivot high/low. Since the FractalUp or FractalDown condition is found after 2 confirming bars, the SR zone would begin //--- at the opening of the 3rd bar following the pivot high/low). For example, if there is a 4hr Fractal confirmed while on the 1hr chart, it would take 3 4hr bars to confirm. //--- That means the high/low point could've occured anywhere between 8-12 1hr bars ago. // // --------- To get the correct bar_index for higher time frame SR zones placed on lower time frame candles, first the range of candles to scan needs to be established. // // --------- Then find the highest/lowest bar within that range of bars for bar_index on the x1 (left) coordinates of lines (next steps below) bool TF1_newbar = ta.change(time(TF1)) != 0, bool TF2_newbar = ta.change(time(TF2)) != 0, bool TF3_newbar = ta.change(time(TF3)) != 0, bool TF4_newbar = ta.change(time(TF4)) != 0 TF1_bi1 = ta.valuewhen(TF1_newbar, bar_index, 1), TF2_bi1 = ta.valuewhen(TF2_newbar, bar_index, 1), TF3_bi1 = ta.valuewhen(TF3_newbar, bar_index, 1), TF4_bi1 = ta.valuewhen(TF4_newbar, bar_index, 1) TF1_bi5 = ta.valuewhen(TF1_newbar, bar_index, 5), TF2_bi5 = ta.valuewhen(TF2_newbar, bar_index, 5), TF3_bi5 = ta.valuewhen(TF3_newbar, bar_index, 5), TF4_bi5 = ta.valuewhen(TF4_newbar, bar_index, 5) TF1_bb1 = bar_index-TF1_bi1, TF2_bb1 = bar_index-TF2_bi1, TF3_bb1 = bar_index-TF3_bi1, TF4_bb1 = bar_index-TF4_bi1 TF1_bb5 = bar_index-TF1_bi5, TF2_bb5 = bar_index-TF2_bi5, TF3_bb5 = bar_index-TF3_bi5, TF4_bb5 = bar_index-TF4_bi5 TF1_br = TF1_bb5 - TF1_bb1, TF2_br = TF2_bb5 - TF2_bb1, TF3_br = TF3_bb5 - TF3_bb1, TF4_br = TF4_bb5 - TF4_bb1 // Get offset value for the highest high or lowest low found within the specified range , using [] to establish the starting point back to begin scanning past bars for highest high or lowest low. // Moving the starting point back ensures it scans within the range in which the high/low was found by FractalUp/FractalDown condition. // Output by default is negative, make positive with absolute value for bar_index. // Adding the TFx_bar_index back in accounts for the number of bars skipped back in []. // First check if the number of bars back to scan for pivot high/low is going to be over the max bars back, and if so set the bar_index to the max bars back, // otherwise get exact bar index value for pivot high/low. var int TF1_Hi_Bi = 0 var int TF1_Lo_Bi = 0 var int TF2_Hi_Bi = 0 var int TF2_Lo_Bi = 0 var int TF3_Hi_Bi = 0 var int TF3_Lo_Bi = 0 var int TF4_Hi_Bi = 0 var int TF4_Lo_Bi = 0 if TF1_bb1 > 4999 or (TF1_bb1 + TF1_br) > 4999 TF1_Hi_Bi := 4999 TF1_Lo_Bi := 4999 else TF1_Hi_Bi := math.abs(ta.highestbars(high, nz(TF1_br, 1)))[TF1_bb1] + TF1_bb1 TF1_Lo_Bi := math.abs(ta.lowestbars(low, nz(TF1_br, 1)))[TF1_bb1] + TF1_bb1 if TF2_bb1 > 4999 or (TF2_bb1 + TF2_br) > 4999 TF2_Hi_Bi := 4999 TF2_Lo_Bi := 4999 else TF2_Hi_Bi := math.abs(ta.highestbars(high, nz(TF2_br, 1)))[TF2_bb1] + TF2_bb1 TF2_Lo_Bi := math.abs(ta.lowestbars(low, nz(TF2_br, 1)))[TF2_bb1] + TF2_bb1 if TF3_bb1 > 4999 or (TF3_bb1 + TF3_br) > 4999 TF3_Hi_Bi := 4999 TF3_Lo_Bi := 4999 else TF3_Hi_Bi := math.abs(ta.highestbars(high, nz(TF3_br, 1)))[TF3_bb1] + TF3_bb1 TF3_Lo_Bi := math.abs(ta.lowestbars(low, nz(TF3_br, 1)))[TF3_bb1] + TF3_bb1 if TF4_bb1 > 4999 or (TF4_bb1 + TF4_br) > 4999 TF4_Hi_Bi := 4999 TF4_Lo_Bi := 4999 else TF4_Hi_Bi := math.abs(ta.highestbars(high, nz(TF4_br, 1)))[TF4_bb1] + TF4_bb1 TF4_Lo_Bi := math.abs(ta.lowestbars(low, nz(TF4_br, 1)))[TF4_bb1] + TF4_bb1 // TFUp and TFDown Calculations f_tfUp(_TF_High, _TF_Vol, _TF_VolMA) => _TF_High[3] > _TF_High[4] and _TF_High[4] > _TF_High[5] and _TF_High[2] < _TF_High[3] and _TF_High[1] < _TF_High[2] and _TF_Vol[3] > _TF_VolMA[3] f_tfDown(_TF_Low, _TF_Vol, _TF_VolMA) => _TF_Low[3] < _TF_Low[4] and _TF_Low[4] < _TF_Low[5] and _TF_Low[2] > _TF_Low[3] and _TF_Low[1] > _TF_Low[2] and _TF_Vol[3] > _TF_VolMA[3] // Function for each time frame's various sources used in FractalUp and FractalDown calculations. f_tfSources(_res, _source) => request.security(syminfo.tickerid, _res, _source) // Line and label arrays var TF1_UpperSupportLine_array = array.new_line(TF1_NumZones), var TF2_UpperSupportLine_array = array.new_line(TF2_NumZones), var TF3_UpperSupportLine_array = array.new_line(TF3_NumZones), var TF4_UpperSupportLine_array = array.new_line(TF4_NumZones) var TF1_LowerSupportLine_array = array.new_line(TF1_NumZones), var TF2_LowerSupportLine_array = array.new_line(TF2_NumZones), var TF3_LowerSupportLine_array = array.new_line(TF3_NumZones), var TF4_LowerSupportLine_array = array.new_line(TF4_NumZones) var TF1SupLabel_array = array.new_label(1), var TF2SupLabel_array = array.new_label(1), var TF3SupLabel_array = array.new_label(1), var TF4SupLabel_array = array.new_label(1) var TF1_UpperResLine_array = array.new_line(TF1_NumZones), var TF2_UpperResLine_array = array.new_line(TF2_NumZones), var TF3_UpperResLine_array = array.new_line(TF3_NumZones), var TF4_UpperResLine_array = array.new_line(TF4_NumZones) var TF1_LowerResLine_array = array.new_line(TF1_NumZones), var TF2_LowerResLine_array = array.new_line(TF2_NumZones), var TF3_LowerResLine_array = array.new_line(TF3_NumZones), var TF4_LowerResLine_array = array.new_line(TF4_NumZones) var TF1ResLabel_array = array.new_label(1), var TF2ResLabel_array = array.new_label(1), var TF3ResLabel_array = array.new_label(1), var TF4ResLabel_array = array.new_label(1) // Resistance Line Functions TF_ResistanceLineA(TF_input,TF_FractalUp,TF_ResLineColor,TF_UpperResLine_array,TF_NumZones,TF_ResZone, TF_LowerResLine_array,TF_text,TF_ResLabel_array,bi_hi,bi_3,bi,bi_2,ext_right) => if show_HL UpperResistanceLine = line.new(x1=TF_input != 'Chart' ? bi_hi : bi_3, y1=TF_FractalUp, x2=bi, y2=TF_FractalUp, color=TF_ResLineColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF_UpperResLine_array, TF_NumZones-1), extend=ext_right ? extend.right : extend.none) if ExtendLines1 == true line.set_x2(id=array.get(TF_UpperResLine_array, TF_NumZones-1), x=TF_input != 'Chart' ? bi_hi : bi_3) array.push(TF_UpperResLine_array, UpperResistanceLine) line.delete(array.shift(TF_UpperResLine_array)) if show_close LowerResistanceLine = line.new(x1=TF_input != 'Chart' ? bi_hi : bi_3, y1=TF_ResZone, x2=bi, y2=TF_ResZone, color=TF_ResLineColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF_LowerResLine_array, TF_NumZones-1), extend=ext_right ? extend.right : extend.none) if ExtendLines1 == true line.set_x2(id=array.get(TF_LowerResLine_array, TF_NumZones-1), x=TF_input != 'Chart' ? bi_hi : bi_3) array.push(TF_LowerResLine_array, LowerResistanceLine) line.delete(array.shift(TF_LowerResLine_array)) if ShowLabel == true and label_loc == 'Left' TFResLabel = label.new(TF_input != 'Chart' ? bi_hi : bi_2, TF_FractalUp, text=TF_text + "(Direnç)", color=color.new(color.white, 100), size=size.small, style=label.style_label_right, textcolor=TF_ResLineColor) array.push(TF_ResLabel_array, TFResLabel) label.delete(array.shift(TF_ResLabel_array)) TF_ResistanceLineB(TF_FractalUp,TF_ResLineColor,TF_UpperResLine_array,TF_NumZones,TF_ResZone,TF_LowerResLine_array,TF_text,TF_ResLabel_array,bi3,bi,ext_right) => if show_HL UpperResistanceLine = line.new(x1=bi3, y1=TF_FractalUp, x2=bi, y2=TF_FractalUp, color=TF_ResLineColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF_UpperResLine_array, TF_NumZones-1), extend=ext_right ? extend.right : extend.none) if ExtendLines1 == true line.set_x2(id=array.get(TF_UpperResLine_array, TF_NumZones-1), x=bi3) array.push(TF_UpperResLine_array, UpperResistanceLine) line.delete(array.shift(TF_UpperResLine_array)) if show_close LowerResistanceLine = line.new(x1=bi3, y1=TF_ResZone, x2=bi, y2=TF_ResZone, color=TF_ResLineColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF_LowerResLine_array, TF_NumZones-1), extend=ext_right ? extend.right : extend.none) if ExtendLines1 == true line.set_x2(id=array.get(TF_LowerResLine_array, TF_NumZones-1), x=bi3) array.push(TF_LowerResLine_array, LowerResistanceLine) line.delete(array.shift(TF_LowerResLine_array)) if ShowLabel == true and label_loc == 'Left' TFResLabel = label.new(bi3, TF_FractalUp, text=TF_text + "(Direnç)", color=color.new(color.white, 100), size=size.small, style=label.style_label_right, textcolor=TF_ResLineColor) array.push(TF_ResLabel_array, TFResLabel) label.delete(array.shift(TF_ResLabel_array)) // Support Line Functions TF_SupportLineA(TF_input, TF_FractalDown,TF_SupLinesColor,TF_UpperSupportLine_array,TF_NumZones,TF_SupportZone, TF_LowerSupportLine_array,TF_text,TF_SupLabel_array,bi_lo,bi_3,bi,bi_2,ext_right) => if show_close UpperSupportLine = line.new(x1=TF_input != 'Chart' ? bi_lo : bi_3, y1=TF_SupportZone, x2=bi, y2=TF_SupportZone, color=TF_SupLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF_UpperSupportLine_array, TF_NumZones-1), extend=ext_right ? extend.right : extend.none) if ExtendLines1 == true line.set_x2(id=array.get(TF_UpperSupportLine_array, TF_NumZones-1), x=TF_input != 'Chart' ? bi_lo : bi_3) array.push(TF_UpperSupportLine_array, UpperSupportLine) line.delete(array.shift(TF_UpperSupportLine_array)) if show_HL LowerSupportLine = line.new(x1=TF_input != 'Chart' ? bi_lo : bi_3, y1=TF_FractalDown, x2=bi, y2=TF_FractalDown, color=TF_SupLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF_LowerSupportLine_array, TF_NumZones-1), extend=ext_right ? extend.right : extend.none) if ExtendLines1 == true line.set_x2(id=array.get(TF_LowerSupportLine_array, TF_NumZones-1), x=TF_input != 'Chart' ? bi_lo : bi_3) array.push(TF_LowerSupportLine_array, LowerSupportLine) line.delete(array.shift(TF_LowerSupportLine_array)) if ShowLabel == true and label_loc == 'Left' SupLabel = label.new(TF_input != 'Chart' ? bi_lo : bi_2, TF_FractalDown, text=TF_text + "(Destek)", color=color.new(color.white, 100), size=size.small, style=label.style_label_right, textcolor=TF_SupLinesColor) array.push(TF_SupLabel_array, SupLabel) label.delete(array.shift(TF_SupLabel_array)) TF_SupportLineB(TF_FractalDown,TF_SupLinesColor,TF_UpperSupportLine_array,TF_NumZones,TF_SupportZone,TF_LowerSupportLine_array,TF_text,TF_SupLabel_array,bi3,bi,ext_right) => if show_close UpperSupportLine = line.new(x1=bi3, y1=TF_SupportZone, x2=bi, y2=TF_SupportZone, color=TF_SupLinesColor, style=LineStyleClose, width=LineWidthCloseInput, extend=extend.right) line.set_extend(id=array.get(TF_UpperSupportLine_array, TF_NumZones-1), extend=ext_right ? extend.right : extend.none) if ExtendLines1 == true line.set_x2(id=array.get(TF_UpperSupportLine_array, TF_NumZones-1), x=bi3) array.push(TF_UpperSupportLine_array, UpperSupportLine) line.delete(array.shift(TF_UpperSupportLine_array)) if show_HL LowerSupportLine = line.new(x1=bi3, y1=TF_FractalDown, x2=bi, y2=TF_FractalDown, color=TF_SupLinesColor, style=LineStyleHL, width=LineWidthHLInput, extend=extend.right) line.set_extend(id=array.get(TF_LowerSupportLine_array, TF_NumZones-1), extend=ext_right ? extend.right : extend.none) if ExtendLines1 == true line.set_x2(id=array.get(TF_LowerSupportLine_array, TF_NumZones-1), x=bi3) array.push(TF_LowerSupportLine_array, LowerSupportLine) line.delete(array.shift(TF_LowerSupportLine_array)) if ShowLabel == true and label_loc == 'Left' SupLabel = label.new(bi3, TF_FractalDown, text=TF_text + "()", color=color.new(color.white, 100), size=size.small, style=label.style_label_right, textcolor=TF_SupLinesColor) array.push(TF_SupLabel_array, SupLabel) label.delete(array.shift(TF_SupLabel_array)) // Label Function TFLabel(bi, TF_Fractal, txt, txtcolor, TFLabel_array) => Label = label.new(bi, TF_Fractal, text=txt, size=size.small, style=label.style_none, textcolor=txtcolor) array.push(TFLabel_array, Label) label.delete(array.shift(TFLabel_array)) // S/R = Time Frame 1 = TF1 TF1_Vol = f_tfSources(TF1, volume) TF1_VolMA = ta.sma(TF1_Vol, TF1_VolMA1Input) TF1_High = f_tfSources(TF1, high) TF1_Low = f_tfSources(TF1, low) TF1_Open = f_tfSources(TF1, open) TF1_Close = f_tfSources(TF1, close) TF1_Up = f_tfUp(TF1_High, TF1_Vol, TF1_VolMA) TF1_Down = f_tfDown(TF1_Low, TF1_Vol, TF1_VolMA) TF1_CalcFractalUp() => TF1_FractalUp = 0.0 TF1_FractalUp := TF1_Up ? TF1_High[3] : TF1_FractalUp[1] TF1_FractalUp TF1_CalcFractalDown() => TF1_FractalDown = 0.0 TF1_FractalDown := TF1_Down ? TF1_Low[3] : TF1_FractalDown[1] TF1_FractalDown TF1_FractalUp = request.security(syminfo.tickerid, TF1, TF1_CalcFractalUp()) TF1_FractalDown = request.security(syminfo.tickerid, TF1, TF1_CalcFractalDown()) // Zones - Current Time Frame = Time Frame 1 = TF1 // Fractal Up Zones TF1_CalcFractalUpZone() => TF1_FractalUpZone = 0.0 TF1_FractalUpZone := TF1_Up and TF1_Close[3] >= TF1_Open[3] ? TF1_Close[3] : TF1_Up and TF1_Close[3] < TF1_Open[3] ? TF1_Open[3] : TF1_FractalUpZone[1] TF1_FractalUpZone TF1_FractalUpZone = request.security(syminfo.tickerid, TF1, TF1_CalcFractalUpZone()) TF1_ResZone = TF1_FractalUpZone // Fractal Down Zones TF1_CalcFractalDownZone() => TF1_FractalDownZone = 0.0 TF1_FractalDownZone := TF1_Down and TF1_Close[3] >= TF1_Open[3] ? TF1_Open[3] : TF1_Down and TF1_Close[3] < TF1_Open[3] ? TF1_Close[3] : TF1_FractalDownZone[1] TF1_FractalDownZone TF1_FractalDownZone = request.security(syminfo.tickerid, TF1, TF1_CalcFractalDownZone()) TF1_SupportZone = TF1_FractalDownZone // Time Frame 1 = TF1 Resistance if (TF1_Menu == 'Açık' or TF1_Menu == 'Çizgi') and TF1_FractalUp != TF1_FractalUp[1] and chartOnLowerTF1 and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 TF_ResistanceLineA(TF1_input,TF1_FractalUp,TF1_ResLinesColor,TF1_UpperResLine_array,TF1_NumZones,TF1_ResZone, TF1_LowerResLine_array,TF1_text,TF1ResLabel_array,bar_index[TF1_Hi_Bi], bar_index[3], bar_index,bar_index[2], TF1_extRight) else if (TF1_Menu == 'Açık' or TF1_Menu == 'Çizgi') and na(TF1_FractalUp != TF1_FractalUp[1]) and chartOnLowerTF1 and na(ta.barssince(TF1_FractalUp != TF1_FractalUp[1])) and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 TF_ResistanceLineB(TF1_FractalUp,TF1_ResLinesColor,TF1_UpperResLine_array,TF1_NumZones,TF1_ResZone,TF1_LowerResLine_array,TF1_text,TF1ResLabel_array,bar_index[3],bar_index, TF1_extRight) if (TF1_Menu == 'Açık') linefill.new(array.get(TF1_UpperResLine_array, TF1_NumZones-1), array.get(TF1_LowerResLine_array, TF1_NumZones-1), TF1_ResZoneColor) if ShowLabel == true and (TF1_Menu == 'Açık' or TF1_Menu == 'Çizgi') and chartOnLowerTF1 and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 and label_loc == 'Right' TFLabel(bar_index+label_offset, TF1_FractalUp, TF1_text+"(Direnç)", TF1_ResLinesColor, TF1ResLabel_array) // Time Frame 1 = TF1 Support if (TF1_Menu == 'Açık' or TF1_Menu == 'Çizgi') and TF1_FractalDown != TF1_FractalDown[1] and chartOnLowerTF1 and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 TF_SupportLineA(TF1_input,TF1_FractalDown,TF1_SupLinesColor,TF1_UpperSupportLine_array,TF1_NumZones,TF1_SupportZone, TF1_LowerSupportLine_array,TF1_text,TF1SupLabel_array,bar_index[TF1_Lo_Bi], bar_index[3], bar_index,bar_index[2], TF1_extRight) else if (TF1_Menu == 'Açık' or TF1_Menu == 'Çizgi') and na(TF1_FractalDown != TF1_FractalDown[1]) and chartOnLowerTF1 and na(ta.barssince(TF1_FractalDown != TF1_FractalDown[1])) and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 TF_SupportLineB(TF1_FractalDown,TF1_SupLinesColor,TF1_UpperSupportLine_array,TF1_NumZones,TF1_SupportZone,TF1_LowerSupportLine_array,TF1_text,TF1SupLabel_array,bar_index[3],bar_index, TF1_extRight) if (TF1_Menu == 'Açık') linefill.new(array.get(TF1_UpperSupportLine_array, TF1_NumZones-1), array.get(TF1_LowerSupportLine_array, TF1_NumZones-1), TF1_SupZoneColor) if ShowLabel == true and (TF1_Menu == 'Açık' or TF1_Menu == 'Çizgi') and chartOnLowerTF1 and not chartEqualTF2 and not chartEqualTF3 and not chartEqualTF4 and label_loc == 'Right' TFLabel(bar_index+label_offset, TF1_FractalDown, TF1_text+"(Destek)", TF1_SupLinesColor, TF1SupLabel_array) if ext_active == false and barstate.islast line.set_extend(array.get(TF1_UpperResLine_array, TF1_NumZones-1), extend.none) line.set_x2(array.get(TF1_UpperResLine_array, TF1_NumZones-1), bar_index) line.set_extend(array.get(TF1_LowerResLine_array, TF1_NumZones-1), extend.none) line.set_x2(array.get(TF1_LowerResLine_array, TF1_NumZones-1), bar_index) if ext_active == false and barstate.islast line.set_extend(array.get(TF1_UpperSupportLine_array, TF1_NumZones-1), extend.none) line.set_x2(array.get(TF1_UpperSupportLine_array, TF1_NumZones-1), bar_index) line.set_extend(array.get(TF1_LowerSupportLine_array, TF1_NumZones-1), extend.none) line.set_x2(array.get(TF1_LowerSupportLine_array, TF1_NumZones-1), bar_index) length = 50 smoothing = 'RMA' m = 2 src1 = high src2 = low pline = false col1 = color.blue col2 = color.teal col3 = color.red m3 = 2 //m3 = input.float(defval = 2,title='Kâr Alma katsayısı',step=0.1,group='Kâr-Zarar Ayarları💰') collong = color.teal colshort = color.red ma_function(source, length) => if smoothing == 'RMA' ta.rma(source, length) else if smoothing == 'SMA' ta.sma(source, length) else if smoothing == 'EMA' ta.ema(source, length) else ta.wma(source, length) a = ma_function(ta.tr(true), length) * m x = ma_function(ta.tr(true), length) * m + src1 x2 = src2 - ma_function(ta.tr(true), length) * m //m4=src2 - ma_function(ta.tr(true), length) * -m*2 //m5=ma_function(ta.tr(true), length) * -m*2 + src1 /////////////////// //GRADIENT AREA //////////////////// f_c_gradientAdvDecPro(_source, _center, _steps, _c_bearWeak, _c_bearStrong, _c_bullWeak, _c_bullStrong) => var float _qtyAdvDec = 0. var float _maxSteps = math.max(1, _steps) bool _xUp = ta.crossover(_source, _center) bool _xDn = ta.crossunder(_source, _center) float _chg = ta.change(_source) bool _up = _chg > 0 bool _dn = _chg < 0 bool _srcBull = _source > _center bool _srcBear = _source < _center _qtyAdvDec := _srcBull ? _xUp ? 1 : _up ? math.min(_maxSteps, _qtyAdvDec + 1) : _dn ? math.max(1, _qtyAdvDec - 1) : _qtyAdvDec : _srcBear ? _xDn ? 1 : _dn ? math.min(_maxSteps, _qtyAdvDec + 1) : _up ? math.max(1, _qtyAdvDec - 1) : _qtyAdvDec : _qtyAdvDec var color _return = na _return := _srcBull ? color.from_gradient(_qtyAdvDec, 1, _maxSteps, _c_bullWeak, _c_bullStrong) : _srcBear ? color.from_gradient(_qtyAdvDec, 1, _maxSteps, _c_bearWeak, _c_bearStrong) : _return _return //MA TYPES mat(source, length, type) => type == 'SMA' ? ta.sma(source, length) : type == 'EMA' ? ta.ema(source, length) : type == 'RMA' ? ta.rma(source, length) : type == 'WMA' ? ta.wma(source, length) : type == 'VWMA' ? ta.vwma(source, length) : type == 'HMA' ? ta.hma(source, length) : type == 'TMA' ? ta.sma(ta.sma(source, length), length) : na //INPUTS bull = #4bca01 bear = color.rgb(255, 0, 0) neutral = color.rgb(255, 255, 0) show_ma = true ma_typehama = 'EMA' ma_sourcehamahama = close //ma_lengthhama = input(defval=88,title='Mum Rengi Hassasiyeti',group='HTF/LTF Ayarları',tooltip='Mum rengi hassasiyetini ayarlar 21 ile 100 arasında tutulması önerilir.') ma_lengthhama = 188 UseGradient = true stepn = 3 ma = mat(ma_sourcehamahama, ma_lengthhama, ma_typehama) col = f_c_gradientAdvDecPro(ma, ta.wma(ma, 3), stepn, neutral, bear, neutral, bull) //////////////////// //END GRADIENT AREA //////////////////// //MA INFO OpenLength = 34 OpenType = 'EMA' HighLength = 34 HighType = 'EMA' LowLength = 34 LowType = 'EMA' CloseLength = 34 CloseType = 'EMA' LengthMA =161 MAType = 'EMA' MASource = close TypeOpen = OpenType SourceOpen = (open[1] + close[1]) / 2 LengthOpen = OpenLength TypeHigh = HighType SourceHigh = math.max(high, close) LengthHigh = HighLength TypeLow = LowType SourceLow = math.min(low, close) LengthLow = LowLength TypeClose = CloseType SourceClose = (open + high + low + close) / 4 LengthClose = CloseLength funcCalcMA1(type1, src1, len1) => return_1 = type1 == 'EMA' ? ta.ema(src1, len1) : type1 == 'SMA' ? ta.sma(src1, len1) : type1 == 'WMA' ? ta.wma(src1, len1) : na return_1 funcCalcOpen(TypeOpen, SourceOpen, LengthOpen) => return_2 = TypeOpen == 'EMA' ? ta.ema(SourceOpen, LengthOpen) : TypeOpen == 'SMA' ? ta.sma(SourceOpen, LengthOpen) : TypeOpen == 'WMA' ? ta.wma(SourceOpen, LengthOpen) : na return_2 funcCalcHigh(TypeHigh, SourceHigh, LengthHigh) => return_3 = TypeHigh == 'EMA' ? ta.ema(SourceHigh, LengthHigh) : TypeHigh == 'SMA' ? ta.sma(SourceHigh, LengthHigh) : TypeHigh == 'WMA' ? ta.wma(SourceHigh, LengthHigh) : na return_3 funcCalcLow(TypeLow, SourceLow, LengthLow) => return_4 = TypeLow == 'EMA' ? ta.ema(SourceLow, LengthLow) : TypeLow == 'SMA' ? ta.sma(SourceLow, LengthLow) : TypeLow == 'WMA' ? ta.wma(SourceLow, LengthLow) : na return_4 funcCalcClose(TypeClose, SourceClose, LengthClose) => return_5 = TypeClose == 'EMA' ? ta.ema(SourceClose, LengthClose) : TypeClose == 'SMA' ? ta.sma(SourceClose, LengthClose) : TypeClose == 'WMA' ? ta.wma(SourceClose, LengthClose) : na return_5 MA1 = funcCalcMA1(MAType, MASource, LengthMA) //ATLAS LUPUS// longCondition = buySignalk and close > MA1 and maintrend == 1 shortCondition =sellSignalk and close < MA1 and maintrend == -1 //Plot AL and SAT Labels/ plotshape(buySignalk and ato4 and O1 > K2 ? AtlasT[2] * 0.9999 : na , title='AL',text='🍃', textcolor=color.white, style=shape.labelup, size=size.tiny, location=location.belowbar, color=color.new(color.green, 50),editable=false) plotshape(sellSignalk and ato4 and O2 > K1 ? AtlasT[2] * 1.0001 : na, title='SAT',text='🍂', textcolor=color.white, style=shape.labeldown, size=size.tiny, location=location.abovebar, color=color.new(color.red, 50),editable=false) plotshape(buySignalk and ato4 and O1 > K2 ? AtlasT[2] * 0.9999 : na, title='AL', textcolor=color.white, style=shape.triangleup, size=size.tiny, location=location.belowbar, color=color.new(color.green, 50),editable=false) plotshape(sellSignalk and ato4 and O2 > K1 ? AtlasT[2] * 1.0001 : na, title='SAT', textcolor=color.white, style=shape.triangledown, size=size.tiny, location=location.abovebar, color=color.new(color.red, 50),editable=false) //plotshape(devam and Trend == 1 and (close[6]>t_uma_avg and close[5]>t_uma_avg and close[4]>t_uma_avg and close[3]>t_uma_avg and ta.crossover(t_uma_avg,close[2]) and close[1]>t_uma_avg and close>t_uma_avg and ao_baseline > 0 and close[1]close),text='🐻', textcolor=color.white, style=shape.labeldown, size=size.tiny, location=location.abovebar, color=color.new(color.red, 0),editable=false) CandleOpen = funcCalcOpen(TypeOpen, SourceOpen, LengthOpen) CandleHigh = funcCalcHigh(TypeHigh, SourceHigh, LengthHigh) CandleLow = funcCalcLow(TypeLow, SourceLow, LengthLow) CandleClose = funcCalcClose(TypeClose, SourceClose, LengthClose) //PLOT CANDLES //BodyColor = CandleOpen > CandleOpen[1] ? color.green : color.red //barcolor(ato5 and UseGradient ? col : na,editable=false) barcolor(ato5 and show_chop and chop_cond?color.rgb(64, 69, 83, 17):not show_chop and ato5 and UseGradient?col:col,editable=false) //plotcandle(CandleOpen, CandleHigh, CandleLow, CandleClose, color=UseGradient ? col : BodyColor, title='HAMA Candles', wickcolor=WickColor, bordercolor=na) plot(ato2 ?MA1:na,color=UseGradient ? col : na ,style=plot.style_line, linewidth=2,editable = false) //MTFTREND mtftrend2 = input.timeframe(title='LTF', defval='5',group='HTF/LTF Ayarları',tooltip='Alt zaman diliminden Trend teyidi almak için kullanılır.Trende Erken giriş için kullanılır.\nÖrnek olarak 15 Dakikada işlem yapmak için 5 dakikalığı seçmeniz önerilir') mtfbull2 = request.security(syminfo.tickerid,mtftrend2, maintrend == 1 and close>t_uma_avg and ao_baseline > 0 and uma_trail > t_uma_avg and Up) mtfbear2 = request.security(syminfo.tickerid, mtftrend2, closet_uma_avg and ao_baseline > 0 and uma_trail > t_uma_avg and Up) mtfbear = request.security(syminfo.tickerid, mtftrend, closet_uma_avg and ao_baseline > 0 and uma_trail > t_uma_avg and Up) mtfbear3 = request.security(syminfo.tickerid, mtftrend3, close FH : FL < FH Fib_x(n) => revfibs ? (Fhigh - Flow) * n + Flow : Fhigh - (Fhigh - Flow) * n Current = revfibs ? (close - Flow) / (Fhigh - Flow) : (Fhigh - close) / (Fhigh - Flow) var label Current_Fib_Label = na label.delete(Current_Fib_Label) if CurrentFib and barstate.islast Current_Fib_Label := label.new(bar_index, close, str.tostring(Current, '##.##'), textcolor=Current_Color, color=color.new(#000000, 100), style=label.style_label_left, yloc=yloc.price) Current_Fib_Label EXTEND = Ext ? extend.right : extend.none STYLE = LineStyle == 'Dotted' ? line.style_dotted : line.style_solid WIDTH = LineWidth BB = fibos ? FIBS == 1 ? FL < FH ? bar_index[-FL] : bar_index[-FH]:na : fibos ?FIBS == 2 ? bar_index[50] : bar_index[50]:na Fib_line(x) => var line ln = na line.delete(ln) ln := fibos?line.new(BB, x, bar_index, x, color=close > x ? BullColor : BearColor, extend=EXTEND, style=STYLE, width=WIDTH):na ln Fib_label(x, _txt) => var label lbl = na label.delete(lbl) lbl := fibos?label.new(bar_index, x, _txt + str.tostring(x, '##.##') + ')', textcolor=close > x ? BullColor : BearColor, color=color.new(#000000, 100), style=label.style_label_left, yloc=yloc.price):na lbl Fib038 = Fib_line(Fib_x(-0.382)) Fib025 = Fib_line(Fib_x(-0.25)) Fib0 = Fib_line(Fib_x(0)) Fib013 = Fib_line(Fib_x(0.0886)) Fib236 = Fib_line(Fib_x(0.236)) Fib382 = Fib_line(Fib_x(0.382)) Fib500 = Fib_line(Fib_x(0.500)) Fib618 = Fib_line(Fib_x(0.618)) Fib688 = Fib_line(Fib_x(0.688)) Fib786 = Fib_line(Fib_x(0.786)) Fib95 = Fib_line(Fib_x(0.95)) Fib1000 = Fib_line(Fib_x(1.000)) Fib114 = (Fib_x(1.19)) Fib886 = ExtraFibs ? Fib_line(Fib_x(0.9)) : na if fibos and FIBS == 2 Fib1113 = ExtraFibs ? Fib_line(Fib_x(1.113)) : na Fib1272 = Fib_line(Fib_x(1.272)) Fib1618 = Fib_line(Fib_x(1.618)) Fib2000 = Fib_line(Fib_x(2.000)) Fib2236 = Fib_line(Fib_x(2.236)) Fib2618 = Fib_line(Fib_x(2.618)) Fib3236 = Fib_line(Fib_x(3.236)) Fib3618 = Fib_line(Fib_x(3.618)) Fib4236 = Fib_line(Fib_x(4.236)) Fib4618 = Fib_line(Fib_x(4.618)) Fib4618 LFib038 = Fib_label(Fib_x(-0.382), 'KÂR 3💰(') LFib025 = Fib_label(Fib_x(-0.25), 'KÂR 2💰(') LFib0 = Fib_label(Fib_x(0), '🏁KÂR 1💰(') LFib013 = Fib_label(Fib_x(0.0886), 'ATLAS KÂR AL🌖💰(') LFib236 = Fib_label(Fib_x(0.236), 'KADEME(') LFib382 = Fib_label(Fib_x(0.382), 'KADEME(') LFib500 = Fib_label(Fib_x(0.500), 'ERKEN GİRİŞ(') LFib618 = Fib_label(Fib_x(0.618), 'GİRİŞ(') LFib688 = Fib_label(Fib_x(0.688), 'ATLAS GİRİŞ🌖(') LFib786 = Fib_label(Fib_x(0.786), 'RİSKLİ GİRİŞ(') LFib95 = Fib_label(Fib_x(0.95), 'STOP🛑(') LFib1000 = Fib_label(Fib_x(1.000),'🏁( ') LFib886 = ExtraFibs ? Fib_label(Fib_x(0.9), 'STOP🛑( ') : na if fibos and FIBS == 2 LFib1113 = ExtraFibs ? Fib_label(Fib_x(1.113), '1.113 ( ') : na LFib1272 = Fib_label(Fib_x(1.272), '1.272 ( ') LFib1618 = Fib_label(Fib_x(1.618), '1.618 ( ') LFib2000 = Fib_label(Fib_x(2.000), '2.000 ( ') LFib2236 = Fib_label(Fib_x(2.236), '2.236 ( ') LFib2618 = Fib_label(Fib_x(2.618), '2.618 ( ') LFib3236 = Fib_label(Fib_x(3.236), '3.236 ( ') LFib3618 = Fib_label(Fib_x(3.618), '3.618 ( ') LFib4236 = Fib_label(Fib_x(4.236), '4.236 ( ') LFib4618 = Fib_label(Fib_x(4.618), '4.618 ( ') LFib4618 linefill.new(Fib0,Fib013,color=color.new(color.aqua, 90)) linefill.new(Fib886,Fib95,color=color.new(color.fuchsia, 90)) linefill.new(Fib618,Fib688,color=color.new(#FFD700, 90)) //FIBEND atrvover= ta.atr(16)+open*1.5 atrvunder= open-ta.atr(16)*1.5 bullatr = close > atrvover and ta.crossover(close, MA1) bearatr = close < atrvunder and ta.crossunder(close, MA1) plotshape(bullatr,style=shape.diamond,location =location.belowbar,color = color.green,editable=false) plotshape(bearatr,style=shape.diamond,location =location.abovebar,color = color.red,editable=false) var isLong = false var isShort = false lonat=(not isLong and maintrend == 1 and close>t_uma_avg and ao_baseline > 0 and Trend == 1 and uma_trail > t_uma_avg) sonat=(not isShort and Trend == -1 and closet_uma_avg and ao_baseline > 0 and Trend == 1 and uma_trail > t_uma_avg and mtfbull) sonat1=(not isShort and Trend == -1 and closet_uma_avg and ao_baseline > 0 and Trend == 1 and uma_trail > t_uma_avg and mtfbull and mtfbull2) sonat2=(not isShort and Trend == -1 and closet_uma_avg and ao_baseline > 0 and Trend == 1 and uma_trail > t_uma_avg and mtfbull2) sonat3=(not isShort and Trend == -1 and close up = ta.change(high) down = -ta.change(low) GigaST = na(up) ? na : up > down and up > 0 ? up : 0 BitST = na(down) ? na : down > up and down > 0 ? down : 0 truerange = ta.rma(ta.tr, len) Ringa = fixnan(100 * ta.rma(GigaST, len) / truerange) Giga = fixnan(100 * ta.rma(BitST, len) / truerange) [Ringa, Giga] prologue(dilen, prologuelen) => [Ringa, Giga] = dirmov(dilen) sum = Ringa + Giga prologue = 100 * ta.rma(math.abs(Ringa - Giga) / (sum == 0 ? 1 : sum), prologuelen) prologue sig = prologue(dilen, prologuelen) vol2 = volume > 0 ? volume : 1 HOLDATR = ta.atr(atrlength) * atrmultip APSATR = close - HOLDATR DPSATR = close + HOLDATR var longcondition = false var shortcondition = true iff_1 = close[1] < open ? math.max(high - close[1], close - low) : math.max(high - open, close - low) iff_2 = close[1] > open ? high - low : math.max(open - close[1], high - low) iff_3 = close[1] < open ? math.max(high - close[1], close - low) : high - open iff_4 = close[1] > open ? high - low : math.max(open - close[1], high - low) iff_5 = close[1] < open ? math.max(open - close[1], high - low) : high - low iff_6 = close[1] > open ? math.max(high - open, close - low) : iff_5 iff_7 = high - close < close - low ? iff_4 : iff_6 iff_8 = high - close > close - low ? iff_3 : iff_7 iff_9 = close > open ? iff_2 : iff_8 BP = close < open ? iff_1 : iff_9 iff_10 = close[1] > open ? math.max(close[1] - open, high - low) : high - low iff_11 = close[1] > open ? math.max(close[1] - low, high - close) : math.max(open - low, high - close) iff_12 = close[1] > open ? math.max(close[1] - open, high - low) : high - low iff_13 = close[1] > open ? math.max(close[1] - low, high - close) : open - low iff_14 = close[1] < open ? math.max(open - low, high - close) : high - low iff_15 = close[1] > open ? math.max(close[1] - open, high - low) : iff_14 iff_16 = high - close < close - low ? iff_13 : iff_15 iff_17 = high - close > close - low ? iff_12 : iff_16 iff_18 = close > open ? iff_11 : iff_17 SP = close < open ? iff_10 : iff_18 TP = BP + SP BPV = BP / TP * vol2 SPV = SP / TP * vol2 TPV = BPV + SPV BPVavg = ta.ema(ta.ema(BPV, signal), signal) SPVavg = ta.ema(ta.ema(SPV, signal), signal) TPVavg = ta.ema(ta.wma(TPV, signal), signal) convdivc = (BPVavg - SPVavg) / TPVavg * 100 Buy = convdivc > TNtolerance and sig > TrendStrgth Sell = convdivc < TNStolerance and sig > TrendStrgth ///momentu trlen=10 upmomen = ta.highest(src, trlen) dnmomen = ta.lowest(src, trlen) oscmomen = ta.mom(ta.ema(ta.ema(src, trlen), trlen), trlen) phoscmomen = ta.crossunder(ta.change(oscmomen), 0) ploscmomen = ta.crossover(ta.change(oscmomen), 0) bearmomen = oscmomen > 0 and phoscmomen and ta.valuewhen(phoscmomen, oscmomen, 0) < ta.valuewhen(phoscmomen, oscmomen, 1) and ta.valuewhen(phoscmomen, upmomen, 0) > ta.valuewhen(phoscmomen, upmomen, 1) ? 1 : 0 bullmomen = oscmomen < 0 and ploscmomen and ta.valuewhen(ploscmomen, oscmomen, 0) > ta.valuewhen(ploscmomen, oscmomen, 1) and ta.valuewhen(ploscmomen, dnmomen, 0) < ta.valuewhen(ploscmomen, dnmomen, 1) ? 1 : 0 ////RSIDIV src4 = close, len4 = 14 up4s = ta.rma(math.max(ta.change(src4), 0), len4) down4s = ta.rma(-math.min(ta.change(src4), 0), len4) rsi4 = down4s == 0 ? 100 : up4s == 0 ? 0 : 100 - (100 / (1 + up4s / down4s)) cumVol += nz(volume) sv = ta.change(hlc3) >= 0 ? volume : -volume lkbk_1 = 34 lkbk_2 = 55 kvo = ta.ema(sv, lkbk_1) - ta.ema(sv, lkbk_2) i_div_select = 'KVO' div_select = i_div_select == 'KVO' ? kvo : i_div_select == 'Signal' ? sig : na lkbk_right = 5 lkbk_left = 5 max_range = 60 min_range = 5 pl_found = na(ta.pivotlow(div_select, lkbk_left, lkbk_right)) ? false : true ph_found = na(ta.pivothigh(div_select, lkbk_left, lkbk_right)) ? false : true _inRange(cond) => bars = ta.barssince(cond == true) min_range <= bars and bars <= max_range // Pozitif // Osc: Higher Low osc_hl = div_select[lkbk_right] > ta.valuewhen(pl_found, div_select[lkbk_right], 1) and _inRange(pl_found[1]) // Price: Lower Low price_ll = low[lkbk_right] < ta.valuewhen(pl_found, low[lkbk_right], 1) bull_cond =price_ll and osc_hl and pl_found //// // Negatif // Osc: Lower High osc_lh = div_select[lkbk_right] < ta.valuewhen(ph_found, div_select[lkbk_right], 1) and _inRange(ph_found[1]) //DIVEND //VOLUMEDIV pine_wma(x, y) => norm = 0.0 sum = 0.0 for i = 0 to y - 1 weight = (y - i) * y norm := norm + weight factor = close[i] < open[i] ? -1 : 1 sum := sum + (x[i] * weight * factor) sum / norm vl1 = 5 vl2 = 8 vl3 = vl1 + vl2 vl4 = vl2 + vl3 vl5 = vl3 + vl4 v1 = pine_wma(volume, vl1) v2 = pine_wma(v1, vl2) v3 = pine_wma(v2, vl3) v4 = pine_wma(v3, vl4) vol = pine_wma(v4, vl5) lbR = 5 lbL = 5 rangeUpper = 60 rangeLower = 5 plFound = na(ta.pivotlow(vol, lbL, lbR)) ? false : true phFound = na(ta.pivothigh(vol, lbL, lbR)) ? false : true inRange(cond) => bars = ta.barssince(cond == true) rangeLower <= bars and bars <= rangeUpper // vol: Higher Low volHL = vol[lbR] > ta.valuewhen(plFound, vol[lbR], 1) and inRange(plFound[1]) // Price: Lower Low priceLL = low[lbR] < ta.valuewhen(plFound, low[lbR], 1) bullCond = priceLL and volHL and plFound volLH = vol[lbR] < ta.valuewhen(phFound, vol[lbR], 1) and _inRange(phFound[1]) // Price: Higher High priceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1) bearCond = priceHH and volLH and phFound //VOLUMEDIVEND //JADA DrawLine2(x1a, y1a, x2a, y2a) => clra1 = y1a < y2a ? #4bca01 : color.rgb(255, 0, 0) line.new(x1a, y1a, x2a, y2a, xloc.bar_index, color=clra1,style=line.style_dotted, width=2) srcya2 =ohlc4 LengthMA2 = 15 lengthya2 = 55 forecast2 = 125 var mult2 = 0.1 var source2 = "Noisy" sh2 = false varip points2 = array.new_float() varip cls2 = array.new_float() varip shift2 = 0.0 //---- t2 = 0. c2 = 0. t2 := 0.9*nz(t2[lengthya2],srcya2) + 0.1*srcya2 + ta.change(0.9*nz(t2[lengthya2],srcya2),lengthya2) trendya2 = ta.sma(t2,lengthya2) srcf2 = t2 fcast2 = srcf2 + ta.change(srcf2,forecast2) array.push(points2, fcast2) maya2 = ta.sma(ohlc4, LengthMA2) if barstate.ishistory == false and yada2 ita = 0 if shift2 == 0 shift2 := maya2 - array.get(points2, bar_index - forecast2) for i = bar_index - forecast2 to bar_index y1a = array.get(points2, i-1) y2a = array.get(points2, i) y1a := y1a+shift2 y2a := y2a+shift2 x1a = bar_index+ita x2a = bar_index+ita+1 DrawLine2(x1a,y1a, x2a, y2a) ita := ita+1 //JADA //RETEST sp = '            ' retestlen = 11 retestbull = true retestbear = true iVal = 'None' percent = 25 auto = true mlt = 77 res = '1' prem = false showDash = true dashLoc = 'Top Right' textSize = 'Normal' dSwingLine = true dOpposLine = false dRetest_Line = false dRetest_Label = true colBl = #089981 colBr = #ff2364 colBl2 = #08998180 colBr2 =#f2364580 //-----------------------------------------------------------------------------} //UDT //-----------------------------------------------------------------------------{ type piv float swing_prc // price int swing_bix // bar_index float oppos_prc // price int oppos_bix // bar_index bool active bool confirmed line swing_line line oppos_line line wicky_line label wicky_label type swing int bix float prc //-----------------------------------------------------------------------------} //Variables //-----------------------------------------------------------------------------{ n = bar_index INV = color(na) FGc = chart.fg_color table_position = dashLoc == 'Bottom Left' ? position.bottom_left : dashLoc == 'Top Right' ? position.top_right : position.bottom_right table_size = textSize == 'Tiny' ? size.tiny : textSize == 'Small' ? size.small : size.normal var tb = table.new(table_position, 2, 3 , bgcolor = #1e222d , border_color = #373a46 , border_width = 1 , frame_color = #373a46 , frame_width = 1) var swing swingH = swing.new() var swing swingL = swing.new() var piv pivH = piv.new() var piv pivL = piv.new() validate = iVal != 'None' valHigher= iVal == 'Volume outside swing > Threshold' valLower = iVal == 'Volume outside swing < Threshold' //---------------------------------------------------------------------------------------------------------------------} //Method //---------------------------------------------------------------------------------------------------------------------{ method n(float piv) => bool out = not na(piv) //---------------------------------------------------------------------------------------------------------------------} //Execution //---------------------------------------------------------------------------------------------------------------------{ tfS = timeframe.in_seconds( res ) tfC = timeframe.in_seconds(timeframe.period) rs = auto ? tfC / mlt : tfS if not validate and retest res := timeframe.period else rs := prem ? rs : math.max(60, rs) res := timeframe.from_seconds(math.min(tfC, rs)) ph = ta.pivothigh(retestlen, 1) pl = ta.pivotlow (retestlen, 1) [ltf_close, ltf_volume] = request.security_lower_tf(syminfo.tickerid, res, [close, volume]) ltf_size = ltf_close.size() if validate and retest if ltf_size > 0 and ltf_size[1] == 0 line.new(n, close, n, close + syminfo.mintick, color=color.silver, style=line.style_dotted, extend=extend.both) //---------------------------------------------------------------------------------------------------------------------} //retestbearish Pattern //---------------------------------------------------------------------------------------------------------------------{ if retestbear and retest if ph.n() swingH.bix := n-1 swingH.prc := ph sw = swingH.prc bx = swingH.bix if high > sw and retest and open < sw and close < sw valid = true if validate if ltf_close.size() > 0 outsideVolume = 0. totalVolume = ltf_volume.sum() for j = 0 to ltf_close.size() -1 if ltf_close.get(j) > sw outsideVolume += ltf_volume.get(j) if (valHigher ? 100 / totalVolume * outsideVolume < percent : 100 / totalVolume * outsideVolume > percent ) valid := false //if valid // label.new(n, high, text=str.format("Total Volume: {0}\nWick Volume: {1}", totalVolume, outsideVolume)) if valid and retest opposL = sw opposB = n for i = 1 to n - bx -1 if low [i] < opposL opposL := low [i] opposB := n - i if not pivH.confirmed pivH.swing_line .delete() pivH.oppos_line .delete() pivH.wicky_line .delete() pivH.wicky_label.delete() pivH := piv.new(sw, bx, opposL, opposB, true, false) if dSwingLine pivH.swing_line := line.new (bx , sw , n, sw , color=colBr,width=3) if dOpposLine pivH.oppos_line := line.new (opposB, opposL, n, opposL, color=colBr, style=line.style_dotted) if dRetest_Line pivH.wicky_line := line.new (n , high , n, sw , color=colBr2, width=3) if dRetest_Label pivH.wicky_label := label.new(n , high , style=label.style_label_down , text='Retest🐻', textcolor=colBr , color=INV, size=size.normal ) if pivH.active and not pivH.confirmed and retest pivH.swing_line.set_x2(n) pivH.oppos_line.set_x2(n) if close < pivH.oppos_prc pivH.confirmed := true if pivH.wicky_label.get_x() == n pivH.wicky_label.set_text('Retest🐻') else label.new(n, high, style=label.style_label_down, text='', textcolor=colBr, color=INV, size=size.normal) if n - pivH.swing_bix > 500 or close > pivH.swing_prc pivH.active := false if not pivH.confirmed pivH.swing_line .delete() pivH.oppos_line .delete() pivH.wicky_line .delete() pivH.wicky_label.delete() //---------------------------------------------------------------------------------------------------------------------} //retestbullish Pattern //---------------------------------------------------------------------------------------------------------------------{ if retestbull and retest if pl.n() swingL.bix := n-1 swingL.prc := pl sw = swingL.prc bx = swingL.bix if low < sw and open > sw and close > sw valid = true if validate if ltf_close.size() > 0 outsideVolume = 0. totalVolume = ltf_volume.sum() for j = 0 to ltf_close.size() -1 if ltf_close.get(j) < sw outsideVolume += ltf_volume.get(j) if (valHigher ? 100 / totalVolume * outsideVolume < percent : 100 / totalVolume * outsideVolume > percent ) valid := false if valid opposH = sw opposB = n for i = 1 to n - bx -1 if high[i] > opposH opposH := high[i] opposB := n - i if not pivL.confirmed pivL.swing_line .delete() pivL.oppos_line .delete() pivL.wicky_line .delete() pivL.wicky_label.delete() pivL := piv.new(sw, bx, opposH, opposB, true, false) if dSwingLine pivL.swing_line := line.new (bx , sw , n, sw , color=colBl , width=3) if dOpposLine pivL.oppos_line := line.new (opposB, opposH, n, opposH, color=colBl , style=line.style_dotted) if dRetest_Line pivL.wicky_line := line.new (n , low , n, sw , color=colBl2, width=3) if dRetest_Label pivL.wicky_label := label.new(n , low , style=label.style_label_up , text='Retest🐂', textcolor=colBl , color=INV, size=size.normal ) if pivL.active and not pivL.confirmed and retest pivL.swing_line.set_x2(n) pivL.oppos_line.set_x2(n) if close > pivL.oppos_prc pivL.confirmed := true if pivL.wicky_label.get_x() == n pivL.wicky_label.set_text('Retest🐂') else label.new(n, low, style=label.style_label_up, text='', textcolor=colBl, color=INV, size=size.normal) if n - pivL.swing_bix > 500 and retest or close < pivL.swing_prc pivL.active := false if not pivL.confirmed pivL.swing_line .delete() pivL.oppos_line .delete() pivL.wicky_line .delete() pivL.wicky_label.delete() //---------------------------------------------------------------------------------------------------------------------} //Dashboard //---------------------------------------------------------------------------------------------------------------------{ if barstate.islast and validate and showDash and retest tb.cell(0, 0, str.format("LTF: {0}", res), text_color=color.white, text_size=table_size) //---------------------------------------------------------------------------------------------------------------------} //RETEST BİTTİ cond = longCondition ? 1 : shortCondition ? 2 : na s01 = input.symbol('BINANCE:BTCUSDT',title='1.Takip',group='Parite / Tarama Paneli') s02 = input.symbol('BINANCE:ETHUSDT',title='2.Takip',group='Parite / Tarama Paneli') s03 = input.symbol('BINANCE:LTCUSDT',title='3.Takip',group='Parite / Tarama Paneli') s04 = input.symbol('BINANCE:XRPUSDT',title='4.Takip',group='Parite / Tarama Paneli') a01 = request.security(s01, timeframe.period, cond) a02 = request.security(s02, timeframe.period, cond) a03 = request.security(s03, timeframe.period, cond) a04 = request.security(s04, timeframe.period, cond) text01 = a01 == 1 ? '🐂' : a01 == 2 ? '🐻' : na text02 = a02 == 1 ? '🐂' : a02 == 2 ? '🐻' : na text03 = a03 == 1 ? '🐂' : a03 == 2 ? '🐻' : na text04 = a04 == 1 ? '🐂' : a04 == 2 ? '🐻' : na col01 = a01 == 1 ? color.green : a01 == 2 ? color.red : color.black col02 = a02 == 1 ? color.green : a02 == 2 ? color.red : color.black col03 = a03 == 1 ? color.green : a03 == 2 ? color.red : color.black col04 = a04 == 1 ? color.green : a04 == 2 ? color.red : color.black //probab ---------------------------------------------------------------------------------------------------------------------{ float source = hlc3 int problength = 60 int gap_problength = 20 int gap = 10 color colorUp = #0fac16 color colorDn = #c51212 // ---------------------------------------------------------------------------------------------------------------------} // 𝙄𝙉𝘿𝙄𝘾𝘼𝙏𝙊𝙍 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎 // ---------------------------------------------------------------------------------------------------------------------{ // Calculate moving averages ema_ = ta.ema(source, problength) sma_ = ta.sma(source, problength) dema_ = ta.ema(2 * ta.ema(source, problength) - ta.ema(ta.ema(source, problength), problength), problength) vwma_ = ta.vwma(source, problength) // Calculate faster moving averages with lower problength ema_fast = ta.ema(source, problength-gap_problength) sma_fast = ta.sma(source, problength-gap_problength) dema_fast = ta.ema(2 * ema_fast - ta.ema(ema_fast, problength-gap_problength), problength-gap_problength) vwma_fast = ta.vwma(source, problength-gap_problength) // Smoothed Gradient Signal Function sig(float src, gap)=> ta.ema( source >= src[gap] ? 1 : source >= src[gap-1] ? 0.9 : source >= src[gap-2] ? 0.8 : source >= src[gap-3] ? 0.7 : source >= src[gap-4] ? 0.6 : source >= src[gap-5] ? 0.5 : source >= src[gap-6] ? 0.4 : source >= src[gap-7] ? 0.3 : source >= src[gap-8] ? 0.2 : source >= src[gap-9] ? 0.1 : 0, 4 ) // Calculate trend for each faster moving average ema_trend_fast = sig(ema_fast, gap) sma_trend_fast = sig(sma_fast, gap) dema_trend_fast = sig(dema_fast, gap) vwma_trend_fast = sig(vwma_fast, gap) // Calculate trend for each moving average ema_trend = sig(ema_, gap) sma_trend = sig(sma_, gap) dema_trend = sig(dema_, gap) vwma_trend = sig(vwma_, gap) // Define prior probabilities using moving averages prior_up = (ema_trend + sma_trend + dema_trend + vwma_trend) / 4 prior_down = 1 - prior_up // Define likelihoods using faster moving averages likelihood_up = (ema_trend_fast + sma_trend_fast + dema_trend_fast + vwma_trend_fast) / 4 likelihood_down = 1 - likelihood_up // Calculate posterior probabilities using 𝘽𝙖𝙮𝙚𝙨❜ 𝙩𝙝𝙚𝙤𝙧𝙚𝙢 posterior_up = prior_up * likelihood_up / (prior_up * likelihood_up + prior_down * likelihood_down) posterior_down = prior_down * likelihood_down / (prior_up * likelihood_up + prior_down * likelihood_down) if na(posterior_up) posterior_up := 0 if na(posterior_down) posterior_down := 0 // ---------------------------------------------------------------------------------------------------------------------} //PROBAB END var table logo2 = table.new(position.top_right, 9, 9,frame_color=color.maroon, frame_width=3, border_width=1, border_color=color.olive) if barstate.islast and tablo table.cell(logo2, 0, 0,text=syminfo.ticker,text_size = size.normal, bgcolor=color.rgb(105, 158, 228),text_color=color.rgb(63, 19, 19), tooltip = syminfo.ticker+" çiftinde işlem yapmaktasınız") table.cell(logo2, 0, 4,text='HTF - '+ mtftrend,text_color=color.black,text_size = size.small,bgcolor=color.silver,tooltip="Üst zaman dilimindeki trendi gösterir.\nİşleme girmeden önce üst zaman teyidi önemlidir.\n1 Saatlik grafikte işleme girecekseniz 4 saatlik HTF\n15 Dakikalık grafikte işleme girecekseniz 1 saatlik HTF\nSonuç olarak alt ve üst zaman uyumu önemlidir.\nÜst zaman dilimiyle işleme girmek daha olgun sinyallerle giriş sağlar. Hem LTF hem HTF ile işleme girmek çok olgunlaşmış bir trends sinyali anlamına gelir.") table.cell(logo2, 0, 5,text='LTF - '+ mtftrend2,text_color=color.black,text_size = size.small,bgcolor=color.silver,tooltip="Alt zaman dilimindeki trendi gösterir.\nİşleme girmeden önce alt zaman teyidi önemlidir.\n1 Saatlik grafikte işleme girecekseniz 15 Dakika LTF\n15 Dakikalık grafikte işleme girecekseniz 5 dakika LTF\nSonuç olarak alt ve üst zaman uyumu önemlidir.\nLTF uyumu ile işleme girmek , sizi daha erken işleme sokarak kâr oranını büyütmeye yarayabilir.") table.cell(logo2, 0, 6,text='SHORT STOP🐻⛔️',text_size = size.small, bgcolor=color.red,text_color=color.black,tooltip = "Önerilen Short pozisyon stop noktasıdır.") table.cell(logo2, 0, 7,text='LONG STOP🐂⛔️',text_size = size.small, bgcolor=color.green,text_color=color.black,tooltip = "Önerilen Long pozisyon stop noktasıdır.") //table.cell(logo2, 0, 4,text='SHORT KÂR AL🐻💰',text_size = size.small, bgcolor=color.red,text_color=color.black,tooltip = "Önerilen Short pozisyon için kâr al noktasıdır.") table.cell(logo2, 0, 1,text='ANA TREND📊',text_size = size.small, bgcolor=color.green,text_color=color.black,tooltip = "HTF ve LTF den bağımsız olarak seçilen enstrumanın uzun vade Trendini gösterir") //table.cell(logo2, 0, 5,text='KÂR AL',text_size = size.small, bgcolor=color.silver,text_color=color.black,tooltip = "Önerilen Long pozisyon stop noktasıdır.") table.cell(logo2, 0, 2,text='YÜKSELİŞ %🐂',text_size = size.small, bgcolor=color.green,text_color=color.black,tooltip = "Yükseliş trendinin kuvveti.") table.cell(logo2, 0, 3,text='DÜŞÜŞ %🐻',text_size = size.small, bgcolor=color.red,text_color=color.black,tooltip = "Düşüş trendinin kuvveti.") table.cell(logo2, 1, 0,text=maintrend == 1 and close>t_uma_avg and ao_baseline > 0 and Trend == 1 and uma_trail > t_uma_avg ?'🐂' :Trend == -1 and closet_uma_avg and ao_baseline > 0 and Trend == 1 and uma_trail > t_uma_avg ?color.green :Trend == -1 and closet_uma_avg and ao_baseline > 0 and Trend == 1 and uma_trail > t_uma_avg ?'Yükseliş Trendi Onaylandı' :Trend == -1 and closeMA1?'Altın Kesişim🥇':ta.crossunder(MA1[1],t_uma_avg[1]) and closeMA1? color.rgb(63, 80, 63):ta.crossunder(MA1[1],t_uma_avg[1]) and closeMA1?color.rgb(233, 211, 15):ta.crossunder(MA1[1],t_uma_avg[1]) and closeMA1, title='🥇 ALTIN KESİŞİM', message='Piyasa mevcut zaman dilimine göre Güçlü Yükselişe başlatabilir. {{ticker}} - {{close}}')