Artan

34,10 10 18:10
12,00 9.99 18:10
6.742,50 9.99 18:10
36,58 9.98 18:10
18,32 9.96 18:10
Artan Hisseler

Azalan

477,00 -10 18:10
7,92 -10 18:10
95,40 -10 18:10
31,90 -9.99 18:10
30,48 -9.98 18:10
Azalan Hisseler

İşlem

15.610.120.553,75 18:10
15.395.772.063,75 18:10
12.839.122.521,65 18:10
11.391.294.342,66 18:10
10.987.845.810,50 18:10
Tüm Hisseler
Sayfa 360/363 İlkİlk ... 260310350358359360361362 ... SonSon
Arama sonucu : 2901 madde; 2,873 - 2,880 arası.

Konu: Tradingview

  1. bolinger kod üzerinde yapılan bir çalışma örneği
    PHP Code:
    //@version=6
    indicator('.'overlay truemax_labels_count 500max_lines_count 500)

    // Inputs - Bollinger Bands settings
    src input.source(close'Source')
    bbLen input.int(20'طول Bollinger Bands'minval 1)
    bbMult input.float(1.5'معامل Bollinger Bands'step 0.25// ✅ كان 1.0 وصار 1.5
    atrLen input.int(14'طول ATR'minval 1)
    minBars input.int(2'عدد الشموع المتتالية خارج الباند'minval 1// ✅ أنظف (تقدر تخليه 3 لو تبي فلترة أكثر)

    // FREE: Higher Timeframe Trend Filter is ALWAYS ON (fixed)
    htfTF 'D'
    htfLen 60

    // Inputs - Display options
    groupDisplay 'Display Options'
    showSignals input.bool(true'Show Buy/Sell Signals'group groupDisplay)
    showLines input.bool(true'Show Entry/SL/TP Lines'group groupDisplay)
    showLabels input.bool(true'Show Price Labels on Lines'group groupDisplay)

    // ✅ أهم تعديل: آخر إشارة فقط (بدون زحمة)
    maxSets 1

    // Inputs - Style settings for lines and labels
    groupStyle 'Style: Lines & Labels'
    lineWidth input.int(1'Line Width'minval 1maxval 4group groupStyle)
    labelSizeOpt input.string('Normal''Label Font Size'options = ['Tiny''Small''Normal''Large''Huge'], group groupStyle)
    labelSize labelSizeOpt == 'Tiny' size.tiny labelSizeOpt == 'Small' size.small labelSizeOpt == 'Large' size.large labelSizeOpt == 'Huge' size.huge size.normal
    entryLblBG 
    input.color(color.new(color.yellow50), 'لون خلفية ENTRY'group groupStyle)
    slLblBG input.color(color.new(color.red50), 'لون خلفية SL'group groupStyle)
    tp1LblBG input.color(color.new(color.teal50), 'لون خلفية TP1'group groupStyle)
    tp2LblBG input.color(color.new(color.purple50), 'لون خلفية TP2'group groupStyle)
    labelTxtC input.color(color.white'لون نص الليبل'group groupStyle)

    // Bollinger Bands calculations
    basis ta.sma(srcbbLen)
    dev ta.stdev(srcbbLen)
    upper basis bbMult dev
    lower 
    basis bbMult dev
    upper2 
    basis bbMult dev
    lower2 
    basis bbMult dev
    atr 
    ta.atr(atrLen)

    // ✅ فلتر الديلي صار ثابت (Daily Close vs Daily EMA200)
    htfClose request.security(syminfo.tickeridhtfTFclose)
    htfEMA request.security(syminfo.tickeridhtfTFta.ema(closehtfLen))
    bullFilter htfClose htfEMA
    bearFilter 
    htfClose htfEMA

    // Track consecutive bars outside bands
    var int barsBelow 0
    var int barsAbove 0
    barsBelow 
    := close lower nz(barsBelow[1]) + 0
    barsAbove 
    := close upper nz(barsAbove[1]) + 0

    // Signal conditions
    longSignal bullFilter and barsBelow[1] >= minBars and close[1] < lower[1] and close lower
    shortSignal 
    bearFilter and barsAbove[1] >= minBars and close[1] > upper[1] and close upper

    // Arrays
    var array<lineentryLines = array.new_line()
    var array<
    lineslLines = array.new_line()
    var array<
    linetp1Lines = array.new_line()
    var array<
    linetp2Lines = array.new_line()
    var array<
    labelentryLabels = array.new_label()
    var array<
    labelslLabels = array.new_label()
    var array<
    labeltp1Labels = array.new_label()
    var array<
    labeltp2Labels = array.new_label()

    // Helper: delete oldest safely
    f_delOldestLine(array<linearr) =>
        if array.
    size(arr) > 0
            line
    .delete(array.shift(arr))

    f_delOldestLabel(array<labelarr) =>
        if array.
    size(arr) > 0
            label
    .delete(array.shift(arr))

    f_drawSet(_entry_sl_tp1_tp2_isLong) =>
        if 
    showLines
            line eLine 
    line.new(bar_index_entrybar_index 1_entryextend extend.rightwidth lineWidthcolor entryLblBG)
            
    line sLine line.new(bar_index_slbar_index 1_slextend extend.rightwidth lineWidthcolor slLblBG)
            
    line t1Line line.new(bar_index_tp1bar_index 1_tp1extend extend.rightwidth lineWidthcolor tp1LblBG)
            
    line t2Line line.new(bar_index_tp2bar_index 1_tp2extend extend.rightwidth lineWidthcolor tp2LblBG)
            array.
    push(entryLineseLine)
            array.
    push(slLinessLine)
            array.
    push(tp1Linest1Line)
            array.
    push(tp2Linest2Line)

        if 
    showLabels
            prefix 
    _isLong 'AL' 'SAT'
            
    entryText prefix ' GİRİS ' str.tostring(_entryformat.mintick)
            
    slText 'STOP ' str.tostring(_slformat.mintick)
            
    tp1Text 'HEDEF1 ' str.tostring(_tp1format.mintick)
            
    tp2Text 'HEDEF2 ' str.tostring(_tp2format.mintick)

            
    label eLbl label.new(bar_index_entryentryTextxloc xloc.bar_indexyloc yloc.pricestyle label.style_label_lefttextalign text.align_leftsize labelSizetextcolor labelTxtCcolor entryLblBG)
            
    label sLbl label.new(bar_index_slslTextxloc xloc.bar_indexyloc yloc.pricestyle label.style_label_lefttextalign text.align_leftsize labelSizetextcolor labelTxtCcolor slLblBG)
            
    label t1Lbl label.new(bar_index_tp1tp1Textxloc xloc.bar_indexyloc yloc.pricestyle label.style_label_lefttextalign text.align_leftsize labelSizetextcolor labelTxtCcolor tp1LblBG)
            
    label t2Lbl label.new(bar_index_tp2tp2Textxloc xloc.bar_indexyloc yloc.pricestyle label.style_label_lefttextalign text.align_leftsize labelSizetextcolor labelTxtCcolor tp2LblBG)

            array.
    push(entryLabelseLbl)
            array.
    push(slLabelssLbl)
            array.
    push(tp1Labelst1Lbl)
            array.
    push(tp2Labelst2Lbl)

        
    // ✅ Trim to last set only
        
    while array.size(entryLines) > maxSets
            f_delOldestLine
    (entryLines)
        while array.
    size(slLines) > maxSets
            f_delOldestLine
    (slLines)
        while array.
    size(tp1Lines) > maxSets
            f_delOldestLine
    (tp1Lines)
        while array.
    size(tp2Lines) > maxSets
            f_delOldestLine
    (tp2Lines)

        while array.
    size(entryLabels) > maxSets
            f_delOldestLabel
    (entryLabels)
        while array.
    size(slLabels) > maxSets
            f_delOldestLabel
    (slLabels)
        while array.
    size(tp1Labels) > maxSets
            f_delOldestLabel
    (tp1Labels)
        while array.
    size(tp2Labels) > maxSets
            f_delOldestLabel
    (tp2Labels)

    // Execute drawing when signals occur
    if longSignal
        f_drawSet
    (closelower2 atrupperupper2true)
    if 
    shortSignal
        f_drawSet
    (closeupper2 atrlowerlower2false)

    // Plot Buy/Sell signal markers
    //plotshape(showSignals and longSignal, title = 'Buy Signal', style = shape.arrowup, location = location.belowbar, color = color.green, text = 'Buy', textcolor = color.white, size = size.small)
    //plotshape(showSignals and shortSignal, title = 'Sell Signal', style = shape.arrowdown, location = location.abovebar, color = color.red, text = 'Sell', textcolor = color.white, size = size.small) 
    örnek https://www.tradingview.com/x/ERo2Jnwm/
    16.07.2024 - 10.12.2024

  2. kama ile bar renklendirme deneme...
    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/
    // © xqweasdzxcv - Modified with KAMA

    //@version=6
    indicator('Candle Coloring Logic V2 'overlay true)

    // ============================================================================
    // KAMA PARAMETERS
    // ============================================================================
    kama1_length input.int(2'KAMA 1 Length'minval 1group 'KAMA Settings')
    kama1_fast input.int(1'KAMA 1 Fast Length'minval 1group 'KAMA Settings')
    kama1_slow input.int(3'KAMA 1 Slow Length'minval 1group 'KAMA Settings')

    kama2_length input.int(3'KAMA 2 Length'minval 1group 'KAMA Settings')
    kama2_fast input.int(2'KAMA 2 Fast Length'minval 1group 'KAMA Settings')
    kama2_slow input.int(4'KAMA 2 Slow Length'minval 1group 'KAMA Settings')

    kama3_length input.int(4'KAMA 3 Length'minval 1group 'KAMA Settings')
    kama3_fast input.int(3'KAMA 3 Fast Length'minval 1group 'KAMA Settings')
    kama3_slow input.int(5'KAMA 3 Slow Length'minval 1group 'KAMA Settings')

    kama4_length input.int(5'KAMA 4 Length'minval 1group 'KAMA Settings')
    kama4_fast input.int(4'KAMA 4 Fast Length'minval 1group 'KAMA Settings')
    kama4_slow input.int(6'KAMA 4 Slow Length'minval 1group 'KAMA Settings')

    kama5_length input.int(6'KAMA 5 Length'minval 1group 'KAMA Settings')
    kama5_fast input.int(7'KAMA 5 Fast Length'minval 1group 'KAMA Settings')
    kama5_slow input.int(8'KAMA 5 Slow Length'minval 1group 'KAMA Settings')

    src874 input.source(close'Source'group 'KAMA Settings')

    // ============================================================================
    // TREND COLORING PARAMETERS
    // ============================================================================
    color color_bearish_price_state input.color(color.rgb(2243251), 'Bearish Trend'group 'Colors')
    color color_bullish_price_state input.color(#f1f6f7, 'Bullish Trend', group = 'Colors')
    color color_bullish_resistance_state input.color(color.rgb(2433352), 'Bullish Resistance'group 'Colors')
    color color_bearish_support_state input.color(color.rgb(226247252), 'Bearish Support'group 'Colors')

    float atr_multiplier_gray input.float(14'ATR Multiplier (Gray Zone)'minval 0.1group 'Ribbon Settings')
    float atr_multiplier_yellow input.float(14'ATR Multiplier (Yellow Zone)'minval 0.1group 'Ribbon Settings')


    // ============================================================================
    // KAMA CALCULATION FUNCTION
    // ============================================================================
    f_kama(float src874int lengthint fastLengthint slowLength) =>
        
    mom math.abs(ta.change(src874length))
        
    volatility math.sum(math.abs(ta.change(src874)), length)
        
    er volatility != mom volatility 0

        fastAlpha 
    / (fastLength 1)
        
    slowAlpha / (slowLength 1)
        
    alpha math.pow(er * (fastAlpha slowAlpha) + slowAlpha2)

        var 
    float kama na
        kama 
    := alpha src874 + (alpha) * nz(kama[1], src874)
        
    kama

    // ============================================================================
    // CALCULATE ALL KAMAS
    // ============================================================================
    float kama1 f_kama(src874kama1_lengthkama1_fastkama1_slow)
    float kama2 f_kama(src874kama2_lengthkama2_fastkama2_slow)
    float kama3 f_kama(src874kama3_lengthkama3_fastkama3_slow)
    float kama4 f_kama(src874kama4_lengthkama4_fastkama4_slow)
    float kama5 f_kama(src874kama5_lengthkama5_fastkama5_slow)

    // ============================================================================
    // KAMA STACK RIBBON LOGIC (Replaces SMA Stack)
    // ============================================================================
    bool is_bullish_stack kama1 kama2 and kama2 kama3 and kama3 kama4 and kama4 kama5
    bool is_bearish_stack 
    kama1 kama2 and kama2 kama3 and kama3 kama4 and kama4 kama5

    float atr_gray 
    ta.atr(14) * atr_multiplier_gray
    float atr_yellow 
    ta.atr(14) * atr_multiplier_yellow
    float kama_spread 
    math.abs(kama1 kama5)

    bool is_narrowing_gray not is_bullish_stack and not is_bearish_stack and kama_spread atr_gray
    bool is_narrowing_yellow 
    not is_bullish_stack and not is_bearish_stack and kama_spread atr_yellow

    var bool was_bullish_stack false
    var bool was_bearish_stack false

    was_bullish_stack 
    := is_bullish_stack true is_bearish_stack false was_bullish_stack
    was_bearish_stack 
    := is_bearish_stack true is_bullish_stack false was_bearish_stack

    // ============================================================================
    color kama_ribbon_color is_bearish_stack color_bearish_price_state is_narrowing_yellow and not was_bullish_stack color_bearish_support_state is_narrowing_gray and was_bullish_stack color_bullish_resistance_state is_bullish_stack color_bullish_price_state na


    // ============================================================================
    plotcandle(openhighlowclosecolor kama_ribbon_colorwickcolor kama_ribbon_colorbordercolor kama_ribbon_colortitle 'MUM'
    örnek https://www.tradingview.com/x/I3FovGbp/
    16.07.2024 - 10.12.2024

  3. açılış-kapanış, yüksek-düşük bar ölçüm denemesi... ve lo etiketleme....(anı olarak )
    PHP Code:
    //@version=6
    indicator('Lo lo Taraması'overlay truemax_labels_count 500)

    // Only act after candle closes
    isClosed barstate.isconfirmed

    // Your raw retracement rules
    bullRaw isClosed and close[1] < open[1] and close open and close low[1]
    bearRaw isClosed and close[1] > open[1] and close open and close high[1]

    // Small wick-based spacing
    spaceUp = (high close) * 0.35
    spaceDown 
    = (open low) * 0.35

    // Colors
    brightRed color.rgb(25500)
    brightGreen color.rgb(02550)

    // Wave locks
    var bool bullWaveLocked false
    var bool bearWaveLocked false

    // Reset locks when opposite candle prints
    if isClosed and close open
        bullWaveLocked 
    := false
        bullWaveLocked

    if isClosed and close open
        bearWaveLocked 
    := false
        bearWaveLocked

    // BEARISH WAVE (Red)
    if bullRaw and not bullWaveLocked
        label
    .new(bar_index 1high[1] + (high[1] - close[1]) * 0.35'L'style label.style_nonetextcolor brightRedsize size.large)

        
    label.new(bar_indexhigh spaceUp'o'style label.style_nonetextcolor brightRedsize size.large)

        
    bullWaveLocked := true
        bullWaveLocked

    // BULLISH WAVE (Green)
    if bearRaw and not bearWaveLocked
        label
    .new(bar_index 1low[1] - (open[1] - low[1]) * 0.35'L'style label.style_nonetextcolor brightGreensize size.large)

        
    label.new(bar_indexlow spaceDown'o'style label.style_nonetextcolor brightGreensize size.large)

        
    bearWaveLocked := true
        bearWaveLocked 
    örnek https://www.tradingview.com/x/8fOhL7Xh/
    16.07.2024 - 10.12.2024

  4.  Alıntı Originally Posted by @yörük@ Yazıyı Oku
    https://tr.tradingview.com/script/kLsYz4jj/ bundaki çizgiler etiketler olmasın. rsi macd gibi kullanılan filtreler olmasın.
    sadece fibo kalsın. long-short kısmını da... Türkçe leştirelim....



    https://tr.tradingview.com/script/Lr...nd-ChartPrime/ bunda ise seviye cizgi etiketi kaldıralım...sadece trend çizgisi
    bırakalım.....

    bu ikisini birleştirip... sade tasarım yapalım. (yapılacak)
    fibo trading...kod birleştirmeli... bar renklendirme-trend-lo etiketli...robotumsu.... deneme örneği....

    PHP Code:
    //@version=6
    indicator('...'overlay truemax_lines_count 500max_labels_count 500)
    ma_tt '=== Moving Average Cycle ==='
    _source close
    _p 
    input(100title 'Period'inline 'set1'group ma_tt)
    //macycle_note_1 = input(false, '1. MA Cycle above 0, background is filled by blue', group = ma_tt)
    //macycle_note_2 = input(false, '2. MA Cycle below 0, background is filled by red', group = ma_tt)
    //_fill = input.bool(true, title = 'Fill background', group = ma_tt)
    _c ta.ema(close_p) - ta.sma(close_p)
    //
    //rsi_tt = '=== RSI ==='
    //rsi_len = input.int(14, title = 'Period', inline = 'set', group = rsi_tt)
    //rsi_ovb_lv = input.int(70, title = 'Overbought', inline = 'set2', group = rsi_tt)
    //rsi_ovs_lv = input.int(30, title = 'Oversold', inline = 'set2', group = rsi_tt)
    //rsi_note_1 = input(false, '1. RSI Overbought show as Hot Face', group = rsi_tt)
    //rsi_note_2 = input(false, '2. RSI Oversold show as Cold Face', group = rsi_tt)
    //_rsi_show = input(true, title = 'Show RSI', inline = 'set3', group = rsi_tt)
    //_rsi = ta.rsi(close, rsi_len)
    //_rsi_ovb = _rsi[0] > rsi_ovb_lv[0]
    //_rsi_ovs = _rsi[0] < rsi_ovs_lv[0]
    //plotshape(_rsi_show and _rsi_ovb ? _rsi : na, title = 'RSI Overbought', style = shape.labeldown, location = location.bottom, color = color.new(color.aqua, 100), offset = 0, text = '��', textcolor = color.new(color.black, 0))
    //plotshape(_rsi_show and _rsi_ovs ? _rsi : na, title = 'RSI Oversold', style = shape.labeldown, location = location.bottom, color = color.new(color.aqua, 100), offset = 0, text = '��', textcolor = color.new(color.black, 0))
    //_rsi_ovb_log = _rsi_ovb[1] == false and _rsi_ovb == true
    //_rsi_ovs_log = _rsi_ovs[1] == false and _rsi_ovs == true
    //_rsi_ovb_index = bar_index > 0 ? bar_index - ta.valuewhen(_rsi_ovb_log, bar_index, 0) : 1
    //_rsi_ovs_index = bar_index > 0 ? bar_index - ta.valuewhen(_rsi_ovs_log, bar_index, 0) : 1
    //MACD
    //macd_tt = '=== MACD ==='
    //macd_source = close
    //macd_fast = input.int(12, title = 'Fast', inline = 'set1', group = macd_tt)
    //macd_slow = input.int(26, title = 'Slow', inline = 'set1', group = macd_tt)
    //macd_sig = input.int(9, title = 'Signal', inline = 'set1', group = macd_tt)
    //macd_note_1 = input(false, '1. MACD show as circle', group = macd_tt)
    //macd_note_2 = input(false, '2. MACD Buy Signal show as Arrow Up', group = macd_tt)
    //macd_note_3 = input(false, '3. MACD Sell Signal show as Arrow Down', group = macd_tt)
    //_macd_show = input(true, title = 'Show MACD', inline = 'set2', group = macd_tt)
    //[_macd, _signal, _hist] = ta.macd(macd_source, macd_fast, macd_slow, macd_sig)
    //_macd_buy_signal = _macd[1] < _signal[1] and _macd[0] > _signal[0]
    //_macd_sell_signal = _macd[1] > _signal[1] and _macd[0] < _signal[0]
    //plotshape(_macd_show and _macd_buy_signal == false and _macd_sell_signal == false ? _macd : na, title = 'MACD', style = shape.circle, location = location.bottom, color = _macd > _signal ? color.new(color.lime, 0) : color.new(color.red, 0), offset = 0)
    //plotshape(_macd_show and _macd_buy_signal ? _macd : na, title = 'MACD Buy Signal', style = shape.arrowup, location = location.bottom, color = color.new(color.lime, 0), offset = 0)
    //plotshape(_macd_show and _macd_sell_signal ? _macd : na, title = 'MACD Sell Signal', style = shape.arrowdown, location = location.bottom, color = color.new(color.red, 0), offset = 0)
    //
    //var _rsi_val = 0
    _m 0
    //if _rsi_ovb_index < _rsi_ovs_index
        //_rsi_val := -1
        //_rsi_val
    //else
        //if _rsi_ovb_index > _rsi_ovs_index
            //_rsi_val := 1
            //_rsi_val
        //else
            //_rsi_val := _rsi_val[1]
            //_rsi_val
    //if _rsi_val == -1 and _macd_sell_signal == true
        //_m := -1
        //_m
    //else
        //if _rsi_val == 1 and _macd_buy_signal == true
            //_m := 1
            //_m
        //else
            //_m := _m[1]
            //_m
            //
    //rsi_macd = 'RSI MACD Background Filling'
    //rsi_macd_note_1 = input(false, '1. MACD Buy Signal after RSI Oversold, background is filled by blue', group = rsi_macd)
    //rsi_macd_note_2 = input(false, '2. MACD Sell Signal after RSI Overbought, background is filled by red', group = rsi_macd)
    //_fill_rsi_macd = input.bool(false, title = 'Fill background', group = rsi_macd)
    //Gaussian Filter script by Alex Orekhov (everget)
    //gf_tt = '=== Gaussian Filter ==='
    //cyclePeriod = input.int(title = 'Period', minval = 1, defval = 100, inline = 'set', group = gf_tt)
    //src = input(title = 'Source', defval = close, inline = 'set', group = gf_tt)
    //gf_note_1 = input(false, '1. Price moving above Gaussian Filter, background is filled by blue', group = gf_tt)
    //gf_note_2 = input(false, '2. Price moving below Gaussian Filter, background is filled by red', group = gf_tt)
    //_fill_gf = input.bool(false, title = 'Fill background', group = gf_tt)
    //Calculate GF with Number of Poles = 4
    //PI = 2 * math.asin(1)
    //beta = (1 - math.cos(2 * PI / cyclePeriod)) / (math.pow(2, 1 / 4.0) - 1)
    //alpha = -beta + math.sqrt(math.pow(beta, 2) + 2 * beta)
    //getGF() =>
        //filter = 0.0
        //filter := math.pow(alpha, 4) * src + 4 * (1 - alpha) * nz(filter[1]) - 6 * math.pow(1 - alpha, 2) * nz(filter[2]) + 4 * math.pow(1 - alpha, 3) * nz(filter[3]) - math.pow(1 - alpha, 4) * nz(filter[4])
        //filter
    //gf = getGF()
    //_g = close > gf ? 1 : -1
    //
    sr_group '=== Support Resistance ==='
    Left input.int(4title '.'minval 1group sr_group)
    Right input.int(4title '.'minval 0group sr_group)
    trading_group '=== Trading Setup ==='
    trading_setup input.string('Both'title 'Setup'options = ['Long Only''Short Only''Both''MA Cycle''RSI_MACD''Gaussian_Filter'], group trading_group)

    var 
    Long false
    Short 
    false
    if trading_setup == 'Long Only'
        
    Long := true
        Short 
    := false
        Short
    else if trading_setup == 'Short Only'
        
    Long := false
        Short 
    := true
        Short
    else if trading_setup == 'MA Cycle'
        
    if _c 0
            Long 
    := true
            Short 
    := false
            Short
        
    else
            
    Long := false
            Short 
    := true
            Short
    //else if trading_setup == 'RSI_MACD'
        //if _m > 0
            //Long := true
            //Short := false
            //Short
        //else
            //Long := false
            //Short := true
            //Short
    //else if trading_setup == 'Gaussian_Filter'
        //if _g > 0
            //Long := true
            //Short := false
            //Short
        //else
            //Long := false
            //Short := true
            //Short
    else
        
    Long := true
        Short 
    := true
        Short
        
    //Background Filling
    //bgcolor(color = _fill and trading_setup == 'MA Cycle' ? _c > 0 ? color.new(color.blue, 80) : color.new(color.red, 80) : na, offset = 0)
    //bgcolor(color = _fill_rsi_macd and trading_setup == 'RSI_MACD' ? _m > 0 ? color.new(color.blue, 80) : color.new(color.red, 80) : na, offset = 0)
    //bgcolor(color = _fill_gf and trading_setup == 'Gaussian_Filter' ? _g > 0 ? color.new(color.blue, 80) : color.new(color.red, 80) : na, offset = 0)


    isFractal(x) =>
        
    ta.highestbars(xLeft Right 1) == -Right
    sF 
    isFractal(-low)
    support low
    support 
    := sF low[Right] : support[1]
    rF isFractal(high)
    resistance high
    resistance 
    := rF high[Right] : resistance[1]
    //plot(support, title="Support", color=sF ? #00000000 : color.blue, linewidth=2, offset=-Right)
    //plot(resistance, title="Resistance", color=rF ? #00000000 : color.red, linewidth=2, offset=-Right)
    //plotshape(sF ? low[Right] : na, title = 'Fractal Low', style = shape.circle, location = location.absolute, color = color.blue, offset = -Right, size = size.tiny)
    //plotshape(rF ? high[Right] : na, title = 'Fractal High', style = shape.circle, location = location.absolute, color = color.red, offset = -Right, size = size.tiny)

    //drawLabel(_offset, _pivot, _text, _style, _color, _textColor) =>
        //if not na(_pivot)
            //label.new(bar_index[_offset], _pivot, _text, style = _style, color = _color, textcolor = _textColor)
            //label.new(bar_index[_offset], _pivot, _text+str.tostring(_pivot, format.mintick), style=_style, color=_color, textcolor=_textColor)

    //drawLine(x1, y1, x2, y2, ext, clr, sty, wid) =>
        //if not na(x1)
            //line.new(x1, y1, x2, y2, xloc = xloc.bar_index, extend = ext, color = clr, style = sty, width = wid)

    //Value & Index
    ph rF
    ph_val 
    ta.valuewhen(phresistance0)
    res ph_val
    ph_index 
    ta.valuewhen(phbar_index Right0)

    pl sF
    pl_val 
    ta.valuewhen(plsupport0)
    sup pl_val
    pl_index 
    ta.valuewhen(plbar_index Right0)
    //Long setup
    var long_sup_index 0
    long_sup_val 
    0.0
    long_res_val 
    0.0
    if pl_index ph_index
        long_sup_index 
    := pl_index
        long_sup_val 
    := pl_val
        long_res_val 
    := ph_val
        long_res_val
    else
        
    long_sup_index := long_sup_index[1]
        
    long_sup_val := long_sup_val[1]
        
    long_sup_val
    if long_sup_index == long_sup_index[1]
        
    long_res_val := long_res_val[1]
        
    long_res_val
        
    //Long Condition
    long_cond close long_sup_val and Long
    //Resistance Line
    long_res_x1 long_sup_index
    long_res_y1 
    long_cond long_res_val na
    long_res_x2 
    bar_index
    long_res_y2 
    long_res_y1
    long_res_ext 
    extend.right
    long_res_clr 
    color.new(color.red0)
    long_res_textColor color.new(color.white0)
    long_res_sty line.style_dotted
    long_res_width 
    2
    //long_res_line = drawLine(long_res_x1, long_res_y1, long_res_x2, long_res_y2, long_res_ext, long_res_clr, long_res_sty, long_res_width)
    //line.delete(long_res_line[1])
    //Label
    //long_ph_lab = drawLabel(0, long_cond ? long_res_y1 : na, 'Break Even', label.style_label_left, color.red, color.white)
    //label.delete(long_ph_lab[1])
    //Value
    plot(long_cond long_res_y1 natitle 'Long Arttır'color color.new(color.red100))

    //Support Line
    long_sup_x1 long_sup_index
    long_sup_y1 
    Long long_sup_val na
    long_sup_x2 
    bar_index
    long_sup_y2 
    long_sup_y1
    long_sup_ext 
    extend.right
    long_sup_clr 
    color.new(color.blue0)
    long_sup_textColor color.new(color.white0)
    long_sup_sty line.style_dotted
    long_sup_width 
    2
    //long_sup_line = drawLine(long_sup_x1, long_sup_y1, long_sup_x2, long_sup_y2, long_sup_ext, long_sup_clr, long_sup_sty, long_sup_width)
    //line.delete(long_sup_line[1])
    //Label
    //long_pl_lab = drawLabel(0, Long ? long_sup_val : na, 'Long Invalidation', label.style_label_left, color.blue, color.white)
    //label.delete(long_pl_lab[1])
    //Value
    plot(Long long_sup_val natitle 'Long DüşünME'color color.new(color.blue100))
    //Fib50 Line
    long_fib50_x1 long_sup_index
    long_fib50_y1 
    long_cond ? (long_res_y1 long_sup_y1) * 0.5 na
    long_fib50_x2 
    bar_index
    long_fib50_y2 
    long_fib50_y1
    long_fib50_ext 
    extend.right
    long_fib50_clr 
    color.new(color.blue0)
    long_fib50_textColor color.new(color.white0)
    long_fib50_sty line.style_dotted
    long_fib50_width 
    2
    //long_fib50_line = drawLine(long_fib50_x1, long_fib50_y1, long_fib50_x2, long_fib50_y2, long_fib50_ext, long_fib50_clr, long_fib50_sty, long_fib50_width)
    //line.delete(long_fib50_line[1])
    //Label
    //long_fib50_lab = drawLabel(0, long_cond ? long_fib50_y1 : na, 'Level 50', label.style_label_left, color.blue, color.white)
    //label.delete(long_fib50_lab[1])
    //Value
    plot(long_cond long_fib50_y1 natitle 'Long Başla'color color.new(color.blue100))
    //Fib618 Line
    long_fib618_x1 long_sup_index
    long_fib618_y1 
    long_cond long_res_y1 - (long_res_y1 long_sup_y1) * 0.618 na
    long_fib618_x2 
    bar_index
    long_fib618_y2 
    long_fib618_y1
    long_fib618_ext 
    extend.right
    long_fib618_clr 
    color.new(color.blue0)
    long_fib618_textColor color.new(color.white0)
    long_fib618_sty line.style_dotted
    long_fib618_width 
    2
    //long_fib618_line = drawLine(long_fib618_x1, long_fib618_y1, long_fib618_x2, long_fib618_y2, long_fib618_ext, long_fib618_clr, long_fib618_sty, long_fib618_width)
    //line.delete(long_fib618_line[1])
    //Label
    //long_fib618_lab = drawLabel(0, long_cond ? long_fib618_y1 : na, 'Level 61.8', label.style_label_left, color.blue, color.white)
    //label.delete(long_fib618_lab[1])
    //Value
    //plot(long_cond ? long_fib618_y1 : na, title = '61.8', color = color.new(color.blue, 100))
    //tp1
    long_tp1_x1 long_sup_index
    long_tp1_y1 
    long_cond long_res_y1 + (long_res_y1 long_sup_y1) * 0.382 na
    long_tp1_x2 
    bar_index
    long_tp1_y2 
    long_tp1_y1
    long_tp1_ext 
    extend.right
    long_tp1_clr 
    color.new(color.blue0)
    long_tp1_textColor color.new(color.white0)
    long_tp1_sty line.style_dotted
    long_tp1_width 
    2
    //long_tp1_line = drawLine(long_tp1_x1, long_tp1_y1, long_tp1_x2, long_tp1_y2, long_tp1_ext, long_tp1_clr, long_tp1_sty, long_tp1_width)
    //line.delete(long_tp1_line[1])
    //Label
    //long_tp1_lab = drawLabel(0, long_cond ? long_tp1_y1 : na, 'Tp1', label.style_label_left, color.blue, color.white)
    //label.delete(long_tp1_lab[1])
    //Value
    plot(long_cond long_tp1_y1 natitle 'Long Kapat'color color.new(color.blue100))
    //tp2
    long_tp2_x1 long_sup_index
    long_tp2_y1 
    long_cond long_res_y1 long_res_y1 long_sup_y1 na
    long_tp2_x2 
    bar_index
    long_tp2_y2 
    long_tp2_y1
    long_tp2_ext 
    extend.right
    long_tp2_clr 
    color.new(color.blue0)
    long_tp2_textColor color.new(color.white0)
    long_tp2_sty line.style_dotted
    long_tp2_width 
    2
    //long_tp2_line = drawLine(long_tp2_x1, long_tp2_y1, long_tp2_x2, long_tp2_y2, long_tp2_ext, long_tp2_clr, long_tp2_sty, long_tp2_width)
    //line.delete(long_tp2_line[1])
    //Label
    //long_tp2_lab = drawLabel(0, long_cond ? long_tp2_y1 : na, 'Tp2', label.style_label_left, color.blue, color.white)
    //label.delete(long_tp2_lab[1])
    //Value
    plot(long_cond long_tp2_y1 natitle 'Long Kesin Kapat'color color.new(color.blue100))
    //Buy Zone
    //if long_cond
        //linefill.new(long_fib50_line, long_sup_line, color.new(color.blue, 90))

    //Short setup
    var short_res_index 0
    short_res_val 
    0.0
    short_sup_val 
    0.0
    if pl_index ph_index
        short_res_index 
    := ph_index
        short_res_val 
    := ph_val
        short_sup_val 
    := pl_val
        short_sup_val
    else
        
    short_res_index := short_res_index[1]
        
    short_res_val := short_res_val[1]
        
    short_res_val
    if short_res_index == short_res_index[1]
        
    short_sup_val := short_sup_val[1]
        
    short_sup_val
        
    //Short Condition
    short_cond close short_res_val and Short
    //Resistance Line
    short_res_x1 short_res_index
    short_res_y1 
    Short short_res_val na
    short_res_x2 
    bar_index
    short_res_y2 
    short_res_y1
    short_res_ext 
    extend.right
    short_res_clr 
    color.new(color.red0)
    short_res_textColor color.new(color.white0)
    short_res_sty line.style_dotted
    short_res_width 
    2
    //short_res_line = drawLine(short_res_x1, short_res_y1, short_res_x2, short_res_y2, short_res_ext, short_res_clr, short_res_sty, short_res_width)
    //line.delete(short_res_line[1])
    //Label
    //short_ph_lab = drawLabel(0, Short ? short_res_val : na, 'Short Invalidation', label.style_label_left, color.red, color.white)
    //label.delete(short_ph_lab[1])
    //Value
    plot(Short short_res_val natitle 'Short DüşünME'color color.new(color.red100))

    //Support Line
    short_sup_x1 short_res_index
    short_sup_y1 
    short_cond short_sup_val na
    short_sup_x2 
    bar_index
    short_sup_y2 
    short_sup_y1
    short_sup_ext 
    extend.right
    short_sup_clr 
    color.new(color.blue0)
    short_sup_textColor color.new(color.white0)
    short_sup_sty line.style_dotted
    short_sup_width 
    2
    //short_sup_line = drawLine(short_sup_x1, short_sup_y1, short_sup_x2, short_sup_y2, short_sup_ext, short_sup_clr, short_sup_sty, short_sup_width)
    //line.delete(short_sup_line[1])
    //Label
    //short_pl_lab = drawLabel(0, short_cond ? short_sup_y1 : na, 'Break Even', label.style_label_left, color.blue, color.white)
    //label.delete(short_pl_lab[1])
    //Value
    plot(short_cond short_sup_y1 natitle 'Short Arttır'color color.new(color.blue100))
    //Fib50 Line
    short_fib50_x1 short_res_index
    short_fib50_y1 
    short_cond ? (short_res_y1 short_sup_y1) * 0.5 na
    short_fib50_x2 
    bar_index
    short_fib50_y2 
    short_fib50_y1
    short_fib50_ext 
    extend.right
    short_fib50_clr 
    color.new(color.red0)
    short_fib50_textColor color.new(color.white0)
    short_fib50_sty line.style_dotted
    short_fib50_width 
    2
    //short_fib50_line = drawLine(short_fib50_x1, short_fib50_y1, short_fib50_x2, short_fib50_y2, short_fib50_ext, short_fib50_clr, short_fib50_sty, short_fib50_width)
    //line.delete(short_fib50_line[1])
    //Label
    //short_fib50_lab = drawLabel(0, short_cond ? short_fib50_y1 : na, 'Level 50', label.style_label_left, color.red, color.white)
    //label.delete(short_fib50_lab[1])
    //Value
    plot(short_cond short_fib50_y1 natitle 'Short Başla'color color.new(color.red100))
    //Fib618 Line
    short_fib618_x1 short_res_index
    short_fib618_y1 
    short_cond short_sup_y1 + (short_res_y1 short_sup_y1) * 0.618 na
    short_fib618_x2 
    bar_index
    short_fib618_y2 
    short_fib618_y1
    short_fib618_ext 
    extend.right
    short_fib618_clr 
    color.new(color.red0)
    short_fib618_textColor color.new(color.white0)
    short_fib618_sty line.style_dotted
    short_fib618_width 
    2
    //short_fib618_line = drawLine(short_fib618_x1, short_fib618_y1, short_fib618_x2, short_fib618_y2, short_fib618_ext, short_fib618_clr, short_fib618_sty, short_fib618_width)
    //line.delete(short_fib618_line[1])
    //Label
    //short_fib618_lab = drawLabel(0, short_cond ? short_fib618_y1 : na, 'Level 61.8', label.style_label_left, color.red, color.white)
    //label.delete(short_fib618_lab[1])
    //Value
    //plot(short_cond ? short_fib618_y1 : na, title = '61.8', color = color.new(color.red, 100))
    //tp1
    short_tp1_x1 short_res_index
    short_tp1_y1 
    short_cond short_sup_y1 - (short_res_y1 short_sup_y1) * 0.382 na
    short_tp1_x2 
    bar_index
    short_tp1_y2 
    short_tp1_y1
    short_tp1_ext 
    extend.right
    short_tp1_clr 
    color.new(color.red0)
    short_tp1_textColor color.new(color.white0)
    short_tp1_sty line.style_dotted
    short_tp1_width 
    2
    //short_tp1_line = drawLine(short_tp1_x1, short_tp1_y1, short_tp1_x2, short_tp1_y2, short_tp1_ext, short_tp1_clr, short_tp1_sty, short_tp1_width)
    //line.delete(short_tp1_line[1])
    //Label
    //short_tp1_lab = drawLabel(0, short_cond ? short_tp1_y1 : na, 'Tp1', label.style_label_left, color.red, color.white)
    //label.delete(short_tp1_lab[1])
    //Value
    plot(short_cond short_tp1_y1 natitle 'Short Kapat'color color.new(color.red100))
    //tp2
    short_tp2_x1 short_res_index
    short_tp2_y1 
    short_cond short_sup_y1 - (short_res_y1 short_sup_y1) : na
    short_tp2_x2 
    bar_index
    short_tp2_y2 
    short_tp2_y1
    short_tp2_ext 
    extend.right
    short_tp2_clr 
    color.new(color.red0)
    short_tp2_textColor color.new(color.white0)
    short_tp2_sty line.style_dotted
    short_tp2_width 
    2
    //short_tp2_line = drawLine(short_tp2_x1, short_tp2_y1, short_tp2_x2, short_tp2_y2, short_tp2_ext, short_tp2_clr, short_tp2_sty, short_tp2_width)
    //line.delete(short_tp2_line[1])
    //Label
    //short_tp2_lab = drawLabel(0, short_cond ? short_tp2_y1 : na, 'Tp2', label.style_label_left, color.red, color.white)
    //label.delete(short_tp2_lab[1])
    //Value
    plot(short_cond short_tp2_y1 natitle 'Short Kesin Kapat'color color.new(color.red100))
    //Sell Zone
    //if short_cond
        //linefill.new(short_fib50_line, short_res_line, color.new(color.red, 90))
        //Alert
    //long_buy_zone = close < long_fib50_y1 and long_cond
    //short_sell_zone = close > short_fib50_y1 and short_cond
    //alertcondition(long_buy_zone or short_sell_zone, title = 'Alert active', message = 'Inside the zone')
    //EOF
    /// --------------------------------------------------------------------------------------------------------------------}
    // �������� ������������
    // --------------------------------------------------------------------------------------------------------------------{

    bool  trend_on input.bool(true""inline "trend"group "Trend")
    float trend_   input.float(4"Trend"step 0.01inline "trend"group "Trend")
    color col1     input.color(#26905d, "", inline = "trend", group = "Trend")
    color col2     input.color(#74286d, "",inline = "trend", group = "Trend")

    int   extend   input.int(15"Extend"group "Fibonacci"inline "1"), fill_col input.color(#2689901c, "", group = "Fibonacci", inline = "1")

    float v_236 input.float(0.236"1")*100
    float v_382 
    input.float(0.382"2")*100
    float v_618 
    input.float(0.618"3")*100
    float v_786 
    input.float(0.786"4")*100

    // UDT
    type data 
        line fib05  
    na    
        line fib0   
    na
        line fib236 
    na
        line fib382 
    na
        line fib618 
    na
        line fib786 
    na
        line fib_   
    na
        line fib_di   
    na

        label H 
    na
        label L 
    na

        label L0   
    na
        label L236 
    na
        label L382 
    na
        label L618 
    na
        label L786 
    na
        label L_   
    na


    var fib_d =  data.new()




    // --------------------------------------------------------------------------------------------------------------------}
    // ������������������ ������������������������
    // --------------------------------------------------------------------------------------------------------------------{

    [supertrenddirection] = ta.supertrend(trend_25)

    draw_fibb(trend)=>

        var 
    float(na)
        var 
    float(na)
        var 
    hi int(na)
        var 
    li int(na)

        var 
    val_0 float(na)
        var 
    val_ float(na)

        
    atr ta.atr(200)
        
    // delete previous fibb 
        
    if trend != trend[1]
            
    line.delete(fib_d.fib_)
            
    line.delete(fib_d.fib0)
            
    line.delete(fib_d.fib05)
            
    line.delete(fib_d.fib_di)
            
    line.delete(fib_d.fib236)
            
    line.delete(fib_d.fib382)
            
    line.delete(fib_d.fib618)
            
    line.delete(fib_d.fib786)
            
    label.delete(fib_d.H)
            
    label.delete(fib_d.L)
            
    label.delete(fib_d.L0)
            
    label.delete(fib_d.L_)        
            
    label.delete(fib_d.L236)
            
    label.delete(fib_d.L382)
            
    label.delete(fib_d.L618)
            
    label.delete(fib_d.L786)


        
    // Creat Fib Lines at the bottom and the top
        
    if trend != trend[1] and trend == -1
        
            fib_d
    .fib_ := line.new(bar_indexlowbar_indexlowcolor chart.fg_colorwidth 2)
            
    fib_d.fib0 := line.new(bar_indexhigh+atr*3bar_indexhigh+atr*3color chart.fg_colorwidth 2)


        if 
    trend != trend[1] and trend == 1
        
            fib_d
    .fib_ := line.new(bar_indexhighbar_indexhighcolor chart.fg_colorwidth 2)
            
    fib_d.fib0 := line.new(bar_indexlow-atr*3bar_indexlow-atr*3color chart.fg_colorwidth 2)

            
    fib_d.fib_di := line.new(lilhihstyle line.style_dashedcolor chart.fg_color)
            

        
    // Extend fibb lines during a trend
        
    if trend == trend[1]
            
    // Update High and low of Fibb
            
            
    if low fib_d.fib_.get_y1()
                
    fib_d.fib_.set_y1(low)
                
    fib_d.fib_.set_y2(low)


            if 
    high fib_d.fib0.get_y1()
                
    fib_d.fib0.set_y1(high)
                
    fib_d.fib0.set_y2(high)


            
    // High and low labels
            //if high == fib_d.fib0.get_y1()
                //h := high
                //hi := bar_index
                //label.delete((fib_d[1]).H)
                //fib_d.H := label.new(hi, h, str.tostring(h, "#,###.####"), color = #15373b)
       
            //if low == fib_d.fib_.get_y1()
                //l := low
                //li := bar_index
                //label.delete((fib_d[1]).L)
                //fib_d.L := label.new(li, l, str.tostring(l, "#,###.####"), style = label.style_label_up, color = #15373b)
       


            //fib_d.fib_.set_x2(bar_index+extend)
            //fib_d.fib0.set_x2(bar_index+extend)

            //line.delete((fib_d[1]).fib_di)
            //fib_d.fib_di := line.new(li, l, hi, h, style = line.style_dashed, color = chart.fg_color)

            //if fib_d.fib_di.get_x1() < fib_d.fib0.get_x1() or fib_d.fib_di.get_x2() < fib_d.fib0.get_x1()
                //line.delete(fib_d.fib_di)

            //size_step = (fib_d.fib0.get_y1() - fib_d.fib_.get_y1()) / 100

            //line.delete((fib_d[1]).fib05)
            //line.delete((fib_d[1]).fib382)
            //line.delete((fib_d[1]).fib236)
            //line.delete((fib_d[1]).fib618)
            //line.delete((fib_d[1]).fib786)

            
    if trend == -1

                val_0   
    := fib_d.fib0.get_y1()
                
    val_    := fib_d.fib_.get_y1()

            if 
    trend == 

                val_0   
    := fib_d.fib_.get_y1()
                
    val_    := fib_d.fib0.get_y1()

            
    //fib_d.fib236 := line.new(fib_d.fib0.get_x1(), val_0 - size_step * v_236 * trend*-1, fib_d.fib0.get_x2(), val_0 - size_step * v_236 * trend*-1, color = chart.fg_color)
            //fib_d.fib382 := line.new(fib_d.fib0.get_x1(), val_0 - size_step * v_382 * trend*-1, fib_d.fib0.get_x2(), val_0 - size_step * v_382 * trend*-1, color = chart.fg_color)

            //fib_d.fib05  := line.new(fib_d.fib0.get_x1(), val_0 - size_step * 50 * trend*-1, fib_d.fib0.get_x2(), val_0 - size_step * 50 * trend*-1, color = color.new(chart.fg_color, 50), style = line.style_dotted)

            //fib_d.fib618 := line.new(fib_d.fib0.get_x1(), val_0 - size_step * v_618 * trend*-1, fib_d.fib0.get_x2(), val_0 - size_step * v_618 * trend*-1, color = chart.fg_color)
            //fib_d.fib786 := line.new(fib_d.fib0.get_x1(), val_0 - size_step * v_786 * trend*-1, fib_d.fib0.get_x2(), val_0 - size_step * v_786 * trend*-1, color = chart.fg_color)

            //label.delete((fib_d[1]).L0)
            //label.delete((fib_d[1]).L_)                
            //label.delete((fib_d[1]).L236)
            //label.delete((fib_d[1]).L382)
            //label.delete((fib_d[1]).L618)
            //label.delete((fib_d[1]).L786)

            //fib_d.L0 := label.new(bar_index+extend, val_0,  text = "0 " + str.tostring(val_0, "(#,###.####)"), textcolor = chart.fg_color, color = chart.bg_color, style = label.style_label_left)
            //fib_d.L_ := label.new(bar_index+extend, val_,   text = "1 " + str.tostring(val_, "(#,###.####)"), textcolor = chart.fg_color, color = chart.bg_color, style = label.style_label_left)      

            //fib_d.L236 := label.new(bar_index+extend, fib_d.fib236.get_y1(), text = str.tostring(v_236/100) + str.tostring(fib_d.fib236.get_y1(), " (#,###.####)"), textcolor = chart.fg_color, color = chart.bg_color, style = label.style_label_left)
            //fib_d.L382 := label.new(bar_index+extend, fib_d.fib382.get_y1(), text = str.tostring(v_382/100) + str.tostring(fib_d.fib382.get_y1(), " (#,###.####)"), textcolor = chart.fg_color, color = chart.bg_color, style = label.style_label_left)
            //fib_d.L618 := label.new(bar_index+extend, fib_d.fib618.get_y1(), text = str.tostring(v_618/100) + str.tostring(fib_d.fib618.get_y1(), " (#,###.####)"), textcolor = chart.fg_color, color = chart.bg_color, style = label.style_label_left)
            //fib_d.L786 := label.new(bar_index+extend, fib_d.fib786.get_y1(), text = str.tostring(v_786/100) + str.tostring(fib_d.fib786.get_y1(), " (#,###.####)"), textcolor = chart.fg_color, color = chart.bg_color, style = label.style_label_left)

            //linefill.new(fib_d.fib618, fib_d.fib786, fill_col)
            //linefill.new(fib_d.fib05, fib_d.fib786, fill_col)


    // --------------------------------------------------------------------------------------------------------------------}
    // ��������������������������
    // --------------------------------------------------------------------------------------------------------------------{

    draw_fibb(direction)

    color trend_on ? (direction == col2 col1) : na
    p1 
    plot(supertrend"Trend"color direction != direction[1] ? na colorstyle plot.style_linebr)
    //p2 = plot(hl2, display = display.none)

    //fill(p1, p2, hl2, supertrend, na, direction != direction[1] ? na : color.new(color, 90))
    // --------------------------------------------------------------------------------------------------------------------}


    // ============================================================================
    // KAMA PARAMETERS
    // ============================================================================
    kama1_length input.int(2'KAMA 1 Length'minval 1group 'KAMA Settings')
    kama1_fast input.int(1'KAMA 1 Fast Length'minval 1group 'KAMA Settings')
    kama1_slow input.int(3'KAMA 1 Slow Length'minval 1group 'KAMA Settings')

    kama2_length input.int(3'KAMA 2 Length'minval 1group 'KAMA Settings')
    kama2_fast input.int(2'KAMA 2 Fast Length'minval 1group 'KAMA Settings')
    kama2_slow input.int(4'KAMA 2 Slow Length'minval 1group 'KAMA Settings')

    kama3_length input.int(4'KAMA 3 Length'minval 1group 'KAMA Settings')
    kama3_fast input.int(3'KAMA 3 Fast Length'minval 1group 'KAMA Settings')
    kama3_slow input.int(5'KAMA 3 Slow Length'minval 1group 'KAMA Settings')

    kama4_length input.int(5'KAMA 4 Length'minval 1group 'KAMA Settings')
    kama4_fast input.int(4'KAMA 4 Fast Length'minval 1group 'KAMA Settings')
    kama4_slow input.int(6'KAMA 4 Slow Length'minval 1group 'KAMA Settings')

    kama5_length input.int(6'KAMA 5 Length'minval 1group 'KAMA Settings')
    kama5_fast input.int(7'KAMA 5 Fast Length'minval 1group 'KAMA Settings')
    kama5_slow input.int(8'KAMA 5 Slow Length'minval 1group 'KAMA Settings')

    src874 input.source(close'Source'group 'KAMA Settings')

    // ============================================================================
    // TREND COLORING PARAMETERS
    // ============================================================================
    color color_bearish_price_state input.color(color.rgb(2243251), 'Bearish Trend'group 'Colors')
    color color_bullish_price_state input.color(#f1f6f7, 'Bullish Trend', group = 'Colors')
    color color_bullish_resistance_state input.color(color.rgb(2433352), 'Bullish Resistance'group 'Colors')
    color color_bearish_support_state input.color(color.rgb(226247252), 'Bearish Support'group 'Colors')

    float atr_multiplier_gray input.float(14'ATR Multiplier (Gray Zone)'minval 0.1group 'Ribbon Settings')
    float atr_multiplier_yellow input.float(14'ATR Multiplier (Yellow Zone)'minval 0.1group 'Ribbon Settings')


    // ============================================================================
    // KAMA CALCULATION FUNCTION
    // ============================================================================
    f_kama(float src874int lengthint fastLengthint slowLength) =>
        
    mom math.abs(ta.change(src874length))
        
    volatility math.sum(math.abs(ta.change(src874)), length)
        
    er volatility != mom volatility 0

        fastAlpha 
    / (fastLength 1)
        
    slowAlpha / (slowLength 1)
        
    alpha math.pow(er * (fastAlpha slowAlpha) + slowAlpha2)

        var 
    float kama na
        kama 
    := alpha src874 + (alpha) * nz(kama[1], src874)
        
    kama

    // ============================================================================
    // CALCULATE ALL KAMAS
    // ============================================================================
    float kama1 f_kama(src874kama1_lengthkama1_fastkama1_slow)
    float kama2 f_kama(src874kama2_lengthkama2_fastkama2_slow)
    float kama3 f_kama(src874kama3_lengthkama3_fastkama3_slow)
    float kama4 f_kama(src874kama4_lengthkama4_fastkama4_slow)
    float kama5 f_kama(src874kama5_lengthkama5_fastkama5_slow)

    // ============================================================================
    // KAMA STACK RIBBON LOGIC (Replaces SMA Stack)
    // ============================================================================
    bool is_bullish_stack kama1 kama2 and kama2 kama3 and kama3 kama4 and kama4 kama5
    bool is_bearish_stack 
    kama1 kama2 and kama2 kama3 and kama3 kama4 and kama4 kama5

    float atr_gray 
    ta.atr(14) * atr_multiplier_gray
    float atr_yellow 
    ta.atr(14) * atr_multiplier_yellow
    float kama_spread 
    math.abs(kama1 kama5)

    bool is_narrowing_gray not is_bullish_stack and not is_bearish_stack and kama_spread atr_gray
    bool is_narrowing_yellow 
    not is_bullish_stack and not is_bearish_stack and kama_spread atr_yellow

    var bool was_bullish_stack false
    var bool was_bearish_stack false

    was_bullish_stack 
    := is_bullish_stack true is_bearish_stack false was_bullish_stack
    was_bearish_stack 
    := is_bearish_stack true is_bullish_stack false was_bearish_stack

    // ============================================================================
    color kama_ribbon_color is_bearish_stack color_bearish_price_state is_narrowing_yellow and not was_bullish_stack color_bearish_support_state is_narrowing_gray and was_bullish_stack color_bullish_resistance_state is_bullish_stack color_bullish_price_state na


    // ============================================================================
    plotcandle(openhighlowclosecolor kama_ribbon_colorwickcolor kama_ribbon_colorbordercolor kama_ribbon_colortitle 'MUM')
    /////////////////////

    // Only act after candle closes
    isClosed barstate.isconfirmed

    // Your raw retracement rules
    bullRaw isClosed and close[1] < open[1] and close open and close low[1]
    bearRaw isClosed and close[1] > open[1] and close open and close high[1]

    // Small wick-based spacing
    spaceUp = (high close) * 0.35
    spaceDown 
    = (open low) * 0.35

    // Colors
    brightRed color.rgb(25500)
    brightGreen color.rgb(02550)

    // Wave locks
    var bool bullWaveLocked false
    var bool bearWaveLocked false

    // Reset locks when opposite candle prints
    if isClosed and close open
        bullWaveLocked 
    := false
        bullWaveLocked

    if isClosed and close open
        bearWaveLocked 
    := false
        bearWaveLocked

    // BEARISH WAVE (Red)
    if bullRaw and not bullWaveLocked
        label
    .new(bar_index 1high[1] + (high[1] - close[1]) * 0.35'L'style label.style_nonetextcolor brightRedsize size.large)

        
    label.new(bar_indexhigh spaceUp'o'style label.style_nonetextcolor brightRedsize size.large)

        
    bullWaveLocked := true
        bullWaveLocked

    // BULLISH WAVE (Green)
    if bearRaw and not bearWaveLocked
        label
    .new(bar_index 1low[1] - (open[1] - low[1]) * 0.35'L'style label.style_nonetextcolor brightGreensize size.large)

        
    label.new(bar_indexlow spaceDown'o'style label.style_nonetextcolor brightGreensize size.large)

        
    bearWaveLocked := true
        bearWaveLocked
    ///////////////////////// 
    örnek https://www.tradingview.com/x/5oj3lq0b/

    not: koddaki turuncu yerler...kapatılıp iptal edilen bölümler....isteyen silebilir ya da aktif edebilir...
    16.07.2024 - 10.12.2024

  5. tasarlayacağınız sistemlerde.. son 100 bar için dip-tepe.. grafik üzerine yazma örneği...
    örnek https://www.tradingview.com/x/weu5kK09/

    PHP Code:
    // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
    // © LuxAlgo

    //@version=6
    indicator('Zig Zag Channels [LuxAlgo]'overlay truemax_bars_back 5000max_lines_count 500max_labels_count 500)
    //------------------------------------------------------------------------------
    length744 input(100)
    extend input(true'Extend To Last Bar')
    //show_ext = input(true, 'Show Extremities')
    show_labels input(true'Show Labels')

    //Style

    upcol input.color(#0004ff, 'Upper Extremity Color', group = 'Style')
    midcol input.color(#ff5d00, 'Zig Zag Color', group = 'Style')
    dncol input.color(color.rgb(2222466), 'Lower Extremity Color'group 'Style')
    //------------------------------------------------------------------------------
    os 0
    src 
    close
    bar_index
    var float valtop na
    var float valbtm na

    //------------------------------------------------------------------------------
    upper ta.highest(srclength744)
    lower ta.lowest(srclength744)
    os := src[length744] > upper src[length744] < lower os[1]

    btm os == and os[1] != 1
    top 
    os == and os[1] != 0

    //------------------------------------------------------------------------------
    btm_n ta.valuewhen(btmn0)
    top_n ta.valuewhen(topn0)
    len math.abs(btm_n top_n)

    if 
    btm
        max_diff_up 
    0.
        max_diff_dn 
    0.
        valbtm 
    := low[length744]

        for 
    0 to len 1 by 1
            point 
    low[length744] + / (len 1) * (valtop low[length744])
            
    max_diff_up := math.max(math.max(src[length744 i], open[length744 i]) - pointmax_diff_up)
            
    max_diff_dn := math.max(point math.min(src[length744 i], open[length744 i]), max_diff_dn)
            
    max_diff_dn

        
    //line.new(n[len + length744], valtop, n[length744], low[length744], color = midcol)

        //if show_ext
            //line.new(n[len + length744], valtop + max_diff_up, n[length744], low[length744] + max_diff_up, color = upcol, style = line.style_dotted)
            //line.new(n[len + length744], valtop - max_diff_dn, n[length744], low[length744] - max_diff_dn, color = dncol, style = line.style_dotted)
        
    if show_labels
            label
    .new(n[length744], low[length744], str.tostring(low[length744], '#.####'), color #00000000, style = label.style_label_up, textcolor = dncol, textalign = text.align_left, size = size.large)

    if top
        max_diff_up 
    0.
        max_diff_dn 
    0.
        valtop 
    := high[length744]

        for 
    0 to len 1 by 1
            point 
    high[length744] + / (len 1) * (valbtm high[length744])
            
    max_diff_up := math.max(math.max(src[length744 i], open[length744 i]) - pointmax_diff_up)
            
    max_diff_dn := math.max(point math.min(src[length744 i], open[length744 i]), max_diff_dn)
            
    max_diff_dn

        
    //line.new(n[len + length744], valbtm, n[length744], high[length744], color = midcol)

        //if show_ext
           // line.new(n[len + length744], valbtm + max_diff_up, n[length744], high[length744] + max_diff_up, color = upcol, style = line.style_dotted)
            //line.new(n[len + length744], valbtm - max_diff_dn, n[length744], high[length744] - max_diff_dn, color = dncol, style = line.style_dotted)
        
    if show_labels
            label
    .new(n[length744], high[length744], str.tostring(high[length744], '#.####'), color #00000000, style = label.style_label_down, textcolor = upcol, textalign = text.align_left, size = size.large)

    if barstate.islast and extend
        max_diff_up 
    0.
        max_diff_dn 
    0.
        x1 
    0
        y1 
    0.

        
    if os == 1
            x1 
    := btm_n length744
            y1 
    := valbtm

            
    for 0 to n btm_n length744 1 by 1
                point 
    src / (btm_n length744 1) * (valbtm src)
                
    max_diff_up := math.max(math.max(src[i], open[i]) - pointmax_diff_up)
                
    max_diff_dn := math.max(point math.min(src[i], open[i]), max_diff_dn)
                
    max_diff_dn
        
    else 
            
    x1 := top_n length744
            y1 
    := valtop

            
    for 0 to n top_n length744 1 by 1
                point 
    src / (top_n length744 1) * (valtop src)
                
    max_diff_up := math.max(math.max(src[i], open[i]) - pointmax_diff_up)
                
    max_diff_dn := math.max(point math.min(src[i], open[i]), max_diff_dn)
                
    max_diff_dn

        
    //line.delete(line.new(x1, y1, n, src, color = midcol, extend = extend.right)[1])

        //if show_ext
            //line.delete(line.new(x1, y1 + max_diff_up, n, src + max_diff_up, color = upcol, style = line.style_dotted, extend = extend.right)[1])
            //line.delete(line.new(x1, y1 - max_diff_dn, n, src - max_diff_dn, color = dncol, style = line.style_dotted, extend = extend.right)[1])

    //------------------------------------------------------------------------------
    plot(btm low[length744] : top high[length744] : na'ANA'color btm dncol upcolstyle plot.style_circlesoffset = -length744
    sadeleştirildi...isteyen kodun kapalı yerini açabilir...
    16.07.2024 - 10.12.2024

  6. birleştirme örneği https://www.tradingview.com/x/83y0RGxc/

    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/
    // © AlgoAlpha

    //@version=6
    indicator(".."overlay truemax_lines_count 500behind_chart false)

    tolerence input.float(0.7"Noise Filter"group "Calculations"tooltip "Determines which levels to use as CSID triggers, a larger setting results in less noise"maxval 1minval 0step 0.1)
    len input.int(12"Swing Period"group "Calculations"tooltip "The period to detect swing points, a larger setting will detect longer term swings")
    expiry_bars input.int(100"Expiry Bars"group "Calculations"tooltip "Number of bars after which old liquidity lines stop updating")
    liquidity_lookback input.int(10"Liquidity Lookback"group "Calculations"tooltip "Lookback period to check if opposing liquidity was wicked before a CISD")

    green input.color(#00ffbb, title = "Bullish Colour", group = "Appearance", tooltip = "Color used for bullish visuals and positive sentiment texts.")
    red   input.color(#ff1100, title = "Bearish Colour", group = "Appearance", tooltip = "Color used for bearish visuals and negative sentiment texts.")
    t1 input.int(90"Candle Body Transperency"maxval 100minval 0group "Appearance")
    t2 input.int(40"Candle Wick/Border Transperency"maxval 100minval 0group "Appearance")
    hide_expired_levels input.bool(true"Hide Expired Levels"group "Appearance"tooltip "Delete liquidity levels once they exceed the expiry bar threshold.")
    hide_mitigated_levels input.bool(false"Hide Mitigated Levels"group "Appearance"tooltip "Delete liquidity levels from the chart as soon as price mitigates them.")

    pivlow ta.pivotlow(lenlen)
    pivhigh ta.pivothigh(lenlen)

    var 
    swinghighs = array.new_line()
    var 
    swinglows = array.new_line()

    if 
    not na(pivhigh)
        
    swinghighs.unshift(line.new(bar_index-lenhigh[len], bar_indexhigh[len], color color.new(chart.fg_color50)))
    if 
    not na(pivlow)
        
    swinglows.unshift(line.new(bar_index-lenlow[len], bar_indexlow[len], color color.new(chart.fg_color50)))

    var 
    float last_wicked_high_level na
    var float last_wicked_low_level na

    wicked_high 
    false
    wicked_low 
    false

    if swinghighs.size() > 0
        
    for swinghighs.size() - 1 to 0
            
    if swinghighs.size()
                
    swinghighs.get(i)
                if 
    bar_index line.get_x1(l) < expiry_bars
                    lvl 
    line.get_y1(l)
                    
    line.set_x2(lbar_index)
                    if 
    high >= lvl and barstate.isconfirmed
                        
    if hide_mitigated_levels
                            line
    .delete(l)
                        
    swinghighs.remove(i)
                        
    wicked_high := true
                        last_wicked_high_level 
    := lvl
                
    else
                    if 
    hide_expired_levels
                        line
    .delete(l)
                        
    swinghighs.remove(i)

    if 
    swinglows.size() > 0
        
    for swinglows.size() - 1 to 0
            
    if swinglows.size()
                
    swinglows.get(i)
                if 
    bar_index line.get_x1(l) < expiry_bars
                    lvl 
    line.get_y1(l)
                    
    line.set_x2(lbar_index)
                    if 
    low <= lvl and barstate.isconfirmed
                        
    if hide_mitigated_levels
                            line
    .delete(l)
                        
    swinglows.remove(i)
                        
    wicked_low := true
                        last_wicked_low_level 
    := lvl
                
    else
                    if 
    hide_expired_levels
                        line
    .delete(l)
                        
    swinglows.remove(i)

    while 
    swinghighs.size() > 100
        line
    .delete(swinghighs.pop())

    while 
    swinglows.size() > 100
        line
    .delete(swinglows.pop())

    bars_since_high ta.barssince(wicked_high)
    bars_since_low ta.barssince(wicked_low)

    var 
    potential_bull_cisd_level 0.0
    var potential_bear_cisd_level 0.0

    var 0.0
    var 0.0

    var bear_potential = array.new_float()
    var 
    bull_potential = array.new_float()

    if 
    close[1] < open[1] and close open
        bear_potential
    .unshift(bar_index)
        
    bear_potential.unshift(open)

    if 
    close[1] > open[1] and  close open
        bull_potential
    .unshift(bar_index)
        
    bull_potential.unshift(open)

    cisd 0
    origin_lvl 
    0.0
    origin_idx 
    0.0

    if bear_potential.size() > 0
        inloop 
    true
        
    while inloop
            
    if close bear_potential.first() 
                
    highest 0.0
                
    for 0 to bar_index-bear_potential.get(1)
                    if 
    close[i] > highest
                        highest 
    := close[i]
                
    running true
                init 
    bar_index-bear_potential.get(1)+1
                top 
    0.0
                
    while running
                    
    if close[init] < open[init]
                        
    top := open[init]
                        
    init+=1
                    
    else
                        
    running:=false
                
    if (highest-bear_potential.first())/(top-bear_potential.first()) > tolerence
                    origin_lvl 
    := bear_potential.first()
                    
    origin_idx := bear_potential.get(1)
                    
    bear_potential.clear()
                    
    cisd := 1
                    inloop 
    := false
                
    else
                    
    bear_potential.shift()
                    
    bear_potential.shift()
                    if 
    bear_potential.size() == 0
                        inloop 
    := false
            
    else
                
    inloop := false


    if bull_potential.size() > 0
        inloop 
    true
        
    while inloop
            
    if close bull_potential.first()
                
    lowest close
                
    for 0 to bar_index-bull_potential.get(1)
                    if 
    close[i] < lowest
                        lowest 
    := close[i]
                
                
    running true
                init 
    bar_index-bull_potential.get(1)+1
                bottom 
    0.0
                
                
    while running
                    
    if close[init] > open[init]
                        
    bottom := open[init]
                        
    init+=1
                    
    else
                        
    running:=false
                
                
    if (bull_potential.first() - lowest)/(bull_potential.first() - bottom) > tolerence
                    origin_lvl 
    := bull_potential.first()
                    
    origin_idx := bull_potential.get(1)
                    
    bull_potential.clear()
                    
    cisd := 2
                    inloop 
    := false
                
    else
                    
    bull_potential.shift()
                    
    bull_potential.shift()
                    if 
    bull_potential.size() == 0
                        inloop 
    := false
            
    else
                
    inloop := false


    var trend 0

    bearish_sweep 
    false
    bullish_sweep 
    false

    if cisd == 1
        trend 
    := -1
        line
    .new(int(origin_idx),origin_lvl,bar_index,origin_lvlcolor redwidth 3)
        if 
    bars_since_high <= liquidity_lookback and close last_wicked_high_level
            bearish_sweep 
    := true

    if cisd == 2
        trend 
    := 1
        line
    .new(int(origin_idx),origin_lvl,bar_index,origin_lvlcolor greenwidth 3)
        if 
    bars_since_low <= liquidity_lookback and close last_wicked_low_level
            bullish_sweep 
    := true

    //plotshape(bearish_sweep ? high : na, "Bearish CISD with Liquidity Sweep", shape.labeldown, location.abovebar, red, size = size.small, text = "▼", textcolor = chart.fg_color)
    //plotshape(bullish_sweep ? low : na, "Bullish CISD with Liquidity Sweep", shape.labelup, location.belowbar, green, size = size.small, text = "▲", textcolor = chart.fg_color)

    plotchar(not na(pivhigh) ? high[len] : na"Swing High""●"location.absoluteredsize size.normaloffset = -len)
    plotchar(not na(pivlow) ? low[len] : na"Swing Low""●"location.absolutegreensize size.normaloffset = -len)

    candle_col color.from_gradient(t10100trend green redchart.bg_color)
    candle_col_ color.from_gradient(t20100trend green redchart.bg_color)
    plotcandle(openhighlowclose"Mum"candle_colcandle_col_bordercolor candle_col_)

    // Alerts 
    alertcondition(wicked_high"Swing High Mitigation""Swing High Mitigated")
    alertcondition(wicked_low"Swing Low Mitigation""Swing Low Mitigated")
    alertcondition(cisd == 1"Bearish Normal CISD""Bearish Normal CISD Detected")
    alertcondition(cisd == 2"Bullish Normal CISD""Bullish Normal CISD Detected")
    alertcondition(bearish_sweep"Strong Bearish CISD""Strong Bearish CISD Detected")
    alertcondition(bullish_sweep"Strong Bullish CISD""Strong Bullish CISD Detected")
    //////////////////////////

    var string vanity_group "Visual Settings"

    magic_wand_toggle input.bool(true"Show Active CISD Level (Plot)"group=vanity_group)

    drama_filter input.string("Both""Triggered CISD Display"options=["Both""Bullish Only""Bearish Only""None"], group=vanity_group)

    amnesia_mode input.bool(false"Limit Displayed Historical Lines"group=vanity_group)
    short_term_memory input.int(10"Max Lines to Show"minval=1group=vanity_group)

    yell_at_me input.bool(true"Show Labels"group=vanity_group)
    girth_units input.int(4"Line Width"minval=1group=vanity_group)
    scream_volume input.string(size.normal"Label Size"options=[size.tinysize.smallsize.normalsize.large], group=vanity_group)

    hipster_font_toggle input.string("Default""Font Family"options=["Default""Monospace"], group=vanity_group)
    fashion_choice input.string("Solid""Triggered Line Style"options=["Solid""Dashed""Dotted"], group=vanity_group)

    crayon_box "Colors"
    shrek_mode input.color(color.new(color.green0), "Bullish CISD"group=crayon_box)
    blood_bath input.color(color.new(color.red0), "Bearish CISD"group=crayon_box)

    nerd_stats "Debug"
    paranoia_switch input.bool(false"Debug: Show Extreme Tracking"group=nerd_stats)

    gossip_column "HTF Trend Panel" 
    stalker_mode input.bool(true"Show Multi-Timeframe Table"group=gossip_column)
    feng_shui input.string("Bottom Right""Table Position"options=["Top Right""Middle Right""Bottom Right""Bottom Left"], group=gossip_column)
    eye_test input.string("Small""Table Size"options=["Tiny""Small""Normal""Large"], group=gossip_column)
    // ---------------------------------------------------------

    var string fancy_typeface hipster_font_toggle == "Monospace" font.family_monospace font.family_default

    decode_fashion_statement
    (outfit) =>
        switch 
    outfit
            
    "Solid"  => line.style_solid
            
    "Dashed" => line.style_dashed
            
    => line.style_dotted

    chosen_style 
    decode_fashion_statement(fashion_choice)

    var 
    int vibes 0
    var float bagholder_entry na
    var int time_machine_setting na
    var float pain_threshold na

    var label sticky_note_of_shame na
    var array<linegraveyard_of_hopes = array.new<line>()
    var array<
    labelchoir_of_screams = array.new<label>()

    consult_the_crystal_ball(int bias) =>
        
    int temporal_shift 0
        float ancient_price 
    open
        
    for 0 to 500
            int candle_attitude 
    close[i] > open[i] ? close[i] < open[i] ? -0
            
    if candle_attitude == 0
                
    continue
            
    bool mood_match candle_attitude == bias
            
    if not mood_match
                
    break
            
    temporal_shift := i
            ancient_price 
    := open[i]
        [
    ancient_pricebar_index temporal_shift]

    archaeologist_jones(int bias) =>
        
    int i 1
        bool artifact_found 
    false
        int dig_site_idx 
    0
        float artifact_value 
    na
        
    for 1 to 500
            i 
    := j
            int candle_attitude 
    close[i] > open[i] ? close[i] < open[i] ? -0
            
    if candle_attitude == 0
                
    continue
            
    bool is_correct_era candle_attitude == bias
            
    if not artifact_found
                
    if is_correct_era
                    artifact_found 
    := true
                    dig_site_idx 
    := i
                    artifact_value 
    := open[i]
            else
                if 
    not is_correct_era
                    
    break
                
    dig_site_idx := i
                artifact_value 
    := open[i]
        [
    artifact_valuebar_index dig_site_idx]

    if 
    vibes == and bar_index 10
        int first_impression 
    close open close open ? -0
        
    if first_impression == 0
            
    for 1 to 50
                first_impression 
    := close[k] > open[k] ? close[k] < open[k] ? -0
                
    if first_impression != 0
                    
    break
        if 
    first_impression != 0
            vibes 
    := first_impression
            
    [origin_priceorigin_time] = consult_the_crystal_ball(first_impression)
            
    bagholder_entry := origin_price
            time_machine_setting 
    := origin_time
            pain_threshold 
    := first_impression == high low

    int candle_personality 
    close open close open ? -0
    float fresh_hopium 
    na
    int fresh_timestamp 
    na

    if vibes == 1
        
    if high pain_threshold
            pain_threshold 
    := high
            
    if candle_personality == 1
                
    [p_pricep_idx] = consult_the_crystal_ball(1)
                
    fresh_hopium := p_price
                fresh_timestamp 
    := p_idx
            
    else
                [
    p_pricep_idx] = archaeologist_jones(1)
                
    fresh_hopium := p_price
                fresh_timestamp 
    := p_idx
            bagholder_entry 
    := fresh_hopium
            time_machine_setting 
    := fresh_timestamp

    else if vibes == -1
        
    if low pain_threshold
            pain_threshold 
    := low
            
    if candle_personality == -1
                
    [p_pricep_idx] = consult_the_crystal_ball(-1)
                
    fresh_hopium := p_price
                fresh_timestamp 
    := p_idx
            
    else
                [
    p_pricep_idx] = archaeologist_jones(-1)
                
    fresh_hopium := p_price
                fresh_timestamp 
    := p_idx
            bagholder_entry 
    := fresh_hopium
            time_machine_setting 
    := fresh_timestamp

    bool shorts_squeezed 
    vibes == -and close bagholder_entry
    bool longs_rekt 
    vibes == and close bagholder_entry

    if shorts_squeezed or longs_rekt
        bool should_i_paint_it 
    false
        
        
    if drama_filter == "Both"
            
    should_i_paint_it := true
        
    else if drama_filter == "Bullish Only"
            
    should_i_paint_it := shorts_squeezed
        
    else if drama_filter == "Bearish Only"
            
    should_i_paint_it := longs_rekt

        
    if should_i_paint_it
            color mood_ring 
    shorts_squeezed shrek_mode blood_bath
            line tragedy_line 
    line.new(time_machine_settingbagholder_entrybar_indexbagholder_entrycolor=mood_ringwidth=girth_unitsstyle=chosen_style)
            array.
    push(graveyard_of_hopestragedy_line)

            
    label loud_noise na
            
    //if yell_at_me
                //int middle_of_nowhere = math.round((time_machine_setting + bar_index) / 2)
                //string gibberish = shorts_squeezed ? "+ALL" : "-SAT"
                //color ink_color = shorts_squeezed ? shrek_mode : blood_bath
                //loud_noise := label.new(middle_of_nowhere, bagholder_entry, gibberish, style=shorts_squeezed ? label.style_label_down : label.style_label_up, color=color.new(#000000, 100), textcolor=ink_color, size=scream_volume, text_font_family = fancy_typeface)
            
            
    array.push(choir_of_screamsloud_noise)

        
    int new_emotional_state shorts_squeezed : -1
        vibes 
    := new_emotional_state
        
    [reset_pricereset_time] = consult_the_crystal_ball(new_emotional_state)
        
    bagholder_entry := reset_price
        time_machine_setting 
    := reset_time
        pain_threshold 
    := new_emotional_state == high low

    color active_crayon 
    vibes == shrek_mode blood_bath

    plot
    (magic_wand_toggle bagholder_entry na"TR"color=active_crayonlinewidth=girth_unitsstyle=plot.style_stepline)
    ///////////////////////

    // --------------------------------------------------------------------------------------------------------------------}
    // 📌 𝙐𝙎𝙀𝙍 𝙄𝙉𝙋𝙐𝙏𝙎
    // --------------------------------------------------------------------------------------------------------------------{

    source      input.source(close'Source')
    length      input.int(10'Period'1)
    displayExt  input.bool(true""inline "ext")
    extrapolate input.int(1'Extrapolate'0inline "ext")
    degree      input.int(1'Degree'1)
    colorUp     input.color(color.yellow""inline "col")
    colorDn     input.color(color.fuchsia""inline "col")


    // --------------------------------------------------------------------------------------------------------------------}
    // 📌 𝙄𝙉𝘿𝙄𝘾𝘼𝙏𝙊𝙍 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎
    // --------------------------------------------------------------------------------------------------------------------{

    polyreg(sourcelengthdegreeextrapolate) =>
        if 
    barstate.islast
            total 
    length extrapolate

            X_all 
    matrix.new<float>(totaldegree 10.0)
            for 
    0 to total 1
                
    for 0 to degree
                    matrix
    .set(X_allijmath.pow(ij))

            
    // y (length × 1), oldest→newest over the fit window
            
    matrix.new<float>(length10.0)
            for 
    0 to length 1
                matrix
    .set(yi0source[length i])

            
    // X_train (first `length` rows of X_all)
            
    X_tr matrix.new<float>(lengthdegree 10.0)
            for 
    0 to length 1
                
    for 0 to degree
                    matrix
    .set(X_trijmatrix.get(X_allij))

            
    // OLS via normal equations: (X'X)^(-1)b = X'y  ⇒  b = (X'X)^(-1) X'y
            
    Xt   matrix.transpose(X_tr)           // X'
            
    XtX  matrix.mult(XtX_tr)           // (X'X) 
            
    Xty  matrix.mult(Xty)             //  X'y
            
    XtX_inv matrix.inv(XtX)            // (X'X)^(-1)      
            
    b       matrix.mult(XtX_invXty//  b = (X'X)^(-1) X'y

            // Predictions for all rows (fit + extrap)
            
    preds matrix.mult(X_allmatrix.col(b,0))    
            
    preds


    dist        
    ta.highest(ta.sma(high-lowlength), length)*2
    predictions 
    polyreg(sourcelengthdegreeextrapolate)

    drawLine(offset)=>
        
        var 
    lastPred  float(na)
        var 
    color     color(na)
        var 
    labels    = array.new<label>()
        var 
    prevValue float(na)

        if 
    barstate.islast
            chartPoints  
    = array.new<chart.point>()
            
    chartPoints1 = array.new<chart.point>()

            if 
    labels.size() > 0
                
    for l in labels
                    l
    .delete()

            for [
    indexpredictionin predictions

                Directioncolor 
    prediction prevValue colorUp colorDn
                prevValue 
    := prediction
                predZone 
    index >= length

                
    if offset == 
                    marker   
    displayExt ? (predZone "•" "⬥") : (predZone "" "⬥")
                    
    txtColor predZone chart.fg_color Directioncolor
                    labels
    .push(label.new(chart.point.from_index(index bar_index index length 1price prediction+offset), markercolor color(na), textcolor txtColorstyle label.style_label_center))
                
                else if 
    predZone and displayExt
                    chartPoints
    .push(value chart.point.from_index(index bar_index index length 1price prediction+offset))
                else if 
    not predZone
                    chartPoints1
    .push(value chart.point.from_index(index bar_index index length 1price prediction+offset))

                if 
    index == length+extrapolate-and displayExt
                    lastPred 
    := prediction
                    
    if offset 0
                        style 
    Directioncolor == colorUp label.style_label_lower_left label.style_label_upper_left
                        label
    .delete(label.new(bar_index+extrapolatelastPred-offsetstr.tostring(lastPred-offset"##,###,###.###"), style styletextcolor chart.fg_colorcolor color(na))[1])
                        
    label.delete(label.new(bar_index+extrapolatelastPredstr.tostring(lastPred"##,###,###.###"), style styletextcolor chart.fg_colorcolor color(na))[1])
                        
    label.delete(label.new(bar_index+extrapolatelastPred+offsetstr.tostring(lastPred+offset"##,###,###.###"), style styletextcolor chart.fg_colorcolor color(na))[1])

            
    color := chart.fg_color
            
    //polyline.delete(polyline.new(chartPoints, line_width = 1, line_style = line.style_dashed, line_color = color)[1])
            //polyline.delete(polyline.new(chartPoints1, line_width = 1, line_style = line.style_solid, line_color = color)[1])

            
        
    lastPred


    // --------------------------------------------------------------------------------------------------------------------}
    // 📌 𝙑𝙄𝙎𝙐𝘼𝙇𝙄𝙕𝘼𝙏𝙄𝙊𝙉
    // --------------------------------------------------------------------------------------------------------------------{

    drawLine(dist)
    drawLine(0)
    drawLine(-dist)

    // --------------------------------------------------------------------------------------------------------------------}

    //////////////////////
    // 2. PSAR (Orta Yakınlık)
    start2 0.01 // İsteğiniz üzerine SIFIR
    inc2 input.float(0.1title '2. Artış (Orta)'step 0.01group '2. Orta PSAR')
    max2 input.float(0.99title '2. Limit'step 0.05group '2. Orta PSAR')
    // 3. PSAR (Nispeten Daha Uzak ama Standarttan Yakın)
    start3 0. // İsteğiniz üzerine SIFIR
    inc3 input.float(0.1title '3. Artış (Uzak)'step 0.01group '3. Uzak PSAR')
    max3 input.float(0.99title '3. Limit'step 0.05group '3. Uzak PSAR')
    psar2 ta.sar(start2inc2max2)
    psar3 ta.sar(start3inc3max3)
    // Define colors for bullish and bearish conditions
    GreenFluorescent color.rgb(02550)
    RedFluorescent color.rgb(25500)
    plot(psar2,"SRX"style plot.style_crosslinewidth 2color close psar2 GreenFluorescent close psar2 RedFluorescent na)
    plot(psar3,"SRY"style plot.style_crosslinewidth 2color close psar3 GreenFluorescent close psar3 RedFluorescent na)
    ////////////////////////////////

    // --------------------------------------------------------------------------------------------------------------------}
    colLong color.rgb(2502464)
    colShort color.rgb(5249241)
    atrLength input.int(5"ATR Period"minval=5maxval=50)
    stFactor input.float(2.0"Supertrend Factor"minval=1.0maxval=5.0step=0.1)
    stPeriod input.int(5"Supertrend Period"minval=5maxval=30)

    atr ta.atr(atrLength)
    [
    supertrendstDirection] = ta.supertrend(stFactorstPeriod)

    isUptrend stDirection == -1
    isDowntrend 
    stDirection == 1

    stColor 
    isUptrend colLong colShort
    plot
    (supertrend"STR"color=stColorlinewidth=1)
    // ============================================================================

    //////////////////////

    // PMI_LA Indicator Parameters
    sm input(4title 'PMI_LA Smoothing Period')
    cd input(0.4title 'PMI_LA Constant D')
    cd1 input(-0.6title 'PMI_LA Constant D')
    cd12 input(1.4title 'PMI_LA Constant D')
    ebc input(falsetitle 'PMI_LA Color Bars')
    ribm input(falsetitle 'PMI_LA Ribbon Mode')

    // Buy Sell Indicator Parameters
    input(2title 'BSI Multiplier')
    c88 input(30title 'BSI ATR Period')
    input(falsetitle 'BSI Heikin Ashi Candles')

    // PMI_LA Calculation
    var float i1 na
    var float i2 na
    var float i3 na
    var float i4 na
    var float i5 na
    var float i6 na
    var float bfr na
    var float bfr1 na
    var float bfr12 na
    var color bfrC na
    var color bfrC1 na
    var color bfrC12 na
    var float di na
    var float c1 na
    var float c2 na
    var float c3 na
    var float c33 na
    var float c333 na
    var float c4 na
    var float c44 na
    var float c444 na
    var float c5 na
    var float c55 na
    var float c555 na

    src_pmi 
    close
    di 
    := (sm 1.0) / 2.0 1.0
    c1 
    := / (di 1.0)
    c2 := c1
    c3 
    := 3.0 * (cd cd cd cd cd)
    c33 := 3.0 * (cd1 cd1cd1 cd1 cd1)
    c333 := 3.0 * (cd12 cd12cd12 cd12 cd12)
    c4 := -3.0 * (2.0 cd cd cd cd cd cd)
    c44 := -3.0 * (2.0 cd1 cd1 cd1 cd1 cd1 cd1)
    c444 := -3.0 * (2.0 cd12 cd12 cd12 cd12 cd12 cd12)
    c5 := 3.0 cd 1.0 cd cd cd 3.0 cd cd
    c55 
    := 3.0 cd1 1.0 cd1 cd1 cd1 3.0 cd1 cd1
    c555 
    := 3.0 cd12 1.0 cd12 cd12 cd12 3.0 cd12 cd12
    i1 
    := c1 src_pmi c2 nz(i1[1])
    i2 := c1 i1 c2 nz(i2[1])
    i3 := c1 i2 c2 nz(i3[1])
    i4 := c1 i3 c2 nz(i4[1])
    i5 := c1 i4 c2 nz(i5[1])
    i6 := c1 i5 c2 nz(i6[1])
    bfr := -cd cd cd i6 c3 i5 c4 i4 c5 i3
    bfr1 
    := -cd1 cd1 cd1 i6 c33 i5 c44 i4 c55 i3
    bfr12 
    := -cd12 cd12 cd12 i6 c333 i5 c444 i4 c555 i3
    bfrC 
    := bfr nz(bfr[1]) ? color.rgb(7617579100) : bfr nz(bfr[1]) ? color.rgb(2558282100) : color.rgb(33149243100)
    bfrC1 := bfr1 nz(bfr1[1]) ? color.rgb(7617579100) : bfr1 nz(bfr1[1]) ? color.rgb(2558282100) : color.rgb(33149243100)
    bfrC12 := bfr12 nz(bfr12[1]) ? color.rgb(7617579100) : bfr12 nz(bfr12[1]) ? color.rgb(2558282100) : color.rgb(33149243100)

    // Buy Sell Indicator Calculation
    xATR ta.atr(c88)
    nLoss xATR
    src_bsi 
    request.security(ticker.heikinashi(syminfo.tickerid), timeframe.periodcloselookahead barmerge.lookahead_off) : close
    var float xATRTrailingStop na
    iff_1 
    src_bsi nz(xATRTrailingStop[1], 0) ? src_bsi nLoss src_bsi nLoss
    iff_2 
    src_bsi nz(xATRTrailingStop[1], 0) and src_bsi[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src_bsi nLoss) : iff_1
    xATRTrailingStop 
    := src_bsi nz(xATRTrailingStop[1], 0) and src_bsi[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src_bsi nLoss) : iff_2
    var int pos na
    pos 
    := src_bsi[1] < nz(xATRTrailingStop[1], 0) and src_bsi nz(xATRTrailingStop[1], 0) ? src_bsi[1] > nz(xATRTrailingStop[1], 0) and src_bsi nz(xATRTrailingStop[1], 0) ? -nz(pos[1], 0)

    xcolor pos == -color.red pos == color.green color.blue
    ema 
    ta.ema(src_bsi1)
    above ta.crossover(emaxATRTrailingStop)
    below ta.crossover(xATRTrailingStopema)
    buy src_bsi xATRTrailingStop and above
    sell 
    src_bsi xATRTrailingStop and below

    // Plotting
    plot(ribm na bfrtitle 'C()'linewidth 2color bfrCstyle=plot.style_circles)
    plot(ribm na bfr1title 'D()'linewidth 2color bfrC1style=plot.style_circles)
    plot(ribm na bfr12title 'B()'linewidth 2color bfrC12style=plot.style_circles)
    //bgcolor(ribm ? bfrC : na)

    //plotshape(buy, title = 'Buy', text = 'Buy', style = shape.labelup, location = location.belowbar, color = color.new(color.green, 0), textcolor = color.new(color.black, 0), size = size.tiny)
    //plotshape(sell, title = 'Sell', text = 'Sell', style = shape.labeldown, location = location.abovebar, color = color.new(color.red, 0), textcolor = color.new(color.black, 0), size = size.tiny)

    //barcolor(buy ? color.green : sell ? color.red : na)

    //alertcondition(buy, 'Purra Long', 'Purra Long')
    //alertcondition(sell, 'Purra Short', 'Purra Short')
    /////////////////////
    // Constants
    const string calc   "Core Calculation Settings" 
    const string thres  "Signals Settings"
    const string ui     "Plotting and Coloring"
    const color  GREEN  #48ff0000
    const color  RED    #ff000000

    // Inputs
    int   calc_p        input.int(3"Average True Range Period"group=calc)
    float atr_factor    input.float(0.3"Factor"step 0.1group=calc)
    int   start         input.int(1"For Loop Start"inline="FL"group=calc)
    int   end           input.int(4"End",maxval 50inline="FL"group=calc)

    bool  show_refs     input.bool(false"Show Reference Lines"group=thres)
    bool  showls        input.bool(true"Show Long and Short Signals On Chart?"group=thres)
    int   thresL        input.int(3"Long Threshold"group=thresinline=thres)
    int   thresS        input.int(-3"Short Threshold"group=thresinline=thres)

    color longcol       input.color(GREEN"Long Color"group=ui)
    color shortcol      input.color(RED"Short Color"group=ui)
    int   lineW         input.int(1"Line Width"group=ui)
    bool  onchart       input.bool(true"Show On Chart?"group=ui)
    bool  paintCandles  input.bool(false"Paint Candles to Trend?"group=ui)
    bool  bgCol         input.bool(false"Background Color?"group=ui)

    method transp(color xint t) =>
        
    color.new(xt)

    // Types
    type tCalc
        float atr
        float band
        float trail
        float up
        float dn
        float score

    type tCond
        bool longCond
        bool shortCond

    type tState
        int signal

    var tCalc  c99  tCalc.new(nananananana)
    var 
    tCond  cd99 tCond.new(falsefalse)
    var 
    tState st tState.new(1)
    var 
    color coloring na 
    float scoreS 
    0.0

    // Core calcs 
    c99.atr  := ta.atr(calc_p)
    c99.band := c99.atr atr_factor

    var float trailS na
    trailS 
    := close
    trailS 
    := nz(trailS[1], trailS)

    c99.up := close c99.band
    c99
    .dn := close c99.band

    if c99.dn trailS
        trailS 
    := c99.dn
    if c99.up trailS
        trailS 
    := c99.up

    c99
    .trail := trailS

    for start to end by 1
        scoreS 
    += (trailS trailS[i] ? : -1)
        
    scoreS

    c99
    .score := scoreS

    cd99
    .longCond  := c99.score thresL
    cd99
    .shortCond := ta.crossunder(c99.scorethresS)


    if 
    cd99.longCond and not cd99.shortCond
        st
    .signal := 1
        coloring 
    := longcol
    else if cd99.shortCond
        st
    .signal := -1
        coloring 
    := shortcol

    //plot(c.score, "", coloring, lineW)
    plot(c99.trail"A()"coloringlineWplot.style_circlesfalseforce_overlay truedisplay onchart?display.all:display.none)

    if 
    barstate.islast and show_refs
        line
    .new(x1=last_bar_indexx2=bar_index 1y1=thresLy2=thresLcolor=chart.fg_color.transp(50), style=line.style_dashedextend=extend.right)
        
    line.new(x1=last_bar_indexx2=bar_index 1y1=thresSy2=thresScolor=chart.fg_color.transp(50), style=line.style_dashedextend=extend.right)

    // Long and Short Signals 
    //plotcandle(open, high, low, close, "Mum",
         //coloring, coloring, true,
         //bordercolor=coloring,
         //display=paintCandles ? display.all : display.none, force_overlay=true)

    //bgcolor(bgCol?coloring.transp(80):na, force_overlay=true)

    int sigS st.signal
    plotshape
    (sigS == and sigS[1] == -1"Long Signal"shape.triangleuplocation.belowbarlongcol0"𝕃"longcoltruesize.smalldisplay=showls display.all display.noneforce_overlay=true)
    plotshape(sigS == -and sigS[1] == 1"Short Signal"shape.triangledownlocation.abovebarshortcol0"𝕊"shortcoltruesize.smalldisplay=showls display.all display.noneforce_overlay=true)
    ////////// 
    16.07.2024 - 10.12.2024

  7. PHP Code:
    // This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International 
    // https://creativecommons.org/licenses/by-nc-sa/4.0/
    // (Modified for Dashboard Forecasting with RSI Divergence)

    //@version=6
    indicator("Elliott Olasılık"overlay truemax_lines_count 500max_labels_count 500)

    // -----------------------------------------------------------------------------
    // SETTINGS
    // -----------------------------------------------------------------------------
    grp_sett "General Settings"
    len        input.int(5"Short-Term Sensitivity"minval=2group=grp_sett)
    color_up   input.color(#089981, "Historical Wave Color", group=grp_sett)

    grp_cast "Short-Term Forecast"
    show_ext_bull input.bool(true"Show Bullish Extension (Up)"group=grp_cast)
    show_ext_bear input.bool(true"Show Bearish Extension (Down)"group=grp_cast)
    color_cont    input.color(#ff9800, "Extension Color", group=grp_cast)

    link_scenarios input.bool(false"Start Reversal after Extension?"group=grp_cast)

    show_reversal input.bool(true"Show Reversal"group=grp_cast)
    color_rev     input.color(#2962ff, "Reversal Color", group=grp_cast)

    grp_macro "Long-Term Forecast (1 Year)"
    show_macro    input.bool(false"Show 1-Year Macro Projection"group=grp_macro)
    len_macro     input.int(21"Macro Sensitivity"minval=10group=grp_macro)
    macro_spacing input.int(50"Bars per Wave (Time)"minval=5group=grp_macro)
    color_macro   input.color(#9c27b0, "Macro Color", group=grp_macro)

    grp_vis   "Dashboard & Visuals"
    show_table  input.bool(true"Show Target Table"group=grp_vis)
    show_labels input.bool(true"Show Chart Labels"group=grp_vis)
    show_grid   input.bool(true"Show Horizontal Fib Levels"group=grp_vis)
    show_inv    input.bool(true"Show Invalidation Line"group=grp_vis)
    show_div    input.bool(true"Show RSI Divergence (⚡)"group=grp_vistooltip="Highlights setups where Price and RSI disagree (Divergence), indicating a stronger reversal signal.")

    // -----------------------------------------------------------------------------
    // STORAGE
    // -----------------------------------------------------------------------------
    var float[] pPrices = array.new_float()
    var 
    int[]   pBars   = array.new_int()
    var 
    bool[]  pDirs   = array.new_bool() 
    var 
    float[] pRSI    = array.new_float() // NEW: Store RSI values

    var float[] pPricesM = array.new_float()
    var 
    int[]   pBarsM   = array.new_int()
    var 
    bool[]  pDirsM   = array.new_bool()

    var 
    line[]  ghostLines  = array.new_line()
    var 
    label[] ghostLabels = array.new_label()
    var 
    table   infoTable   table.new(position.top_right420border_width 1)

    // -----------------------------------------------------------------------------
    // FUNCTIONS
    // -----------------------------------------------------------------------------
    // Updated to store RSI
    addPivot(float pint bbool dfloat rfloat[] pricesint[] barsbool[] dirsfloat[] rsis) =>
        array.
    unshift(pricesp)
        array.
    unshift(barsb)
        array.
    unshift(dirsd)
        array.
    unshift(rsisr// Store RSI
        
    if array.size(prices) > 20
            
    array.pop(prices)
            array.
    pop(bars)
            array.
    pop(dirs)
            array.
    pop(rsis)

    // Overload for Macro (no RSI tracking needed yet)
    addPivotMacro(float pint bbool dfloat[] pricesint[] barsbool[] dirs) =>
        array.
    unshift(pricesp)
        array.
    unshift(barsb)
        array.
    unshift(dirsd)
        if array.
    size(prices) > 20
            
    array.pop(prices)
            array.
    pop(bars)
            array.
    pop(dirs)

    drawPred(int t1float p1int t2float p2string txtstring fibcolor colint width) =>
        
    line.new(t1p1t2p2color=colstyle=line.style_dashedwidth=width)
        array.
    push(ghostLinesl)
        
        if 
    show_grid
            l_hor 
    line.new(t2p2t2 10p2color=color.new(col50), style=line.style_dottedwidth=1)
            array.
    push(ghostLinesl_hor)

        if 
    show_labels
            lbl_text 
    txt "\n" str.tostring(p2format.mintick)
            
    lb label.new(t2p2text=lbl_textcolor=color.new(color.white100), textcolor=colstyle=label.style_label_leftsize=size.small)
            array.
    push(ghostLabelslb)

    fillRow(int rstring tstring ffloat pcolor c) =>
        
    pct_diff = (close) / close 100
        pct_str  
    = (pct_diff "+" "") + str.tostring(pct_diff"#.##") + "%"
        
    pct_col  pct_diff >= #089981 : #f23645 
        
        
    table.cell(infoTable0rttext_color=color.whitebgcolor=ctext_size=size.small)
        
    table.cell(infoTable1rftext_color=color.whitebgcolor=color.new(c20), text_size=size.small)
        
    table.cell(infoTable2rstr.tostring(pformat.mintick), text_color=color.whitebgcolor=color.new(color.black20), text_size=size.small)
        
    table.cell(infoTable3rpct_strtext_color=pct_colbgcolor=color.new(color.black20), text_size=size.small)

    // -----------------------------------------------------------------------------
    // MAIN LOGIC
    // -----------------------------------------------------------------------------
    // Calculate RSI for Divergence Checks
    my_rsi ta.rsi(close14)

    ph ta.pivothigh(highlenlen)
    pl ta.pivotlow(lowlenlen)

    if 
    not na(ph)
        
    // Pass RSI at the time of the pivot (offset by len)
        
    addPivot(phbar_index[len], truemy_rsi[len], pPricespBarspDirspRSI)
    if 
    not na(pl)
        
    addPivot(plbar_index[len], falsemy_rsi[len], pPricespBarspDirspRSI)

    phM ta.pivothigh(highlen_macrolen_macro)
    plM ta.pivotlow(lowlen_macrolen_macro)

    if 
    not na(phM)
        
    addPivotMacro(phMbar_index[len_macro], truepPricesMpBarsMpDirsM)
    if 
    not na(plM)
        
    addPivotMacro(plMbar_index[len_macro], falsepPricesMpBarsMpDirsM)

    if (
    not na(ph) or not na(pl)) and array.size(pPrices) > 1
        p1_val 
    = array.get(pPrices0)
        
    p1_bar = array.get(pBars0)
        
    p2_val = array.get(pPrices1)
        
    p2_bar = array.get(pBars1)
        
    line.new(p2_barp2_valp1_barp1_valcolor=color_upwidth=2)

    // 3. PREDICTIVE LOGIC & TABLE
    if barstate.islast
        
    for l in ghostLines
            line
    .delete(l)
        for 
    lb in ghostLabels
            label
    .delete(lb)
        array.
    clear(ghostLines)
        array.
    clear(ghostLabels)
        
        
    table.clear(infoTable00319)
        
        if 
    show_table
            table
    .cell(infoTable00"Dalga"bgcolor=color.graytext_color=color.white)
            
    table.cell(infoTable10"Fibo"bgcolor=color.graytext_color=color.white)
            
    table.cell(infoTable20"Hedef"bgcolor=color.graytext_color=color.white)
            
    table.cell(infoTable30"% +/-"bgcolor=color.graytext_color=color.white)
        
        
    int tbl_row 

        
    if array.size(pPrices) > 0
            last_conf_val 
    = array.get(pPrices0)
            
    last_conf_bar = array.get(pBars0)
            
    last_conf_dir = array.get(pDirs0)
            
            
    int bars_elapsed bar_index last_conf_bar
            float live_pivot_val 
    0.0
            int   live_pivot_bar 
    0
            bool  live_pivot_dir 
    bool(na)
            
    float live_pivot_rsi 50.0 // Default
            
            
    if last_conf_dir 
                lowest_val 
    1000000.0
                lowest_idx 
    0
                
    for 0 to bars_elapsed
                    
    if low[i] < lowest_val
                        lowest_val 
    := low[i]
                        
    lowest_idx := bar_index[i]
                        
    live_pivot_rsi := my_rsi[i// Capture RSI at lowest point
                
    live_pivot_val := lowest_val
                live_pivot_bar 
    := lowest_idx
                live_pivot_dir 
    := false 
            
    else 
                
    highest_val 0.0
                highest_idx 
    0
                
    for 0 to bars_elapsed
                    
    if high[i] > highest_val
                        highest_val 
    := high[i]
                        
    highest_idx := bar_index[i]
                        
    live_pivot_rsi := my_rsi[i// Capture RSI at highest point
                
    live_pivot_val := highest_val
                live_pivot_bar 
    := highest_idx
                live_pivot_dir 
    := true 

            float vol 
    math.abs(last_conf_val live_pivot_val)
            if 
    vol == 
                vol 
    := syminfo.mintick 100

            float rev_start_price 
    live_pivot_val
            int   rev_start_bar   
    live_pivot_bar
            
            
    // =========================================================
            // SCENARIO 1: EXTENSION
            // =========================================================
            
    float pExt na
            int   tExt 
    bar_index 10
            bool  drawing_ext 
    false

            
    if not live_pivot_dir 
                
    if show_ext_bear
                    calc_price 
    live_pivot_val - (vol 0.5)
                    
    pExt := math.max(0.01calc_price)
                    
    drawPred(live_pivot_barlive_pivot_valtExtpExt"(Stop)""0.5"color_cont2)
                    if 
    show_table
                        fillRow
    (tbl_row"Ayı Stop""0.5 Vol"pExtcolor_cont)
                        
    tbl_row += 1
                    drawing_ext 
    := true
            
    else 
                if 
    show_ext_bull
                    pExt 
    := live_pivot_val + (vol 0.5)
                    
    drawPred(live_pivot_barlive_pivot_valtExtpExt"(Stop)""0.5"color_cont2)
                    if 
    show_table
                        fillRow
    (tbl_row"Boğa Stop""0.5 Vol"pExtcolor_cont)
                        
    tbl_row += 1
                    drawing_ext 
    := true

            
    if link_scenarios and drawing_ext
                rev_start_price 
    := pExt
                rev_start_bar   
    := tExt

            
    // =========================================================
            // SCENARIO 2: REVERSAL + RSI DIVERGENCE CHECK
            // =========================================================
            
    if show_reversal
                int t_step 
    5
                
                
    // --- RSI DIVERGENCE LOGIC ---
                
    bool has_div false
                
    // Check if we have history
                
    if array.size(pPrices) > 1
                    
    // If Live is Low, compare to Previous Low (index 1)
                    
    if not live_pivot_dir 
                        prev_low_val 
    = array.get(pPrices1)
                        
    prev_low_rsi = array.get(pRSI1)
                        
    // BULLISH DIV: Lower Price + Higher RSI
                        
    if live_pivot_val prev_low_val and live_pivot_rsi prev_low_rsi
                            has_div 
    := true
                    
    // If Live is High, compare to Previous High (index 1)
                    
    else 
                        
    prev_high_val = array.get(pPrices1)
                        
    prev_high_rsi = array.get(pRSI1)
                        
    // BEARISH DIV: Higher Price + Lower RSI
                        
    if live_pivot_val prev_high_val and live_pivot_rsi prev_high_rsi
                            has_div 
    := true

                
    // Invalidation Line
                
    if show_inv
                    inv_col 
    color.red
                    inv_y   
    rev_start_price
                    l_inv   
    line.new(rev_start_barinv_yrev_start_bar 30inv_ycolor=inv_colwidth=2style=line.style_solid)
                    array.
    push(ghostLinesl_inv)
                    
                    
    // Add Lightning Bolt if Divergence Detected
                    
    inv_txt "Denge" + (has_div and show_div " ⚡" "")
                    
    inv_txt_col has_div and show_div color.yellow inv_col
                    
                    
    if show_labels
                        lb_inv 
    label.new(rev_start_bar 30inv_ytext=inv_txtcolor=color.new(color.white100), textcolor=inv_txt_colstyle=label.style_label_leftsize=size.small)
                        array.
    push(ghostLabelslb_inv)
                    
                    if 
    show_table
                        fillRow
    (tbl_row"Geçersiz", (has_div and show_div "DIV ⚡" "Start"), inv_ycolor.red)
                        
    tbl_row += 1

                
    if not live_pivot_dir 
                    p1 
    math.max(0.01rev_start_price + (vol 0.382))
                    
    t1 rev_start_bar 
                    drawPred
    (rev_start_barrev_start_pricet1p1"(1)""0.382"color_rev2)
                    if 
    show_table
                        fillRow
    (tbl_row"Wave 1""0.382"p1color_rev)
                        
    tbl_row += 1
                    
                    p2 
    math.max(0.01p1 - ((p1 rev_start_price) * 0.618))
                    
    t2 t1 t_step
                    drawPred
    (t1p1t2p2"(2)""0.618"color_rev2)
                    if 
    show_table
                        fillRow
    (tbl_row"Wave 2""0.618"p2color_rev)
                        
    tbl_row += 1
                    
                    p3 
    math.max(0.01p2 + ((p1 rev_start_price) * 1.618))
                    
    t3 t2 t_step
                    drawPred
    (t2p2t3p3"(3)""1.618"color_rev2)
                    if 
    show_table
                        fillRow
    (tbl_row"Wave 3""1.618"p3color_rev)
                        
    tbl_row += 1

                    p4 
    math.max(0.01p3 - ((p3 p2) * 0.382))
                    
    t4 t3 t_step
                    drawPred
    (t3p3t4p4"(4)""0.382"color_rev2)
                    if 
    show_table
                        fillRow
    (tbl_row"Wave 4""0.382"p4color_rev)
                        
    tbl_row += 1

                    p5 
    math.max(0.01p4 + (p1 rev_start_price))
                    
    t5 t4 t_step
                    drawPred
    (t4p4t5p5"(5)""1.0"color_rev2)
                    if 
    show_table
                        fillRow
    (tbl_row"Wave 5""1.0"p5color_rev)
                        
    tbl_row += 1
                    
                
    else 
                    
    pA math.max(0.01rev_start_price - (vol 0.382))
                    
    tA rev_start_bar 5
                    drawPred
    (rev_start_barrev_start_pricetApA"(A)""0.382"color_rev2)
                    if 
    show_table
                        fillRow
    (tbl_row"A""0.382"pAcolor_rev)
                        
    tbl_row += 1

                    pB 
    math.max(0.01pA + ((rev_start_price pA) * 0.618))
                    
    tB tA t_step
                    drawPred
    (tApAtBpB"(B)""0.618"color_rev2)
                    if 
    show_table
                        fillRow
    (tbl_row"B""0.618"pBcolor_rev)
                        
    tbl_row += 1

                    pC 
    math.max(0.01pB - ((rev_start_price pA) * 1.272))
                    
    tC tB t_step
                    drawPred
    (tBpBtCpC"(C)""1.272"color_rev2)
                    if 
    show_table
                        fillRow
    (tbl_row"C""1.272"pCcolor_rev)
                        
    tbl_row += 1

        
    // =========================================================
        // SCENARIO 3: MACRO
        // =========================================================
        
    if show_macro and array.size(pPricesM) > 0
            last_M_val 
    = array.get(pPricesM0)
            
    last_M_bar = array.get(pBarsM0)
            
    last_M_dir = array.get(pDirsM0)
            
            
    int M_elapsed bar_index last_M_bar
            float live_M_val 
    0.0
            int   live_M_bar 
    0
            bool  live_M_dir 
    bool(na)
            
            if 
    last_M_dir 
                lowest_val 
    1000000.0
                lowest_idx 
    0
                
    for 0 to M_elapsed
                    
    if low[i] < lowest_val
                        lowest_val 
    := low[i]
                        
    lowest_idx := bar_index[i]
                
    live_M_val := lowest_val
                live_M_bar 
    := lowest_idx
                live_M_dir 
    := false 
            
    else 
                
    highest_val 0.0
                highest_idx 
    0
                
    for 0 to M_elapsed
                    
    if high[i] > highest_val
                        highest_val 
    := high[i]
                        
    highest_idx := bar_index[i]
                
    live_M_val := highest_val
                live_M_bar 
    := highest_idx
                live_M_dir 
    := true 

            float volM 
    math.abs(last_M_val live_M_val)
            if 
    volM == 
                volM 
    := syminfo.mintick 100

            int t_step_M 
    macro_spacing
            
            
    if show_table
                table
    .cell(infoTable0tbl_row"MACRO (1Y)"bgcolor=color.graytext_color=color.white)
                
    table.merge_cells(infoTable0tbl_row3tbl_row)
                
    tbl_row += 1

            
    if not live_M_dir 
                p1 
    math.max(0.01live_M_val + (volM 0.382))
                
    t1 live_M_bar t_step_M
                drawPred
    (live_M_barlive_M_valt1p1"M(1)""Start"color_macro4)
                if 
    show_table
                    fillRow
    (tbl_row"M1""Start"p1color_macro)
                    
    tbl_row += 1
                
                p2 
    math.max(0.01p1 - ((p1 live_M_val) * 0.618))
                
    t2 t1 t_step_M
                drawPred
    (t1p1t2p2"M(2)""0.618"color_macro4)
                if 
    show_table
                    fillRow
    (tbl_row"M2""0.618"p2color_macro)
                    
    tbl_row += 1
                
                p3 
    math.max(0.01p2 + ((p1 live_M_val) * 1.618))
                
    t3 t2 t_step_M
                drawPred
    (t2p2t3p3"M(3)""1.618"color_macro4)
                if 
    show_table
                    fillRow
    (tbl_row"M3""1.618"p3color_macro)
                    
    tbl_row += 1

                p4 
    math.max(0.01p3 - ((p3 p2) * 0.382))
                
    t4 t3 t_step_M
                drawPred
    (t3p3t4p4"M(4)""0.382"color_macro4)
                if 
    show_table
                    fillRow
    (tbl_row"M4""0.382"p4color_macro)
                    
    tbl_row += 1

                p5 
    math.max(0.01p4 + (p1 live_M_val))
                
    t5 t4 t_step_M
                drawPred
    (t4p4t5p5"M(5)""1.0"color_macro4)
                if 
    show_table
                    fillRow
    (tbl_row"M5""1.0"p5color_macro)
                    
    tbl_row += 1
                
            
    else 
                
    pA math.max(0.01live_M_val - (volM 0.382))
                
    tA live_M_bar t_step_M
                drawPred
    (live_M_barlive_M_valtApA"M(A)""Start"color_macro4)
                if 
    show_table
                    fillRow
    (tbl_row"Macro A""Start"pAcolor_macro)
                    
    tbl_row += 1

                pB 
    math.max(0.01pA + ((live_M_val pA) * 0.618))
                
    tB tA t_step_M
                drawPred
    (tApAtBpB"M(B)""0.618"color_macro4)
                if 
    show_table
                    fillRow
    (tbl_row"Macro B""0.618"pBcolor_macro)
                    
    tbl_row += 1

                pC 
    math.max(0.01pB - ((live_M_val pA) * 1.272))
                
    tC tB t_step_M
                drawPred
    (tBpBtCpC"M(C)""1.272"color_macro4)
                if 
    show_table
                    fillRow
    (tbl_row"Macro C""1.272"pCcolor_macro)
                    
    tbl_row += 
    16.07.2024 - 10.12.2024

  8. PHP Code:
    //@version=6
    indicator('.'overlay true)

    showBreakLabels input.bool(truetitle 'Show breakouts'group 'Breakout Labels')
    showVolumeBreakLabels input.bool(truetitle 'Show Breakouts with high volume'group 'Breakout Labels')

    timeframe input.timeframe(''title 'Timeframe')
    [
    OpenHighLowCloseVolume] = request.security(syminfo.tickeridtimeframe, [openhighlowclosevolume])

    start44 input(0.title 'start'group 'Parabolic SAR')
    increment44 input(0.01title 'Increment'group 'Parabolic SAR')
    maximum44 input(0.9'Max Value'group 'Parabolic SAR')

    out44 request.security(syminfo.tickeridtimeframeta.sar(start44increment44maximum44), gaps barmerge.gaps_off)

    sarChange ta.change(out44 High)

    var 
    prevSar out44

    if sarChange
        prevSar 
    := out44[1] + out44[1] / 100 0.01
        prevSar

    crossOverLong 
    out44 Close and Close Open and (ta.crossover(CloseprevSar) or ta.crossover(Close[1], prevSar))
    crossOverShort out44 Close and Close Open and ta.crossunder(CloseprevSar)

    plot(sarChange na prevSarstyle plot.style_linebroffset = -1color out44 high color.new(color.aqua0) : color.new(color.lime0), title 'KRL'linewidth 1)
    plot(out44'SAR'style plot.style_steplinebrcolor color.new(color.yellow0))
    /////////////////////// 
    16.07.2024 - 10.12.2024

Sayfa 360/363 İlkİlk ... 260310350358359360361362 ... SonSon

Yer İmleri

Yer İmleri

Gönderi Kuralları

  • Yeni konu açamazsınız
  • Konulara cevap yazamazsınız
  • Yazılara ek gönderemezsiniz
  • Yazılarınızı değiştiremezsiniz
  •