yeni başlıktan devam
Printable View
yeni başlıktan devam
İlk mesaj benden gelsin o zaman :)
Hedef 2025 ocak minimum 150bin :)
53'ten sertçe geldi satış
51 altına inerse sarkma yapabilir, 48.5 altına inerse baya tatsız olur
düzeltmenin kısa kalması işi canımı sıkıyor. dert aranıyorum belki :)
55bini gösterecekler birazdan.
https://i.hizliresim.com/dt3qe7z.png
neredeyse geldik :) negatif uyumsuzluklarla devam ediyor.
57.5 artık aşağı bakan son yer. üstü baya yukarılardan bahseder ama tabi önceki master tepe civarını da unutmadan yürümek gerekir.
neyse geçebilirse tekrar bakalım.
etf :ok:
halving'e kalmış 2 aydan az süre: https://www.binance.com/en/events/bitcoin-halving
geriye bir tek eli kulağında faiz indirimleri kalıyor.
yolla 6 haneleri kpl üstad :)
Bit iyi gitti,eski zirvesi 60 üstüne fazla kalmadı,bazı alt coinlerde uçuşta:yes:
altcoinlere geçiş için öncelikle btcnin soğuması lazım ve dominansının önce eth sonrasında da diğerlerine kayması lazım bu esnada altcoinlerin çok gideceğni sanımyoruım
zamanı gelince şöyle sakin b.kunu çıkartmadan gidemiyor abi :)
Bit 62-63 arasında,bir gecede %13-14 fena değil,16 cıvarına inmişti,şimdi 4 misli ona göre.
https://x.com/btc_archive/status/176...h4vnojlh4BJh7g
Sen mi geldin yâ emir-ul muminûn
bende 62'ye kadar sıkıntı yok, altında ekşime başlar
gerçi 64.5 ufak tefek ihlalle de olsa dayanabilse ne güzel olur
kaldıraçlı olanlar....dikkatli olmalı....
69dan 59gösterilen yerde....10k fark....
amerikaya paralel çakılmış, ama 62 ve 64.5 üstüne dönülmüş sonuçta.
bir iki gün kritik. görüntüde tekrar hemen herşey pozitif, aşırı alım dışında, o da sürüp gidebiliyor zaman zaman.
57.5a pull back niyetlenip bu kadar yapabilmiş de olabilir, zebil gibi alım geliyor etflerden vs.
geçen çıkışta önceki tepede sallanmış ama bu kadar terör olmamıştı.
daha yukarıda olmuştu çok benzeri. orası 102de şimdi.
önce 69 üstüne oturalım, becerirsek 82 ve 102 görünecek ama arada zor bi yer de olacak.
:ok:,anında 69 rakamlardan 60 cıvarına inmesi ironi,oradan tekrar 67-68 olması hep ironi,çok büyük paralar dönüyor,öyle bizim gibi 3-500 dolarlarlan oynamıyorlar,milyon dolarlar dönüyor ortada,ben bunda değilim zaten,ilk çıktığında almıştık onuda çerez parasına sattık,nereden bileceksinki cent fiatından 60 bin üstüne atacağını,60 neysede bana 1000 rakamıda yeterliydi,1 adet bile bırakmadık korkumuza,neymis cia takipteymiş guya:notr:
67 üstü iyi, 64 altı pohtan artık :)
not :
ben böyle kesin şeylerden bahsediyor hissi verebilecek şekilde yazıyorum galiba ama sonuçta herkes neredeyse her zaman olasılıklardan bahsediyor. yani yazdıklarım (bence) parantezinde.
https://www.tradingview.com/x/1Emw6xjl/ 66 yoklar gibi...65 e pin atar mı....
https://www.tradingview.com/x/Tqfaqr7o/ 69.500 yoklayacak gibi....
https://www.tradingview.com/x/vSRf1nAF/PHP Code:
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © east-west_trading
//@version=5
indicator("Pivots and Swings",overlay=true, max_labels_count = 500, max_lines_count = 500, max_bars_back = 500)
//User inputs
pivotbars = input.int(title = 'number of bars for pivot', defval = 2, inline='1')
swingD = input.string(title = 'Show swing details?', options=['None','On plot','In table','Both'],defval ='None', inline='1')
labelcolor = input.color(title = 'Label background color', defval =color.white, inline='2')
PHtextcolor = input.color(title = 'Pivot High text', defval=color.green, inline ='2')
PLtextcolor = input.color(title = 'Pivot low text', defval=color.red, inline='2')
colorbars = input.bool(title='color bars basis trend?', defval = false, inline='3')
uptrendup = input.color(defval = color.rgb(65, 235, 71),title = 'uptrend / up day',inline='3')
uptrenddown = input.color(defval = color.rgb(3, 113, 6),title = 'Up trend / down day', inline='3')
downtrendup = input.color(defval = color.rgb(237, 162, 188),title='Down trend / up day', inline ='5')
downtrenddown = input.color(defval = color.rgb(159, 48, 48),title='Down trend / down day',inline='5')
showfirstpivots = input.bool(title = 'Show first order pivots', defval = true, group = '---- First Order Pivots ----', inline='1')
show1sttrends = input.bool(title='Show first order swing trends', defval = false,group = '---- First Order Pivots ----', inline='1' )
FOPH_color = input.color(defval = color.lime, title = 'Pivot high', group = '---- First Order Pivots ----', inline='1')
FOPL_color = input.color(defval = color.rgb(237, 162, 188), title = 'Pivot low', group = '---- First Order Pivots ----', inline='1')
FOPH_connect_color = input.color(defval = color.rgb(188, 218, 244), title = 'Up swing', group = '---- First Order Pivots ----', inline='2')
FOPL_connect_color = input.color(defval = color.rgb(188, 218, 244), title = 'Down swing', group = '---- First Order Pivots ----',inline='2' )
FOPH_style = input.string(defval = 'Circle', title = 'High style', group = '---- First Order Pivots ----', options = ['Circle','X Cross','Cross', 'Triangle Up', 'Triangle Down', 'Flag','Arrow Up','Arrow Down','Square',
'Diamond','None'], inline = '3')
FOPL_style = input.string(defval = 'Circle', title = 'Low style', group = '---- First Order Pivots ----', options = ['Circle','X Cross','Cross', 'Triangle Up', 'Triangle Down', 'Flag','Arrow Up','Arrow Down','Square',
'Diamond','None'], inline = '3')
FOP_size = input.string(size.auto, 'Size', options=[size.auto, size.tiny,size.small,size.normal,size.large,size.huge],group = '---- First Order Pivots ----', inline='3' )
showsecondpivots = input.bool(title='Show second order pivots', defval = true, group = '---- Second Order Pivots ----', inline='1')
show2ndtrends = input.bool(title='Show second order swing trends',defval=false, group = '---- Second Order Pivots ----', inline='1' )
SOPH_color = input.color(defval = color.teal, title = 'Pivot high', group = '---- Second Order Pivots ----', inline='2')
SOPL_color = input.color(defval = color.red, title = 'Pivot low', group = '---- Second Order Pivots ----',inline='2')
SOPH_connect_color = input.color(defval = color.silver, title = 'Up swing', group = '---- Second Order Pivots ----', inline='2')
SOPL_connect_color = input.color(defval = color.silver, title = 'Down swing', group = '---- Second Order Pivots ----',inline='2' )
SOPH_style = input.string(defval = 'Triangle Down', title = ' High style', group = '---- Second Order Pivots ----', options = ['Circle','X Cross','Cross', 'Triangle Up', 'Triangle Down', 'Flag','Arrow Up',
'Arrow Down','Square', 'Diamond','None'], inline='3')
SOPL_style = input.string(defval = 'Triangle Up', title = 'Low style', group = '---- Second Order Pivots ----', options = ['Circle','X Cross','Cross', 'Triangle Up', 'Triangle Down', 'Flag','Arrow Up',
'Arrow Down','Square', 'Diamond','None'], inline='3')
SOP_size = input.string(size.auto, 'Size', options=[size.auto, size.tiny,size.small,size.normal,size.large,size.huge],group = '---- Second Order Pivots ----', inline='3' )
showthirdpivots = input.bool(title='Show third order pivots', defval = true, group = '---- Third Order Pivots ----', inline ='1')
show3rdtrends = input.bool(title='show third order swings', defval = false, group = '---- Third Order Pivots ----', inline= '1')
TOPH_color = input.color(defval = color.black, title = 'Pivot high', group = '---- Third Order Pivots ----', inline='2')
TOPL_color = input.color(defval = color.black, title = 'Pivot low', group = '---- Third Order Pivots ----',inline='2')
TOPH_connect_color = input.color(defval = color.rgb(255, 153, 0, 66), title = 'Up swing', group = '---- Third Order Pivots ----', inline='2')
TOPL_connect_color = input.color(defval = color.rgb(255, 153, 0, 66), title = 'Down swing', group = '---- Third Order Pivots ----',inline='2' )
TOPH_style = input.string(defval = 'Triangle Down', title = 'High style', group = '---- Third Order Pivots ----', options = ['Circle','X Cross','Cross', 'Triangle Up', 'Triangle Down', 'Flag','Arrow Up',
'Arrow Down','Square', 'Diamond','None'], inline='3')
TOPL_style = input.string(defval = 'Triangle Up', title = 'Low style', group = '---- Third Order Pivots ----', options = ['Circle','X Cross','Cross', 'Triangle Up', 'Triangle Down', 'Flag','Arrow Up',
'Arrow Down','Square', 'Diamond','None'], inline='3')
TOP_size = input.string(size.auto, 'Size', options=[size.auto, size.tiny,size.small,size.normal,size.large,size.huge],group = '---- Third Order Pivots ----', inline='3' )
FOPH_style_option = switch FOPH_style
'Circle' => label.style_circle
'X Cross' => label.style_xcross
'Cross' => label.style_cross
'Triangle Up' => label.style_triangleup
'Triangle Down' => label.style_triangledown
'Flag' => label.style_flag
'Arrow Up'=>label.style_arrowup
'Arrow Down'=>label.style_arrowdown
'Square'=>label.style_square
'Diamond'=>label.style_diamond
'None'=>label.style_none
FOPL_style_option = switch FOPL_style
'Circle' => label.style_circle
'X Cross' => label.style_xcross
'Cross' => label.style_cross
'Triangle Up' => label.style_triangleup
'Triangle Down' => label.style_triangledown
'Flag' => label.style_flag
'Arrow Up'=>label.style_arrowup
'Arrow Down'=>label.style_arrowdown
'Square'=>label.style_square
'Diamond'=>label.style_diamond
'None'=>label.style_none
SOPH_style_option = switch SOPH_style
'Circle' => label.style_circle
'X Cross' => label.style_xcross
'Cross' => label.style_cross
'Triangle Up' => label.style_triangleup
'Triangle Down' => label.style_triangledown
'Flag' => label.style_flag
'Arrow Up'=>label.style_arrowup
'Arrow Down'=>label.style_arrowdown
'Square'=>label.style_square
'Diamond'=>label.style_diamond
'None'=>label.style_none
SOPL_style_option = switch SOPL_style
'Circle' => label.style_circle
'X Cross' => label.style_xcross
'Cross' => label.style_cross
'Triangle Up' => label.style_triangleup
'Triangle Down' => label.style_triangledown
'Flag' => label.style_flag
'Arrow Up'=>label.style_arrowup
'Arrow Down'=>label.style_arrowdown
'Square'=>label.style_square
'Diamond'=>label.style_diamond
'None'=>label.style_none
TOPH_style_option = switch TOPH_style
'Circle' => label.style_circle
'X Cross' => label.style_xcross
'Cross' => label.style_cross
'Triangle Up' => label.style_triangleup
'Triangle Down' => label.style_triangledown
'Flag' => label.style_flag
'Arrow Up'=>label.style_arrowup
'Arrow Down'=>label.style_arrowdown
'Square'=>label.style_square
'Diamond'=>label.style_diamond
'None'=>label.style_none
TOPL_style_option = switch TOPL_style
'Circle' => label.style_circle
'X Cross' => label.style_xcross
'Cross' => label.style_cross
'Triangle Up' => label.style_triangleup
'Triangle Down' => label.style_triangledown
'Flag' => label.style_flag
'Arrow Up'=>label.style_arrowup
'Arrow Down'=>label.style_arrowdown
'Square'=>label.style_square
'Diamond'=>label.style_diamond
'None'=>label.style_none
// Calculate pivot bars
ph = ta.pivothigh(pivotbars, pivotbars)
pl = ta.pivotlow(pivotbars, pivotbars)
// label positioning
labpos = ta.atr(10)
// ---- Variables for line drawings ---- //
//first order pivot connections
var string lastcheck1 = na,var int ph1index = 0,var int pl1index = 0,var int lookback1 = 0,var float ph1val = 0,var float pl1val = 0,var line connect1 = na
// second order pivot connections
var string lastcheck2 = na,var int ph2index = 0,var int pl2index = 0,var float ph2val = 0,var float pl2val = 0,var line connect2 = na,var array<line> lines = array.new<line>(),var float[] p2low_val = array.new_float(),
var int[] p2low_index = array.new_int(),var float[] p2high_val = array.new_float(),var int[] p2high_index = array.new_int()
// third order pivot connections
var string lastcheck3 = na,var int ph3index = 0,var int pl3index = 0,var int lookback3 = 0,var float ph3val = 0,var float pl3val = 0,var line connect3 = na
// --- Variables for pivots --- //
//variables for first order pivot lows
var float[] lows = array.new_float(3,0),var int[] pl_loc = array.new_int(3,0),var float pl1 = 0,var float pl2 = 0,var float pl3 = 0
// variables for second order pivot lows
var float[] seclows = array.new_float(3,0),var int[] secpl_loc = array.new_int(3,0),var float secpl1 = 0,var float secpl2 = 0,var float secpl3 = 0,var label secondpivotlow = na,var int spl_loc = 0
//variables for third order pivots
var label thirdpivotlow = na,var int tpl_loc = 0
//variables for first order pivot highs
var float[] highs = array.new_float(3,0),var int[] ph_loc = array.new_int(3,0),var float ph1 = 0,var float ph2 = 0,var float ph3 = 0
//variables for second order pivot highs
var float[] sechighs = array.new_float(3,0),var int[] secph_loc = array.new_int(3,0),var float secph1 = 0,var float secph2 = 0,var float secph3 = 0,var label secondpivothigh = na,var int sph_loc = 0
//variable for thrid order pivot highs
var label thirdpivothigh = na,var int tph_loc = 0
//sequence arrays
var float[] seqhighs = array.new_float(),var float[] seqlows = array.new_float()
// uncommon situation variables
var float temp_index_h = 0,var float temp_val_h = 0,var float[] temp_h = array.new_float(),var float temp_index_l = 0,var float temp_val_l = 0,var float[] temp_l = array.new_float()
// Variables for color coding
var label swinghigh = na,var label swinglow = na,var float lowprice = na,var float hiprice = na,var string trend = na,upday = close > open,downday = close < open
// Table
var table swings = table.new(position.top_right,20,20,border_color=color.black), var float[] highstamp = array.new_float(), var float[] lowstamp = array.new_float(),
var int[] highstampindex= array.new_int(), var int[] lowstampindex = array.new_int(),var float distance = 0, var float[] seqswing = array.new_float()
// ----- PIVOT HIGHS ----- //
if not na(ph)
if showfirstpivots == true
label.new(x=bar_index - pivotbars, y = na(labpos) ? high[pivotbars] + syminfo.mintick*250 : high[pivotbars] + labpos,style=FOPH_style_option, size=FOP_size,color=FOPH_color)
hiprice := high[pivotbars]
// set price arrays
array.push(highs, high[pivotbars]),array.set(highs, 0, array.get(highs, 1)), array.set(highs, 1, array.get(highs, 2)),array.set(highs, 2, high[pivotbars])
// set index arrays
array.push(ph_loc,bar_index[pivotbars]), array.set(ph_loc, 0, array.get(ph_loc, 1)),array.set(ph_loc, 1, array.get(ph_loc, 2)),array.set(ph_loc, 2, bar_index[pivotbars])
//set comparison values
ph1 := array.get(highs,0),ph2 := array.get(highs,1), ph3 := array.get(highs,2)
// first order swing connections
if lastcheck1 == 'PL1' or na(lastcheck1)
if pl1index !=0 and high[pivotbars] > pl1val
lookback1 := bar_index - pl1index
connect1 := show1sttrends == true ? line.new(x1 = pl1index, y1 = low[lookback1], x2 = bar_index - pivotbars, y2 = high[pivotbars], color=FOPH_connect_color) : na
lastcheck1 := 'PH1'
ph1val := high[pivotbars]
ph1index := bar_index - pivotbars
if lastcheck1 == 'PH1' and high[pivotbars] > ph1val
line.delete(connect1)
lookback1 := bar_index - pl1index
connect1 := show1sttrends == true ? line.new(x1 = pl1index, y1 = low[lookback1], x2 = bar_index - pivotbars, y2 = high[pivotbars], color=FOPH_connect_color) : na
ph1val := high[pivotbars]
ph1index := bar_index - pivotbars
//second order pivot highs
if (ph1 < ph2 and ph2 > ph3) or (ph1 == ph2 and ph2 > ph3)
sph_loc := array.get(ph_loc,1)
if ph1 < ph2 and ph2 == ph3
sph_loc := array.get(ph_loc,2)
if ((ph1 < ph2 and ph2 > ph3) or (ph1 == ph2 and ph2 > ph3) or (ph1 < ph2 and ph2 == ph3 ))
//set price arrays
array.push(sechighs, high[bar_index - sph_loc]),array.set(sechighs,0,array.get(sechighs,1)),array.set(sechighs,1,array.get(sechighs,2)),array.set(sechighs, 2, high[bar_index - sph_loc])
//set index arrays
array.push(secph_loc, bar_index[bar_index - sph_loc]),array.set(secph_loc,0,array.get(secph_loc,1)),array.set(secph_loc,1,array.get(secph_loc,2)), array.set(secph_loc, 2, bar_index[bar_index - sph_loc])
// set comparison values
secph1 := array.get(sechighs,0),secph2 := array.get(sechighs,1), secph3 := array.get(sechighs,2)
// label
secondpivothigh := showsecondpivots == true ? label.new(x = bar_index - (bar_index - sph_loc), y= high[bar_index - sph_loc] + labpos[bar_index - sph_loc]*2 , style=SOPH_style_option, size=SOP_size, color=SOPH_color ) : na
// second order pivot high swing connections
if lastcheck2 == 'PL2'
if sph_loc > pl2index
if high[bar_index - sph_loc] > pl2val
connect2 := show2ndtrends == true ? line.new(x1 = pl2index, y1 = low[bar_index - pl2index], x2 = sph_loc, y2 = high[bar_index - sph_loc], color=SOPH_connect_color) : na, lines.push(connect2)
swinghigh := swingD == 'On plot' or swingD == 'Both' ? label.new(x=sph_loc,y=high[bar_index - sph_loc] + labpos*4, color=labelcolor, textcolor=PHtextcolor,
text = 'Time : ' + str.tostring(sph_loc - pl2index) + '\n' + 'Distance : ' +
str.tostring(((high[bar_index - sph_loc]-low[bar_index - pl2index])/low[bar_index - pl2index]),'#.##'+'%'), size=size.small):na
distance := ((high[bar_index - sph_loc]-low[bar_index - pl2index])/low[bar_index - pl2index])
array.push(highstamp,distance), array.push(highstampindex,sph_loc - pl2index),array.push(seqswing,1), array.push(seqswing,distance), array.push(seqswing,sph_loc - pl2index)
array.clear(seqhighs),array.push(seqhighs,sph_loc),array.push(seqhighs, high[bar_index - sph_loc])
ph2index := sph_loc,ph2val := high[bar_index - sph_loc]
array.push(p2high_index, ph2index),array.push(p2high_val, ph2val)
lastcheck2 := 'PH2'
if high[bar_index - sph_loc] < pl2val
array.push(seqhighs, sph_loc),array.push(seqhighs,high[bar_index - sph_loc])
if sph_loc < spl_loc
line.delete(array.get(lines, array.size(lines) -1)), array.remove(lines, array.size(lines) -1)
connect2 := show2ndtrends == true ? line.new(x1 = pl2index, y1 = low[bar_index - pl2index], x2 = sph_loc, y2 = high[bar_index - sph_loc], color=SOPH_connect_color) : na,lines.push(connect2)
connect2 := show2ndtrends == true ? line.new(x1 = sph_loc, y1 = high[bar_index - sph_loc], x2 = spl_loc, y2 = low[bar_index - spl_loc], color=SOPL_connect_color) : na,lines.push(connect2)
swinglow := swingD == 'On plot'or swingD == 'Both' ? label.new(x=spl_loc,y=low[bar_index - spl_loc] - labpos*4, color=labelcolor, textcolor=PLtextcolor,
text = 'Time : ' + str.tostring(spl_loc - ph2index) + '\n' + 'Distance : ' + str.tostring(((low[bar_index - spl_loc]-high[bar_index - ph2index])/high[bar_index - ph2index]),'#.##'+'%'), size=size.small):na
distance := low[bar_index - spl_loc]-high[bar_index - ph2index]/high[bar_index - ph2index]
array.push(lowstamp,distance), array.push(lowstampindex,spl_loc - ph2index),array.push(seqswing,0), array.push(seqswing,distance), array.push(seqswing,spl_loc - pl2index)
lastcheck2 := 'PL2'
pl2index := spl_loc, pl2val := low[bar_index - spl_loc]
array.clear(seqlows),array.push(seqlows,spl_loc),array.push(seqlows, low[bar_index - spl_loc])
if sph_loc < pl2index
if array.size(seqlows) > 2 and array.size(lines)!=0
if array.get(seqlows, array.size(seqlows) - 2) > sph_loc
array.pop(seqlows), array.pop(seqlows)
if array.size(seqlows) > 2
for i = 1 to array.size(seqlows) by 2
array.push(temp_l, array.get(seqlows,i))
temp_val_l := array.min(temp_l),temp_index_l := array.get(seqlows, (array.indexof(seqlows, temp_val_l)-1))
if array.size(seqlows) == 2
temp_val_l := array.get(seqlows,1),temp_index_l := array.get(seqlows,0)
if temp_val_l < high[bar_index - sph_loc]
line.delete(array.get(lines, array.size(lines) - 1)), array.remove(lines, array.size(lines) - 1), label.delete(swinglow),array.pop(lowstamp), array.pop(lowstampindex),
array.pop(seqswing),array.pop(seqswing),array.pop(seqswing)
connect2 := show2ndtrends == true ? line.new(x1 = ph2index, y1 = high[bar_index - ph2index], x2 = int(temp_index_l), y2 = low[bar_index - temp_index_l], color=SOPL_connect_color ) : na,lines.push(connect2)
swinglow := swingD == 'On plot'or swingD == 'Both' ? label.new(x=int(temp_index_l),y=low[bar_index - temp_index_l] - labpos*4, color=labelcolor, textcolor=PLtextcolor,
text = 'Time : ' + str.tostring(temp_index_l - ph2index) + '\n' + 'Distance : ' + str.tostring(((low[bar_index - temp_index_l]-high[bar_index - ph2index])/high[bar_index - ph2index]),'#.##'+'%'), size=size.small):na
distance := (low[bar_index - spl_loc]-high[bar_index - ph2index])/high[bar_index - ph2index]
array.push(lowstamp,distance), array.push(lowstampindex,bar_index - int(temp_index_l)),array.push(seqswing,0), array.push(seqswing,distance), array.push(seqswing,bar_index - int(temp_index_l))
connect2 := show2ndtrends == true ? line.new(x1 = int(temp_index_l), y1 = low[bar_index - temp_index_l], x2 = sph_loc, y2 = high[bar_index - sph_loc], color=SOPH_connect_color) : na,lines.push(connect2)
swinghigh := swingD == 'On plot'or swingD == 'Both' ? label.new(x=sph_loc,y=high[bar_index - sph_loc] + labpos*4, color=labelcolor, textcolor=PHtextcolor,
text = 'Time : ' + str.tostring(sph_loc - temp_index_l) + '\n' + 'Distance : ' + str.tostring(((high[bar_index - sph_loc]-low[bar_index - temp_index_l])/low[bar_index - temp_index_l]),'#.##'+'%'), size=size.small):na
distance := ((high[bar_index - sph_loc]-low[bar_index - pl2index])/low[bar_index - pl2index])
array.push(highstamp,distance), array.push(highstampindex,sph_loc - int(temp_index_l)),array.push(seqswing,1), array.push(seqswing,distance), array.push(seqswing,sph_loc - int(temp_index_l))
connect2 := show2ndtrends == true ? line.new(x1 = sph_loc, y1 = high[bar_index -sph_loc], x2 = spl_loc, y2 = low[bar_index - spl_loc], color=SOPL_connect_color) : na,lines.push(connect2)
swinglow := swingD == 'On plot'or swingD == 'Both' ? label.new(x=spl_loc,y=low[bar_index - spl_loc] - labpos*4, color=labelcolor, textcolor=PLtextcolor, text = 'Time : ' + str.tostring(spl_loc - sph_loc) + '\n' + 'Distance : ' +
str.tostring(((low[bar_index - spl_loc]-high[bar_index - sph_loc])/high[bar_index - ph2index]),'#.##'+'%'), size=size.small):na
distance := (low[bar_index - spl_loc]-high[bar_index - ph2index])/high[bar_index - ph2index]
array.push(lowstamp,distance), array.push(lowstampindex,spl_loc - sph_loc),array.push(seqswing,0), array.push(seqswing,distance), array.push(seqswing,spl_loc - sph_loc)
array.clear(seqlows), array.push(seqlows,spl_loc),array.push(seqlows, low[bar_index - spl_loc])
ph2index := sph_loc,ph2val := high[ bar_index - sph_loc]
array.push(p2high_index, ph2index),array.push(p2high_val, ph2val),array.clear(seqhighs),array.push(seqhighs, sph_loc),array.push(seqhighs, high[bar_index - sph_loc]),array.clear(temp_l)
lastcheck2 := 'PL2',temp_val_l := na,temp_index_l := na
if array.size(seqlows) == 2 // Could be problems here
if high[bar_index - sph_loc] > ph2val
line.delete(array.get(lines, array.size(lines) -1)), array.remove(lines, array.size(lines) - 1)
line.delete(array.get(lines, array.size(lines) -1)), array.remove(lines, array.size(lines) - 1),label.delete(swinghigh),array.pop(highstamp), array.pop(highstampindex),
array.pop(seqswing),array.pop(seqswing),array.pop(seqswing),array.pop(seqswing),array.pop(seqswing),array.pop(seqswing)
connect2 := show2ndtrends == true ? line.new(x1 = array.get(p2low_index,array.size(p2low_index)-2),
y1 = low[bar_index - array.get(p2low_index,array.size(p2low_index)-2)], x2 = sph_loc, y2 = high[bar_index - sph_loc], color=SOPH_connect_color) : na,lines.push(connect2)
swinghigh := swingD == 'On plot'or swingD == 'Both' ? label.new(x=sph_loc,y=high[bar_index - sph_loc] + labpos*4, color=labelcolor, textcolor=PHtextcolor,
text = 'Time : ' + str.tostring(sph_loc - array.get(p2low_index,array.size(p2low_index)-2)) + '\n' + 'Distance : ' +
str.tostring(((high[bar_index - sph_loc]-low[bar_index - array.get(p2low_index,array.size(p2low_index)-2)])/low[bar_index - array.get(p2low_index,array.size(p2low_index)-2)]),'#.##'+'%'), size=size.small):na
distance := (high[bar_index - sph_loc]-low[bar_index - array.get(p2low_index,array.size(p2low_index)-2)])/low[bar_index - array.get(p2low_index,array.size(p2low_index)-2)]
// distance := (high[bar_index - sph_loc]-low[bar_index - pl2index])/low[bar_index - pl2index]
array.push(highstamp,distance), array.push(highstampindex,sph_loc - array.get(p2low_index,array.size(p2low_index)-2)),array.push(seqswing,1), array.push(seqswing,distance),
array.push(seqswing,sph_loc - array.get(p2low_index,array.size(p2low_index)-2))
connect2 := show2ndtrends == true ? line.new(x1 = sph_loc, y1 = high[bar_index - sph_loc], x2 = spl_loc, y2 = low[bar_index - spl_loc], color=SOPL_connect_color ) : na,lines.push(connect2)
swinglow := swingD == 'On plot'or swingD == 'Both' ? label.new(x=spl_loc,y=low[bar_index - spl_loc] - labpos*4, color=labelcolor, textcolor=PLtextcolor,
text = 'Time : ' + str.tostring(spl_loc - sph_loc) + '\n' + 'Distance : ' + str.tostring(((low[bar_index - spl_loc]-high[bar_index - sph_loc])/high[bar_index - ph2index]),'#.##'+'%'), size=size.small):na
distance := (low[bar_index - spl_loc]-high[bar_index - ph2index])/high[bar_index - ph2index]
array.push(lowstamp,distance), array.push(lowstampindex,spl_loc - sph_loc),array.push(seqswing,0), array.push(seqswing,distance), array.push(seqswing,spl_loc - sph_loc)
ph2index := sph_loc,ph2val := high[bar_index - sph_loc]
array.remove(p2high_index,array.size(p2high_index)-1),array.remove(p2high_val,array.size(p2high_val)-1),array.push(p2high_index, ph2index),array.push(p2high_val, ph2val)
if lastcheck2 == 'PH2'
if sph_loc > ph2index
if high[bar_index - sph_loc] < ph2val
array.push(seqhighs, sph_loc),array.push(seqhighs,high[bar_index - sph_loc])
if high[bar_index - sph_loc] >= ph2val
if array.size(lines)!=0
line.delete(array.get(lines, array.size(lines) -1)), array.remove(lines, array.size(lines) - 1),label.delete(swinghigh),array.pop(highstamp), array.pop(highstampindex),
array.pop(seqswing),array.pop(seqswing),array.pop(seqswing)
connect2 := show2ndtrends == true ? line.new(x1 = pl2index, y1 = low[bar_index - pl2index], x2 = sph_loc, y2 = high[bar_index - sph_loc], color=SOPH_connect_color) : na,lines.push(connect2)
swinghigh := swingD == 'On plot'or swingD == 'Both' ? label.new(x=sph_loc,y=high[bar_index - sph_loc] + labpos*4, color=labelcolor, textcolor=PHtextcolor,
text = 'Time : ' + str.tostring(sph_loc - pl2index) + '\n' + 'Distance : ' + str.tostring(((high[bar_index - sph_loc]-low[bar_index - pl2index])/low[bar_index - pl2index]),'#.##'+'%'), size=size.small):na
distance := ((high[bar_index - sph_loc]-low[bar_index - pl2index])/low[bar_index - pl2index])
array.push(highstamp,distance),array.push(highstampindex,sph_loc - pl2index),array.push(seqswing,1), array.push(seqswing,distance), array.push(seqswing,sph_loc - pl2index)
array.push(seqhighs,sph_loc), array.push(seqhighs, high[bar_index - sph_loc])
ph2index := sph_loc,ph2val := high[bar_index - sph_loc]
array.remove(p2high_index,array.size(p2high_index)-1),array.remove(p2high_val,array.size(p2high_val)-1), array.push(p2high_index, ph2index), array.push(p2high_val, ph2val)
if na(lastcheck2)
ph2index := sph_loc, ph2val := high[bar_index - sph_loc]
array.push(seqhighs, sph_loc),array.push(seqhighs,high[bar_index - sph_loc]), array.push(p2high_index, ph2index), array.push(p2high_val, ph2val)
lastcheck2 := 'PH2'
// third order pivot highs
if secph1 < secph2 and secph2 > secph3 or secph1 == secph2 and secph2 > secph3
tph_loc := array.get(secph_loc,1)
if secph1 < secph2 and secph2 == secph3
tph_loc :=array.get(secph_loc,2)
if (secph1 < secph2 and secph2 > secph3 or secph1 == secph2 and secph2 > secph3) or (secph1 < secph2 and secph2 == secph3)
thirdpivothigh := showthirdpivots == true ? label.new(x = bar_index - (bar_index - tph_loc), y= high[bar_index - tph_loc] + labpos[bar_index - tph_loc]*3 , style=TOPH_style_option,size=TOP_size,
color=TOPH_color) : na
//code for connecting third order swings
if lastcheck3 == 'PL3'
if tph_loc > pl3index and high[bar_index - tph_loc] > pl3val
connect3 := show3rdtrends == true ? line.new(x1 = pl3index, y1 = low[bar_index - pl3index], x2 = tph_loc, y2 = high[bar_index - tph_loc], color=TOPH_connect_color) : na
ph3index := tph_loc, ph3val := high[bar_index - tph_loc]
lastcheck3 := "PH3"
if lastcheck3 == 'PH3' and high[bar_index - tph_loc] > ph3val
line.delete(connect3),connect3 := show3rdtrends == true ? line.new(x1 = pl3index, y1 = low[bar_index - pl3index], x2 = tph_loc, y2 =high[bar_index - tph_loc], color=TOPH_connect_color) : na
ph3index := tph_loc, ph3val := high[bar_index - tph_loc]
if na(lastcheck3)
ph3index := tph_loc, ph3val := high[bar_index - tph_loc]
lastcheck3 := 'PH3'
// ----- PIVOT LOWS ----- //
if not na(pl)
if showfirstpivots == true
label.new(x=bar_index - pivotbars,y= na(labpos) ? low[pivotbars] - syminfo.mintick*250 : low[pivotbars] - labpos, style=FOPH_style_option, size=FOP_size,color=FOPL_color)
lowprice := low[pivotbars]
//set price arrays
array.push(lows, low[pivotbars]),array.set(lows, 0, array.get(lows, 1)),array.set(lows, 1, array.get(lows, 2)),array.set(lows, 2, low[pivotbars])
// set index arrays
array.push(pl_loc,bar_index[pivotbars]),array.set(pl_loc, 0, array.get(pl_loc, 1)),array.set(pl_loc, 1, array.get(pl_loc, 2)), array.set(pl_loc, 2, bar_index[pivotbars])
// set comparison values
pl1 := array.get(lows,0),pl2 := array.get(lows,1),pl3 := array.get(lows,2)
//first order swing connections
if lastcheck1 == 'PH1' or na(lastcheck1)
if ph1index !=0 and low[pivotbars] < ph1val
lookback1 := bar_index - ph1index
connect1 := show1sttrends == true ? line.new(x1 = ph1index, y1 = high[lookback1],x2= bar_index-pivotbars, y2=low[pivotbars], color=FOPL_connect_color ) : na
lastcheck1 := 'PL1'
pl1val := low[pivotbars]
pl1index := bar_index - pivotbars
if lastcheck1 == 'PL1' and low[pivotbars] < pl1val
line.delete(connect1)
lookback1 := bar_index - ph1index
connect1 := show1sttrends == true ? line.new(x1 = ph1index, y1 = high[lookback1],x2= bar_index-pivotbars, y2=low[pivotbars], color=FOPL_connect_color ) : na
pl1val := low[pivotbars]
pl1index := bar_index - pivotbars
//second order pivot lows
if (pl1 > pl2 and pl2 < pl3) or (pl1 == pl2 and pl2 < pl3)
spl_loc := array.get(pl_loc,1)
if pl1 > pl2 and pl2 == pl3
spl_loc := array.get(pl_loc,2)
if ((pl1 > pl2 and pl2 < pl3) or (pl1 == pl2 and pl2 < pl3) ) or (pl1 > pl2 and pl2 == pl3)
//set price arrays
array.push(seclows, low[bar_index - spl_loc]),array.set(seclows,0,array.get(seclows,1)),array.set(seclows,1,array.get(seclows,2)),array.set(seclows, 2, low[bar_index - spl_loc])
//set index arrays
array.push(secpl_loc, bar_index[bar_index - spl_loc]),array.set(secpl_loc,0,array.get(secpl_loc,1)),array.set(secpl_loc,1,array.get(secpl_loc,2)),array.set(secpl_loc, 2, bar_index[bar_index - spl_loc])
//set comparison values
secpl1 := array.get(seclows,0),secpl2 := array.get(seclows,1),secpl3 := array.get(seclows,2)
// label
secondpivotlow := showsecondpivots == true ? label.new(x = bar_index - (bar_index - spl_loc), y= low[bar_index - spl_loc] - labpos[(bar_index - spl_loc)]*2 , style=SOPL_style_option, size=SOP_size, color=SOPL_color) : na
// second order pivot low swing connections
if lastcheck2 == 'PH2'
if spl_loc > ph2index
if low[bar_index - spl_loc] < ph2val
connect2 := show2ndtrends == true ? line.new(x1 = ph2index, y1 = high[bar_index - ph2index], x2 = spl_loc, y2 = low[bar_index - spl_loc], color=SOPL_connect_color) : na,lines.push(connect2)
swinglow := swingD == 'On plot'or swingD == 'Both' ? label.new(x=spl_loc,y=low[bar_index - spl_loc] - labpos*4, color=labelcolor, textcolor=PLtextcolor,
text = 'Time : ' + str.tostring(spl_loc - ph2index) + '\n' + 'Distance : ' + str.tostring(((low[bar_index - spl_loc]-high[bar_index - ph2index])/high[bar_index - ph2index]),'#.##'+'%'), size=size.small):na
distance := (low[bar_index - spl_loc]-high[bar_index - ph2index])/high[bar_index - ph2index]
array.push(lowstamp,distance),array.push(lowstampindex,spl_loc - ph2index), array.push(seqswing,0), array.push(seqswing,distance), array.push(seqswing,spl_loc - ph2index)
array.clear(seqlows),array.push(seqlows,spl_loc),array.push(seqlows, low[bar_index - spl_loc])
pl2index := spl_loc,pl2val := low[bar_index - spl_loc]
array.push(p2low_index, pl2index),array.push(p2low_val, pl2val)
lastcheck2 := 'PL2'
if low[bar_index - spl_loc] > ph2val
array.push(seqlows, spl_loc),array.push(seqlows,low[bar_index - spl_loc])
if spl_loc < sph_loc
connect2 := show2ndtrends == true ? line.new(x1 = spl_loc, y1 = low[bar_index - spl_loc], x2 = sph_loc, y2 = high[bar_index - sph_loc], color=SOPH_connect_color) : na,lines.push(connect2)
swinghigh := swingD == 'On plot'or swingD == 'Both' ? label.new(x=sph_loc,y=high[bar_index - sph_loc] + labpos*4, color=labelcolor, textcolor=PHtextcolor,
text = 'Time : ' + str.tostring(sph_loc - pl2index) + '\n' + 'Distance : ' + str.tostring(((high[bar_index - sph_loc]-low[bar_index - pl2index])/low[bar_index - pl2index]),'#.##'+'%'), size=size.small):na
distance := ((high[bar_index - sph_loc]-low[bar_index - pl2index])/low[bar_index - pl2index])
array.push(highstamp,distance),array.push(highstampindex,sph_loc - pl2index),array.push(seqswing,1), array.push(seqswing,distance), array.push(seqswing,sph_loc - pl2index)
ph2index := sph_loc,ph2val := high[bar_index - sph_loc]
lastcheck2 := 'PH2'
array.clear(seqhighs),array.push(seqhighs,sph_loc),array.push(seqhighs, high[bar_index - sph_loc])
if spl_loc < ph2index
if array.size(seqhighs) > 2 and array.size(lines)!=0
if array.get(seqhighs, array.size(seqhighs) - 2) > spl_loc
array.pop(seqhighs), array.pop(seqhighs)
if array.size(seqhighs) > 2
for i = 1 to array.size(seqhighs) by 2
array.push(temp_h, array.get(seqhighs,i))
temp_val_h := array.max(temp_h),temp_index_h := array.get(seqhighs, (array.indexof(seqhighs, temp_val_h)-1))
if array.size(seqhighs) == 2
temp_val_h := array.get(seqhighs,1),temp_index_h := array.get(seqhighs,0)
if temp_val_h > low[bar_index - spl_loc]
line.delete(array.get(lines, array.size(lines) -1)), array.remove(lines, array.size(lines) - 1), array.pop(highstamp), array.pop(highstampindex), label.delete(swinghigh),
array.pop(seqswing),array.pop(seqswing),array.pop(seqswing)
connect2 := show2ndtrends == true ? line.new(x1 = pl2index, y1 = low[bar_index - pl2index], x2 = int(temp_index_h), y2 = high[bar_index - temp_index_h], color=SOPH_connect_color ) : na,lines.push(connect2)
swinghigh := swingD == 'On plot'or swingD == 'Both' ? label.new(x=int(temp_index_h),y=high[bar_index - temp_index_h] + labpos*4, color=labelcolor, textcolor=PHtextcolor,
text = 'Time : ' + str.tostring(temp_index_h - pl2index) + '\n' + 'Distance : ' + str.tostring(((high[bar_index - temp_index_h]-low[bar_index - pl2index])/low[bar_index - pl2index]),'#.##'+'%'), size=size.small):na
distance := ((high[bar_index - temp_index_h]-low[bar_index - pl2index])/low[bar_index - pl2index])
array.push(highstamp,distance),array.push(highstampindex,int(temp_index_h) - pl2index),array.push(seqswing,1), array.push(seqswing,distance), array.push(seqswing,int(temp_index_h) - pl2index)
connect2 := show2ndtrends == true ? line.new(x1 = int(temp_index_h), y1 = high[bar_index - temp_index_h], x2 = spl_loc, y2 = low[bar_index - spl_loc], color=SOPL_connect_color) : na,lines.push(connect2)
swinglow := swingD == 'On plot'or swingD == 'Both' ? label.new(x=spl_loc,y=low[bar_index - spl_loc] - labpos*4, color=labelcolor, textcolor=PHtextcolor,
text = 'Time : ' + str.tostring(spl_loc - temp_index_h) + '\n' + 'Distance : ' + str.tostring(((low[bar_index - spl_loc]-high[bar_index - temp_index_h])/high[bar_index - temp_index_h]),'#.##'+'%'), size=size.small):na
distance := (low[bar_index - spl_loc]-high[bar_index - ph2index])/high[bar_index - ph2index]
array.push(lowstamp,distance),array.push(lowstampindex,spl_loc - int(temp_index_h)),array.push(seqswing,0), array.push(seqswing,distance), array.push(seqswing,spl_loc - int(temp_index_h))
connect2 := show2ndtrends == true ? line.new(x1 = spl_loc, y1 = low[bar_index -spl_loc], x2 = sph_loc, y2 = high[bar_index - sph_loc], color=SOPH_connect_color) : na,lines.push(connect2)
swinghigh := swingD == 'On plot'or swingD == 'Both' ? label.new(x=sph_loc,y=high[bar_index - sph_loc] + labpos*4, color=labelcolor, textcolor=PHtextcolor,
text = 'Time : ' + str.tostring(sph_loc - spl_loc) + '\n' + 'Distance : ' + str.tostring(((high[bar_index - sph_loc]-low[bar_index - spl_loc])/low[bar_index - pl2index]),'#.##'+'%'), size=size.small):na
distance := ((high[bar_index - sph_loc]-low[bar_index - spl_loc])/low[bar_index - spl_loc])
array.push(highstamp,distance), array.push(highstampindex,sph_loc - spl_loc),array.push(seqswing,1), array.push(seqswing,distance), array.push(seqswing,sph_loc - spl_loc)
array.clear(seqhighs),array.push(seqhighs, sph_loc),array.push(seqhighs, high[bar_index - sph_loc])
pl2index := spl_loc,pl2val := low[bar_index - spl_loc]
array.push(p2low_index, pl2index),array.push(p2low_val, pl2val),array.clear(seqlows),array.push(seqlows, spl_loc),array.push(seqlows, low[bar_index - spl_loc]),array.clear(temp_h)
lastcheck2 := 'PH2'
temp_val_h := na,temp_index_h := na
if array.size(seqhighs) == 2
if low[bar_index - spl_loc] < pl2val
line.delete(array.get(lines, array.size(lines) -1)), array.remove(lines, array.size(lines) - 1)
line.delete(array.get(lines, array.size(lines) -1)), array.remove(lines, array.size(lines) - 1),label.delete(swinglow),array.pop(lowstamp), array.pop(lowstampindex),label.delete(swinghigh),array.pop(highstamp),
array.pop(highstampindex),array.pop(seqswing),array.pop(seqswing),array.pop(seqswing),array.pop(seqswing),array.pop(seqswing),array.pop(seqswing)
connect2 := show2ndtrends == true ? line.new(x1 = array.get(p2high_index,array.size(p2high_index)-2),
y1 = high[bar_index - array.get(p2high_index,array.size(p2high_index)-2)], x2 = spl_loc, y2 = low[bar_index - spl_loc], color=SOPL_connect_color) : na,lines.push(connect2)
swinglow := swingD == 'On plot'or swingD == 'Both' ? label.new(x=spl_loc,y=low[bar_index - spl_loc] - labpos*4, color=labelcolor, textcolor=PLtextcolor,
text = 'Time : ' + str.tostring(spl_loc - array.get(p2high_index,array.size(p2high_index)-2)) + '\n' + 'Distance : ' +
str.tostring(((low[bar_index - spl_loc]-high[bar_index - array.get(p2high_index,array.size(p2high_index)-2)])/high[bar_index - array.get(p2high_index,array.size(p2high_index)-2)]),'#.##'+'%'), size=size.small):na
distance := (low[bar_index - spl_loc]-high[bar_index - array.get(p2high_index,array.size(p2high_index)-2)])/high[bar_index - array.get(p2high_index,array.size(p2high_index)-2)]
array.push(lowstamp,distance), array.push(lowstampindex,spl_loc - array.get(p2high_index,array.size(p2high_index)-2)),
array.push(seqswing,0), array.push(seqswing,distance), array.push(seqswing,spl_loc - array.get(p2high_index,array.size(p2high_index)-2))
connect2 := show2ndtrends == true ? line.new(x1 = spl_loc, y1 = low[bar_index - spl_loc], x2 = sph_loc, y2 = high[bar_index - sph_loc], color=SOPH_connect_color ) : na,lines.push(connect2)
swinghigh := swingD == 'On plot'or swingD == 'Both' ? label.new(x=sph_loc,y=high[bar_index - sph_loc] + labpos*4, color=labelcolor, textcolor=PHtextcolor,
text = 'Time : ' + str.tostring(sph_loc - spl_loc) + '\n' + 'Distance : ' + str.tostring(((high[bar_index - sph_loc]-low[bar_index - spl_loc])/low[bar_index - spl_loc]),'#.##'+'%'), size=size.small):na
distance := ((high[bar_index - sph_loc]-low[bar_index - spl_loc])/low[bar_index - spl_loc])
array.push(highstamp,distance), array.push(highstampindex,sph_loc - spl_loc),array.push(seqswing,1), array.push(seqswing,distance), array.push(seqswing,sph_loc - spl_loc)
pl2index := spl_loc,pl2val := low[bar_index - spl_loc]
array.remove(p2low_index,array.size(p2low_index)-1),array.remove(p2low_val,array.size(p2low_val)-1),array.push(p2low_index, pl2index),array.push(p2low_val, pl2val)
if lastcheck2 == 'PL2'
if spl_loc > pl2index
if low[bar_index - spl_loc] > pl2val
array.push(seqlows, spl_loc),array.push(seqlows,low[bar_index - spl_loc])
if low[bar_index - spl_loc] <= pl2val
if array.size(lines)!=0
line.delete(array.get(lines, array.size(lines) -1)), array.remove(lines, array.size(lines) - 1),label.delete(swinglow),array.pop(lowstamp),array.pop(lowstampindex),
array.pop(seqswing),array.pop(seqswing),array.pop(seqswing)
connect2 := show2ndtrends == true ? line.new(x1 = ph2index, y1 = high[bar_index - ph2index], x2 = spl_loc, y2 = low[bar_index - spl_loc], color=SOPL_connect_color) : na,lines.push(connect2)
swinglow := swingD == 'On plot'or swingD == 'Both' ? label.new(x=spl_loc,y=low[bar_index - spl_loc] - labpos*4, color=labelcolor, textcolor=PLtextcolor,
text = 'Time : ' + str.tostring(spl_loc - ph2index) + '\n' + 'Distance : ' + str.tostring(((low[bar_index - spl_loc]-high[bar_index - ph2index])/high[bar_index - ph2index]),'#.##'+'%'), size=size.small):na
distance := (low[bar_index - spl_loc]-high[bar_index - ph2index])/high[bar_index - ph2index]
array.push(lowstamp,distance),array.push(lowstampindex,spl_loc - ph2index),array.push(seqswing,0), array.push(seqswing,distance), array.push(seqswing,spl_loc - ph2index)
array.push(seqlows,spl_loc),array.push(seqlows, low[bar_index - spl_loc])
pl2index := spl_loc,pl2val := low[bar_index - spl_loc]
array.remove(p2low_index,array.size(p2low_index)-1),array.remove(p2low_val,array.size(p2low_val)-1),array.push(p2low_index, pl2index),array.push(p2low_val, pl2val)
if sph_loc > pl2index // Problem here
connect2 := show2ndtrends == true ? line.new(x1 = spl_loc, y1 = low[bar_index - spl_loc], x2 = sph_loc, y2 = high[bar_index - sph_loc], color=color.blue) : na,lines.push(connect2)
array.clear(seqhighs),array.push(seqhighs,sph_loc),array.push(seqhighs, high[bar_index - sph_loc])
ph2index := sph_loc,ph2val := high[bar_index - sph_loc]
array.push(p2high_index, ph2index),array.push(p2high_val, ph2val)
lastcheck2 := 'PH2'
if na(lastcheck2)
pl2index := spl_loc,pl2val := low[bar_index - spl_loc]
array.push(seqlows, spl_loc),array.push(seqlows,low[bar_index - spl_loc]),array.push(p2low_index, pl2index),array.push(p2low_val, pl2val)
lastcheck2 := 'PL2'
// third order pivot low
if secpl1 > secpl2 and secpl2 < secpl3 or secpl1 == secpl2 and secpl2 < secpl3
tpl_loc := array.get(secpl_loc,1)
if secpl1 > secpl2 and secpl2 == secpl3
tpl_loc :=array.get(secpl_loc,2)
if (secpl1 > secpl2 and secpl2 < secpl3 or secpl1 == secpl2 and secpl2 < secpl3) or (secpl1 > secpl2 and secpl2 == secpl3)
thirdpivotlow := showthirdpivots == true ?
label.new(x = bar_index - (bar_index - tpl_loc), y= low[(bar_index - tpl_loc)] - labpos[(bar_index - tpl_loc)]*3, style=TOPL_style_option,size=TOP_size,color=TOPL_color) : na
//code for connecting third order swings
if lastcheck3 == 'PH3'
if tpl_loc > ph3index and low[bar_index - tpl_loc] < ph3val
connect3 := show3rdtrends == true ? line.new(x1 = ph3index, y1 = high[bar_index - ph3index], x2 = tpl_loc, y2 = low[bar_index - tpl_loc], color=TOPL_connect_color) : na
pl3index := tpl_loc, pl3val := low[bar_index - tpl_loc]
lastcheck3 := 'PL3'
if lastcheck3 == 'PL3' and low[bar_index - tpl_loc] < pl3val
line.delete(connect3), connect3 := show3rdtrends == true ? line.new(x1 = ph3index, y1 = high[bar_index - ph3index], x2 = tpl_loc, y2 = low[bar_index - tpl_loc], color=TOPL_connect_color) : na
pl3index := tpl_loc, pl3val := low[bar_index - tpl_loc]
if na(lastcheck3)
pl3index := tpl_loc, pl3val := low[bar_index - tpl_loc]
lastcheck3 := 'PL3'
// color coding
if high > hiprice
trend := 'up'
if low < lowprice
trend :='down'
barcolor(colorbars == true ?trend=='up'? upday ? uptrendup:uptrenddown : trend == 'down'? upday ? downtrendup:downtrenddown: color.gray : na)
if barstate.islast
if array.size(highstamp) >= 3 and array.size(lowstamp) >=3 and swingD == 'In table' or swingD == 'Both'
table.cell(swings,1,0,bgcolor=labelcolor, text_color=color.rgb(7, 77, 7), text=' Pivot Highs', text_size=size.small)
table.cell(swings,1,1,bgcolor = labelcolor, text_color = PHtextcolor, text='Duration',text_valign = text.align_center, text_size = size.small)
table.cell(swings,2,1,bgcolor = labelcolor, text_color = PHtextcolor, text='Distance',text_valign = text.align_center, text_size = size.small)
// table.cell(swings,3,1,bgcolor = color.white, text_color = color.green, text='Sequence',text_valign = text.align_center, text_size = size.small)
table.cell(swings,1,2, bgcolor=labelcolor, text_color=PHtextcolor, text=str.tostring(array.get(highstampindex,array.size(highstampindex)-3)))
table.cell(swings,2,2, bgcolor=labelcolor, text_color=PHtextcolor, text=str.tostring(array.get(highstamp,array.size(highstamp)-3),'#.##'+ '%'))
// table.cell(swings,3,2, bgcolor=color.white, text_color=color.green, text = )
table.cell(swings,1,3, bgcolor=labelcolor, text_color=PHtextcolor, text=str.tostring(array.get(highstampindex,array.size(highstampindex)-2)))
table.cell(swings,2,3, bgcolor=labelcolor, text_color=PHtextcolor, text=str.tostring(array.get(highstamp,array.size(highstamp)-2),'#.##'+ '%'))
table.cell(swings,1,4, bgcolor=labelcolor, text_color=PHtextcolor, text=str.tostring(array.get(highstampindex,array.size(highstampindex)-1)))
table.cell(swings,2,4, bgcolor=labelcolor, text_color=PHtextcolor, text=str.tostring(array.get(highstamp,array.size(highstamp)-1),'#.##'+ '%'))
table.cell(swings,1,5,bgcolor=labelcolor, text_color=color.rgb(134, 38, 52), text=' Pivot Lows', text_size=size.small)
table.cell(swings,1,6,bgcolor = labelcolor, text_color = PLtextcolor, text='Duration',text_valign = text.align_center, text_size = size.small)
table.cell(swings,2,6,bgcolor = labelcolor, text_color = PLtextcolor, text='Distance',text_valign = text.align_center, text_size = size.small)
table.cell(swings,1,7, bgcolor=labelcolor, text_color=PLtextcolor, text=str.tostring(array.get(lowstampindex,array.size(lowstampindex)-3)))
table.cell(swings,2,7, bgcolor=labelcolor, text_color=PLtextcolor, text=str.tostring(array.get(lowstamp,array.size(lowstamp)-3),'#.##'+ '%'))
table.cell(swings,1,8, bgcolor=labelcolor, text_color=PLtextcolor, text=str.tostring(array.get(lowstampindex,array.size(lowstampindex)-2)))
table.cell(swings,2,8, bgcolor=labelcolor, text_color=PLtextcolor, text=str.tostring(array.get(lowstamp,array.size(lowstamp)-2),'#.##'+ '%'))
table.cell(swings,1,9, bgcolor=labelcolor, text_color=PLtextcolor, text=str.tostring(array.get(lowstampindex,array.size(lowstampindex)-1)))
table.cell(swings,2,9, bgcolor=labelcolor, text_color=PLtextcolor, text=str.tostring(array.get(lowstamp,array.size(lowstamp)-1),'#.##'+ '%'))
table.cell(swings,1,10, bgcolor=labelcolor, text_color = color.rgb(33, 184, 243), text = 'Sequence Swings', text_size = size.small, text_halign = text.align_right )
table.cell(swings,1,11, bgcolor=labelcolor, text_color=color.rgb(33, 184, 243), text = 'Duration', text_size = size.small)
table.cell(swings,2,11, bgcolor=labelcolor, text_color=color.rgb(33, 184, 243), text = 'Distance', text_size = size.small)
table.cell(swings,1,13, bgcolor=labelcolor,text_color= array.get(seqswing,array.size(seqswing)-15) == 1 ? PHtextcolor:PLtextcolor, text=str.tostring(array.get(seqswing,array.size(seqswing)-13)))
table.cell(swings,2,13, bgcolor=labelcolor,text_color= array.get(seqswing,array.size(seqswing)-15) == 1 ? PHtextcolor:PLtextcolor, text=str.tostring(array.get(seqswing,array.size(seqswing)-14),'#.##'+'%'))
table.cell(swings,1,14, bgcolor=labelcolor,text_color= array.get(seqswing,array.size(seqswing)-12) == 1 ? PHtextcolor:PLtextcolor, text=str.tostring(array.get(seqswing,array.size(seqswing)-10)))
table.cell(swings,2,14, bgcolor=labelcolor,text_color= array.get(seqswing,array.size(seqswing)-12) == 1 ? PHtextcolor:PLtextcolor, text=str.tostring(array.get(seqswing,array.size(seqswing)-11),'#.##'+'%'))
table.cell(swings,1,15, bgcolor=labelcolor,text_color= array.get(seqswing,array.size(seqswing)-9) == 1 ? PHtextcolor:PLtextcolor, text=str.tostring(array.get(seqswing,array.size(seqswing)-7)))
table.cell(swings,2,15, bgcolor=labelcolor,text_color= array.get(seqswing,array.size(seqswing)-9) == 1 ? PHtextcolor:PLtextcolor, text=str.tostring(array.get(seqswing,array.size(seqswing)-8),'#.##'+'%'))
table.cell(swings,1,16, bgcolor=labelcolor,text_color= array.get(seqswing,array.size(seqswing)-6) == 1 ? PHtextcolor:PLtextcolor, text=str.tostring(array.get(seqswing,array.size(seqswing)-4)))
table.cell(swings,2,16, bgcolor=labelcolor,text_color= array.get(seqswing,array.size(seqswing)-6) == 1 ? PHtextcolor:PLtextcolor, text=str.tostring(array.get(seqswing,array.size(seqswing)-5),'#.##'+'%'))
table.cell(swings,1,17, bgcolor=labelcolor,text_color= array.get(seqswing,array.size(seqswing)-3) == 1 ? PHtextcolor:PLtextcolor, text=str.tostring(array.get(seqswing,array.size(seqswing)-1)))
table.cell(swings,2,17, bgcolor=labelcolor,text_color= array.get(seqswing,array.size(seqswing)-3) == 1 ? PHtextcolor:PLtextcolor, text=str.tostring(array.get(seqswing,array.size(seqswing)-2),'#.##'+'%'))
//////////
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © dg_factor
//@version=5
string tt = "The script does not contain any security calls.
If there are not enough bars on the chart, the result may not be displayed. You can try higher timeframes."
sh_monday = input.bool(false, "Monday ")
sh_daily = input.bool(false, "Daily ")
sh_weekly = input.bool(true, "Weekly ", tooltip=tt)
sh_monthly = input.bool(false, "Monthly ", tooltip=tt)
sh_ln = input.bool(true, "Line ", group="DISPLAY")
sh_tx = input.bool(true, "Text ", group="DISPLAY")
sh_pr = input.bool(true, "Price ", group="DISPLAY")
col_1 = input.color(#2962ff, "Color", inline="c", group="DISPLAY")
col_2 = input.color(#00bb00, "", inline="c", group="DISPLAY")
col_3 = input.color(#fb0000, "", inline="c", group="DISPLAY")
col_4 = input.color(#9C27B0, "", inline="c", group="DISPLAY")
p(x, y, c, t) =>
var line ln = na, line.delete(ln)
var label lb = na, label.delete(lb)
ln := sh_ln ? line.new(x, y, time, y, xloc.bar_time, color=c) : na
t1 = sh_tx ? t : na, t2 = sh_pr ? " [" + str.tostring(y, format.mintick) + "]" : na
lb := label.new(time, y, t1 + t2, xloc.bar_time, yloc.price,
#00000000, label.style_label_left, c, size.normal, text.align_right)
//
f(x, t) =>
s = x and not x[1]
f = not x and x[1]
o = ta.valuewhen(s, open, 0)
var h1 = 0.0, h1 := fixnan(not x ? na : s or f ? high : math.max(high, h1))
var l1 = 0.0, l1 := fixnan(not x ? na : s or f ? low : math.min(low, l1))
var h2 = 0.0, h2 := s ? high : math.max(high, h2)
var l2 = 0.0, l2 := s ? low : math.min(low, l2)
h = t == "Monday" ? h1 : h2
l = t == "Monday" ? l1 : l2
m = math.avg(h, l)
ot = ta.valuewhen(s, time, 0)
ht = ta.valuewhen(h==high, time, 0)
lt = ta.valuewhen(l==low, time, 0)
mt = math.max(ht, lt)
p(ot, o, col_1, sh_tx ? t + " Açılış" : na)
p(ht, h, col_2, sh_tx ? t + " Yüksek" : na)
p(lt, l, col_3, sh_tx ? t + " Düşük" : na)
p(mt, m, col_4, sh_tx ? t + " Ortalama" : na)
//
if sh_monday
f(dayofweek == dayofweek.monday, "HaftaBaşı")
if sh_daily
f(time_tradingday != time_tradingday[1], "Günlük")
if sh_weekly
f(dayofweek < dayofweek[1], "Haftalık")
if sh_monthly
f(dayofmonth < dayofmonth[1], "Aylık")
/////////
PHP Code:
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © dg_factor
//@version=5
indicator("OHLC", overlay=true)
string tt = "The script does not contain any security calls.
If there are not enough bars on the chart, the result may not be displayed. You can try higher timeframes."
sh_monday = input.bool(false, "Monday ")
sh_daily = input.bool(false, "Daily ")
sh_weekly = input.bool(true, "Weekly ", tooltip=tt)
sh_monthly = input.bool(false, "Monthly ", tooltip=tt)
sh_ln = input.bool(true, "Line ", group="DISPLAY")
sh_tx = input.bool(true, "Text ", group="DISPLAY")
sh_pr = input.bool(true, "Price ", group="DISPLAY")
col_1 = input.color(#2962ff, "Color", inline="c", group="DISPLAY")
col_2 = input.color(#00bb00, "", inline="c", group="DISPLAY")
col_3 = input.color(#fb0000, "", inline="c", group="DISPLAY")
col_4 = input.color(#9C27B0, "", inline="c", group="DISPLAY")
p(x, y, c, t) =>
var line ln = na, line.delete(ln)
var label lb = na, label.delete(lb)
ln := sh_ln ? line.new(x, y, time, y, xloc.bar_time, color=c) : na
t1 = sh_tx ? t : na, t2 = sh_pr ? " [" + str.tostring(y, format.mintick) + "]" : na
lb := label.new(time, y, t1 + t2, xloc.bar_time, yloc.price,
#00000000, label.style_label_left, c, size.normal, text.align_right)
//
f(x, t) =>
s = x and not x[1]
f = not x and x[1]
o = ta.valuewhen(s, open, 0)
var h1 = 0.0, h1 := fixnan(not x ? na : s or f ? high : math.max(high, h1))
var l1 = 0.0, l1 := fixnan(not x ? na : s or f ? low : math.min(low, l1))
var h2 = 0.0, h2 := s ? high : math.max(high, h2)
var l2 = 0.0, l2 := s ? low : math.min(low, l2)
h = t == "Monday" ? h1 : h2
l = t == "Monday" ? l1 : l2
m = math.avg(h, l)
ot = ta.valuewhen(s, time, 0)
ht = ta.valuewhen(h==high, time, 0)
lt = ta.valuewhen(l==low, time, 0)
mt = math.max(ht, lt)
p(ot, o, col_1, sh_tx ? t + " Açılış" : na)
p(ht, h, col_2, sh_tx ? t + " Yüksek" : na)
p(lt, l, col_3, sh_tx ? t + " Düşük" : na)
p(mt, m, col_4, sh_tx ? t + " Ortalama" : na)
//
if sh_monday
f(dayofweek == dayofweek.monday, "HaftaBaşı")
if sh_daily
f(time_tradingday != time_tradingday[1], "Günlük")
if sh_weekly
f(dayofweek < dayofweek[1], "Haftalık")
if sh_monthly
f(dayofmonth < dayofmonth[1], "Aylık")
//
//@version=5
// Input parameters
length_high = input.int(20, title="High Length", minval=1)
length_low = input.int(20, title="Low Length", minval=1)
length_ema = input.int(20, title="EMA Length", minval=1)
// Calculate high and low within specified lengths
high_price = ta.highest(length_high)
low_price = ta.lowest(length_low)
median_price = (high_price + low_price) / 2
// Calculate EMAs for median price
ema_median = ta.ema(median_price, length_ema)
plot(median_price, color=color.rgb(19, 3, 253), style=plot.style_stepline, linewidth=1, title="Median")
plot(ema_median, color=color.rgb(247, 243, 3), style=plot.style_stepline, linewidth=1, title="EMAMedian")
kamalandık gibi, umarım bozar yoksa 69 altına savrulabilir yine
kama çalıştı diyebiliriz :)
kriptoda oluşup da çalışmayan nadir oldu şimdiye dek gördüklerimden, genelde güvenilir ama kriptoda %90 filan gidiyor..
TA ilgiliyseniz çalışınız, biliniz. bir anlamda 69-59 satışının etkisinden kurtulamadık.
https://i.hizliresim.com/cln8fuz.png
https://www.tradingview.com/x/H1yJ7vXz/
44den başlayan 73kusurla bitti....
58 hem pivot hem mom....
65 range kanalı kırılacak daha.....sonra 58e.....
range kanalı güncellenmiş....https://www.tradingview.com/x/NeptnLsp/
seanslık...https://www.tradingview.com/x/soCYyM1U/ 3.döngü ihtimal...dahilinde....
saatlik görüntü....https://www.tradingview.com/x/ZDO9DYKe/
https://www.tradingview.com/x/H5whZAyB/
https://www.tradingview.com/x/pYSZOBUp/PHP Code:
// This Pine Scriptâ„¢ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AllanDecker
//@version=5
indicator("Deck@r True Range Index", overlay=true,precision = 2, format = format.price, timeframe = "", timeframe_gaps = true)
// ATR period
atr_period = input.int(14, title="ATR Period")
// ATR multiplier
atr_multiplier = input.float(1.0, title="ATR Multiplier")
// Calculate ATR
atr_value = ta.atr(atr_period)
// Calculate upper and lower bands for ATR Bands
upper_band = ta.sma(close, 20) + (atr_multiplier * atr_value)
lower_band = ta.sma(close, 20) - (atr_multiplier * atr_value)
// Calculate midline at Fibonacci retracement level of 0.75
midline_75 = upper_band - (upper_band - lower_band) * 0.75
// Calculate midline at Fibonacci retracement level of 0.25
midline_25 = upper_band - (upper_band - lower_band) * 0.25
// Plot bands and midlines for ATR Bands
//plot(upper_band, color=color.red, title="Upper Band", style=plot.style_cross)
//plot(lower_band, color=color.red, title="Lower Band", style=plot.style_cross)
//plot(midline_75, color=color.purple, title="Midline 0.75")
//plot(midline_25, color=color.orange, title="Midline 0.25")
// Define buy and sell conditions
buy_condition = close > midline_25
sell_condition = close < midline_75
// Set candle colors
candle_color = buy_condition ? color.blue : sell_condition ? color.red : na
//barcolor(candle_color)
// Check for buy signal (price breaking above midline 0.25 of ATR Bands and CCI line color1 is blue)
buy_signal = ta.crossover(close, midline_25)
// Check for sell signal (price breaking below midline 0.75 of ATR Bands and CCI line color1 is red)
sell_signal = ta.crossunder(close, midline_75)
// Plot buy and sell signals for ATR Bands
plotshape(series=buy_signal, title="Buy Signal ATR", location=location.belowbar, color=color.rgb(41,98,255), style=shape.triangleup, size = size.tiny)
plotshape(series=sell_signal, title="Sell Signal ATR", location=location.abovebar, color=color.rgb(236,64,122), style=shape.triangledown, size = size.tiny)
// Alert conditions for ATR Bands
alertcondition(buy_signal, title="Buy", message="BUY")
alertcondition(sell_signal, title="Sell", message="SELL")
/////
// This Pine Scriptâ„¢ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BackQuant
//@version=5
// Kalman Filter parameters
series float pricesource = input.source(close, "Kalman Price Source", group = "Calculation")
simple float processNoise = input.float(0.01, title="Process Noise", step = 0.01, group = "Calculation")
simple float measurementNoise = input.float(3.0, title="Measurement Noise", group = "Calculation")
simple int N = input.int(5, title="Filter Order", minval=1, group = "Calculation")
simple bool showkalman = input.bool(true, "Show Filtered Price on chart?", group = "UI Settings")
simple bool paintCandles = input.bool(true, "Paint candles according to Trend?", group = "UI Settings")
var float[] stateEstimate = array.new_float(N, na)
var float[] errorCovariance = array.new_float(N, 100.0)
f_init(series float pricesource) =>
if na(array.get(stateEstimate, 0))
for i = 0 to N-1
array.set(stateEstimate, i, pricesource)
array.set(errorCovariance, i, 1.0)
f_kalman(series float pricesource) =>
// Prediction Step
predictedStateEstimate = array.new_float(N)
predictedErrorCovariance = array.new_float(N)
for i = 0 to N-1
array.set(predictedStateEstimate, i, array.get(stateEstimate, i)) // Simplified prediction
array.set(predictedErrorCovariance, i, array.get(errorCovariance, i) + processNoise)
kalmanGain = array.new_float(N)
for i = 0 to N-1
kg = array.get(predictedErrorCovariance, i) / (array.get(predictedErrorCovariance, i) + measurementNoise)
array.set(kalmanGain, i, kg)
array.set(stateEstimate, i, array.get(predictedStateEstimate, i) + kg * (pricesource - array.get(predictedStateEstimate, i)))
array.set(errorCovariance, i, (1 - kg) * array.get(predictedErrorCovariance, i))
array.get(stateEstimate, 0)
f_init(pricesource)
kalmanFilteredPrice = f_kalman(pricesource)
// Conditional Trend
var Trend = 0
if kalmanFilteredPrice>kalmanFilteredPrice[1]
Trend := 1
if kalmanFilteredPrice<kalmanFilteredPrice[1]
Trend := -1
// Colouring
var barColour = #ffffff
if Trend == 1
barColour := #33ff00
if Trend == -1
barColour := #ff0000
// Plotting
barcolor(paintCandles ? barColour : na)
plot(
showkalman ? kalmanFilteredPrice : na,
"Kalman",
color = color.new(barColour, 40),
linewidth = 4
)
/////////
https://www.tradingview.com/x/t6hh359P/PHP Code:
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
indicator(title="My Indicator", overlay=true)
// draws high label, requires index and the value that needs to be plotted
drawHighLabel(index, value) =>
label.new(index, na, str.tostring(value), yloc = yloc.abovebar, color=color.green, textcolor=color.white, style=label.style_label_down, yloc=yloc.abovebar)
// draws low label, requires index and the value that needs to be plotted
drawLowLabel(index, value) =>
label.new(index, na, str.tostring(value), yloc= yloc.belowbar, color=color.red, textcolor=color.white, style=label.style_label_up, yloc=yloc.belowbar)
// getting the close of a bar, requires index
getClose(barIndex) => close[bar_index - barIndex]
// getting the close of a bar, requires index
getOpen(barIndex) => open[bar_index - barIndex]
// getting the high of a bar, requires index
getHigh(barIndex) => high[bar_index - barIndex]
// getting the low of a bar, requires index
getLow(barIndex) => low[bar_index - barIndex]
// high swing, which is the previous two candle and the next two candle has to be lower than the indexed candle, requires index of the high candle.
highSwing(index) =>
getHigh(index) > getHigh(index+1) and getHigh(index) > getHigh(index+2) and getHigh(index) > getHigh(index-1) and getHigh(index) > getHigh(index-2)
// low swing, which is the previous two candle and the next two candle has to be higher than the indexed candle, requires index of the low candle.
lowSwing(index) =>
getLow(index) < getLow(index+1) and getLow(index) < getLow(index+2) and getLow(index) < getLow(index-1) and getLow(index) < getLow(index-2)
// Define a function to find the lowest low between two indices
findLowestLow(previousIndex, currentIndex) =>
// Initialize the lowest low and its index
float lowestLow = 10e10 // Initialize lowestLow to a very large value
int lowestLowIndex = na // Initialize lowestLowIndex to na
// Loop through the indices from previousIndex to currentIndex
for i = previousIndex to currentIndex
// Get the low for the current index
lowValue = low[bar_index - i] // Use low[i] instead of getLow(i)
// Update the lowest low if the current low is lower than the previous lowest low
if lowValue < lowestLow
lowestLow := lowValue
lowestLowIndex := i
// Return the lowest low index found between previousIndex and currentIndex
drawLowLabel(lowestLowIndex, "")
lowestLow
// Define a function to find the highest high between two indices
findHighestHigh(previousIndex, currentIndex) =>
// Initialize the highest high and its index
float highestHigh = -10e10
int highestHighIndex = 0
// Loop through the indices from previousIndex to currentIndex
for i = previousIndex to currentIndex
// Get the high for the current index
highValue = high[bar_index - i]
// Update the highest high if the current high is higher than the previous highest high
if highValue > highestHigh
highestHigh := highValue
highestHighIndex := i
// Return the highest high and its index found between previousIndex and currentIndex
drawHighLabel(highestHighIndex, "")
highestHigh
// Function to check if an array includes an index
arrayIncludesIndex(arr, index) =>
bool found = false
for i = 0 to array.size(arr) - 1
if array.get(arr, i) == index
found := true
found
if barstate.islast
// Define variables: initial_candle, final_candle where initial_candle is 108th candle and final_candle is 1st candle
var initial_candle = bar_index - 108
// Define variables: current_high, current_low which is defined on initial_candle
float current_high = getHigh(initial_candle)
float current_low = getLow(initial_candle)
int currentIndex = initial_candle
int previousIndex = initial_candle
int currentHighIndex = na
int currentLowIndex = na
int trend = 0
var int[] AllHighsIndex = array.new_int(0)
var int[] AllLowsIndex = array.new_int(0)
array.push(AllHighsIndex, initial_candle)
array.push(AllLowsIndex, initial_candle)
// Loop through all the candles from initial_candle to final_candle
for i = initial_candle to bar_index
if(i <= bar_index - 2)
if trend == 1 or getClose(i) > current_high
trend := 1
if getClose(i) < current_low
trend := -1
else if highSwing(i)
current_high := getHigh(i)
drawHighLabel(i, current_high)
previousIndex := currentIndex
currentIndex := i
if array.size(AllHighsIndex) >= 2
array.shift(AllHighsIndex)
array.push(AllHighsIndex, i)
else
array.push(AllHighsIndex, i)
// if a green candle makes a new high, the low of that candle should not be considered to draw the lowest low,except if it is the initial candle
containsHighIndex = arrayIncludesIndex(AllHighsIndex, previousIndex)
isGreenCandle = getOpen(previousIndex) < getClose(previousIndex)
if containsHighIndex and isGreenCandle and previousIndex != initial_candle
current_low := findLowestLow(previousIndex + 1, currentIndex)
else
current_low := findLowestLow(previousIndex, currentIndex)
trend:= 0
if trend == -1 or getClose(i) < current_low
trend := -1
if getClose(i) > current_high
trend := 1
else if lowSwing(i)
current_low := getLow(i)
drawLowLabel(i, current_low)
previousIndex := currentIndex
currentIndex := i
if array.size(AllLowsIndex) >= 2
array.shift(AllLowsIndex)
array.push(AllLowsIndex, i)
else
array.push(AllLowsIndex, i)
// if a red candle makes a new low, the high of that candle should not be considered to draw the highest high, except if it is the initial candle
containsLowIndex = arrayIncludesIndex(AllLowsIndex, previousIndex)
isRedCandle = getOpen(previousIndex) > getClose(previousIndex)
if containsLowIndex and isRedCandle and previousIndex != initial_candle
current_high := findHighestHigh(previousIndex + 1, currentIndex)
else
current_high := findHighestHigh(previousIndex, currentIndex)
trend := 0
////////
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AllanDecker
//@version=5
// ATR period
atr_period = input.int(14, title="ATR Period")
// ATR multiplier
atr_multiplier = input.float(1.0, title="ATR Multiplier")
// Calculate ATR
atr_value = ta.atr(atr_period)
// Calculate upper and lower bands for ATR Bands
upper_band = ta.sma(close, 20) + (atr_multiplier * atr_value)
lower_band = ta.sma(close, 20) - (atr_multiplier * atr_value)
// Calculate midline at Fibonacci retracement level of 0.75
midline_75 = upper_band - (upper_band - lower_band) * 0.75
// Calculate midline at Fibonacci retracement level of 0.25
midline_25 = upper_band - (upper_band - lower_band) * 0.25
// Plot bands and midlines for ATR Bands
//plot(upper_band, color=color.red, title="Upper Band", style=plot.style_cross)
//plot(lower_band, color=color.red, title="Lower Band", style=plot.style_cross)
//plot(midline_75, color=color.purple, title="Midline 0.75")
//plot(midline_25, color=color.orange, title="Midline 0.25")
// Define buy and sell conditions
buy_condition = close > midline_25
sell_condition = close < midline_75
// Set candle colors
candle_color = buy_condition ? color.blue : sell_condition ? color.red : na
//barcolor(candle_color)
// Check for buy signal (price breaking above midline 0.25 of ATR Bands and CCI line color1 is blue)
buy_signal = ta.crossover(close, midline_25)
// Check for sell signal (price breaking below midline 0.75 of ATR Bands and CCI line color1 is red)
sell_signal = ta.crossunder(close, midline_75)
// Plot buy and sell signals for ATR Bands
plotshape(series=buy_signal, title="Buy Signal ATR", location=location.belowbar, color=color.rgb(41,98,255), style=shape.triangleup, size = size.tiny)
plotshape(series=sell_signal, title="Sell Signal ATR", location=location.abovebar, color=color.rgb(236,64,122), style=shape.triangledown, size = size.tiny)
// Alert conditions for ATR Bands
alertcondition(buy_signal, title="Buy", message="BUY")
alertcondition(sell_signal, title="Sell", message="SELL")
/////
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © BackQuant
//@version=5
// Kalman Filter parameters
series float pricesource = input.source(close, "Kalman Price Source", group = "Calculation")
simple float processNoise = input.float(0.01, title="Process Noise", step = 0.01, group = "Calculation")
simple float measurementNoise = input.float(3.0, title="Measurement Noise", group = "Calculation")
simple int N = input.int(5, title="Filter Order", minval=1, group = "Calculation")
simple bool showkalman = input.bool(true, "Show Filtered Price on chart?", group = "UI Settings")
simple bool paintCandles = input.bool(true, "Paint candles according to Trend?", group = "UI Settings")
var float[] stateEstimate = array.new_float(N, na)
var float[] errorCovariance = array.new_float(N, 100.0)
f_init(series float pricesource) =>
if na(array.get(stateEstimate, 0))
for i = 0 to N-1
array.set(stateEstimate, i, pricesource)
array.set(errorCovariance, i, 1.0)
f_kalman(series float pricesource) =>
// Prediction Step
predictedStateEstimate = array.new_float(N)
predictedErrorCovariance = array.new_float(N)
for i = 0 to N-1
array.set(predictedStateEstimate, i, array.get(stateEstimate, i)) // Simplified prediction
array.set(predictedErrorCovariance, i, array.get(errorCovariance, i) + processNoise)
kalmanGain = array.new_float(N)
for i = 0 to N-1
kg = array.get(predictedErrorCovariance, i) / (array.get(predictedErrorCovariance, i) + measurementNoise)
array.set(kalmanGain, i, kg)
array.set(stateEstimate, i, array.get(predictedStateEstimate, i) + kg * (pricesource - array.get(predictedStateEstimate, i)))
array.set(errorCovariance, i, (1 - kg) * array.get(predictedErrorCovariance, i))
array.get(stateEstimate, 0)
f_init(pricesource)
kalmanFilteredPrice = f_kalman(pricesource)
// Conditional Trend
var Trend = 0
if kalmanFilteredPrice>kalmanFilteredPrice[1]
Trend := 1
if kalmanFilteredPrice<kalmanFilteredPrice[1]
Trend := -1
// Colouring
var barColour = #ffffff
if Trend == 1
barColour := #33ff00
if Trend == -1
barColour := #ff0000
// Plotting
barcolor(paintCandles ? barColour : na)
plot(
showkalman ? kalmanFilteredPrice : na,
"Kalman",
color = color.new(barColour, 40),
linewidth = 4
)
/////////
gelirse 60-61 oralar geri/ek alım için ilginç olabilir
orayı da delersek iş uzar gibi (ilk elde 50-51ler belki)