Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
3.5 kB
1
Indexable
Never
//@version=5
indicator(title="Combined SAR and CTI", overlay=true, max_labels_count=500)

// Parabolik SAR
start = input(0.02)
increment = input(0.02)
maximum = input(0.2, "Max Value")
sar_out = ta.sar(start, increment, maximum)
plot(sar_out, "Parabolik SAR", style=plot.style_cross, color=#2962FF)

var int sar_counter = 0
var label sar_label = na
var int sonsarsifirlama= na      ////eklenen


label_color = input(color.new(color.white, 100), title="SAR Label Color")
label_offset = input(5, title="SAR Label Offset")

if (sar_out > close and sar_out[1] > close[1]) or (sar_out < close and sar_out[1] < close[1])
    sar_counter := sar_counter + 1
    sonsarsifirlama := bar_index //// Eklenen kod
else
    sar_counter := 1

if sar_counter == 10
    sar_counter := 1

if barstate.isconfirmed 

    sar_label := label.new(bar_index, sar_out + label_offset * syminfo.mintick, str.tostring(sar_counter), color=label_color, style=label.style_none)


// Coral Trend Indicator (CTI)
src = input(close, title='CTI Source')
sm = input(21, title='CTI Smoothing Period')
cd = input(0.4, title='CTI Constant D')

bar_col = input(false, title='CTI Color Bars')
flat = input(color.new(color.blue, 0), title='CTI Line')

raise = input(color.new(color.green, 0), title='CTI Raise Color')
fall = input(color.new(color.red, 0), title='CTI Fall Color')

var int soncftsifirlama=na        ////eklenen

di = (sm - 1.0) / 2.0 + 1.0
c1 = 2 / (di + 1.0)
c2 = 1 - c1
c3 = 3.0 * (cd * cd + cd * cd * cd)
c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd

var float cti_i1 = na
var float cti_i2 = na
var float cti_i3 = na
var float cti_i4 = na
var float cti_i5 = na
var float cti_i6 = na

cti_i1 := c1 * src + c2 * nz(cti_i1[1])
cti_i2 := c1 * cti_i1 + c2 * nz(cti_i2[1])
cti_i3 := c1 * cti_i2 + c2 * nz(cti_i3[1])
cti_i4 := c1 * cti_i3 + c2 * nz(cti_i4[1])
cti_i5 := c1 * cti_i4 + c2 * nz(cti_i5[1])
cti_i6 := c1 * cti_i5 + c2 * nz(cti_i6[1])

cti_Cto = -cd * cd * cd * cti_i6 + c3 * cti_i5 + c4 * cti_i4 + c5 * cti_i3

var int cti_counter = 0

cti_bfrC = cti_Cto > nz(cti_Cto[1]) ? raise : cti_Cto < nz(cti_Cto[1]) ? fall : na
cti_tc = bar_col ? flat : cti_bfrC

distance_between_bars = input(3, title='CTI Distance Between Bars')

plot(cti_Cto, title='CTI Trend', linewidth=3, style=plot.style_circles, color=cti_tc, editable=false)

if barstate.isconfirmed
    if cti_bfrC == cti_bfrC[1]
        cti_counter := cti_counter + 1
        soncftsifirlama := bar_index // Eklenen kod

        if cti_counter > 9
            cti_counter := 1
    else
        cti_counter := 1

    label.new(bar_index, cti_Cto + distance_between_bars * syminfo.mintick, str.tostring(cti_counter), color=color.new(color.white, 100), style=label.style_none)


//3- psar için
 if sar_counter == cti_counter and (sar_counter == 3 or sar_counter == 6 or sar_counter == 9)
      if sonsarsifirlama >soncftsifirlama 
          kacmumgeride = bar_index-sonsarsifirlama
          for i = 1 to kacmumgeride
                 label.set_text(saretiketiniz[kacmumgeride],i-1) /// *********


 if sar_counter == cti_counter and (cti_counter == 3 or cti_counter == 6 or cti_counter == 9)
      if soncftsifirlama > sonsarsifirlama
          kacmumgeride = bar_index-soncftsifirlama
          for i = 1 to kacmumgeride
                 label.set_text(labeletiktimiz[kacmumgeride],i-1) /// ********
Leave a Comment