Sayfa 309/309 İlkİlk ... 209259299307308309
Arama sonucu : 2472 madde; 2,465 - 2,472 arası.

Konu: Tradingview

  1. https://tr.tradingview.com/script/IU...ntile-Rank-SS/

    seçeceğiniz ema değerine göre range hesabını yüzdeyle...çift yönlü yapıyor...destek direnç misali...

  2. https://tr.tradingview.com/script/zy8EETop/
    bilinen 50 patterni tarıyor... açıklamalı...

    ayarlamalı.....
    â—† Recommended Settings
    Scalping: Detection period 20, Sensitivity 0.0025
    Day Trading: Detection period 50, Sensitivity 0.002
    Swing Trading: Detection period 100, Sensitivity 0.0015

    örnek...
    https://www.tradingview.com/x/b6f1Ecga/ day trade ayarıyla endeks saatlikte düşüş diyor...

    scalp olursa... https://www.tradingview.com/x/GjAlejkF/ yükseliş...

    swing olursa... https://www.tradingview.com/x/J6rwKRN2/ bekle diyor...

    bunu denemeli.... ve kodu türkçeleştirelim...


  3. https://tr.tradingview.com/u/ata_sab...lished-scripts

    kodları incelenecek....

    çünkü https://www.tradingview.com/x/SMnUrRtV/ bu kodu editörler seçmiş....

    tam matematiksel..... hacim analizi ancak böyle yapılır.... helal olsun....

  4.  Alıntı Originally Posted by @yörük@ Yazıyı Oku
    https://tr.tradingview.com/script/zy8EETop/
    bilinen 50 patterni tarıyor... açıklamalı...

    ayarlamalı.....
    â—† Recommended Settings
    Scalping: Detection period 20, Sensitivity 0.0025
    Day Trading: Detection period 50, Sensitivity 0.002
    Swing Trading: Detection period 100, Sensitivity 0.0015

    örnek...
    https://www.tradingview.com/x/b6f1Ecga/ day trade ayarıyla endeks saatlikte düşüş diyor...

    scalp olursa... https://www.tradingview.com/x/GjAlejkF/ yükseliş...

    swing olursa... https://www.tradingview.com/x/J6rwKRN2/ bekle diyor...

    bunu denemeli.... ve kodu türkçeleştirelim...
    day trading için...
    PHP Code:
    //@version=6
    indicator("."overlay=truemax_bars_back=500)

    // ============================================
    // INPUT PARAMETERS
    // ============================================
    g1 "ARAMA AYARLARI"
    lookback input.int(50"MODEL PERİYOT"minval=20maxval=200group=g1)
    sensitivity input.float(0.002"DUYARLILIK"minval=0.0005maxval=0.01step=0.0005group=g1)
    min_touches input.int(2"TEST ADET"minval=2maxval=5group=g1)

    g2 "KLASİK MODELLER"
    detect_classic input.bool(true"▼ KLASİK MODELLER"group=g2)
    classic_double input.bool(true"├ İKİLİ TEPE/DİP"group=g2)
    classic_triple input.bool(true"├ ÜÇLÜ TEPE/DİP"group=g2)
    classic_hs input.bool(true"├ BAŞ & OMUZLAR"group=g2)
    classic_rounding input.bool(true"└ YUVARLAMA"group=g2)

    g3 "ÜÇGEN MODELLER"
    detect_triangles input.bool(true"▼ ÜÇGEN MODELLER"group=g3)
    tri_ascending input.bool(true"├ YÜKSELEN ÜÇGEN"group=g3)
    tri_descending input.bool(true"├ ALÇALAN ÜÇGEN"group=g3)
    tri_symmetrical input.bool(true"├ SİMETRİK ÜÇGEN"group=g3)
    tri_expanding input.bool(true"└ GENİŞLEYEN ÜÇGEN"group=g3)

    g4 "DEVAM MODELLERİ"
    detect_continuation input.bool(true"▼ DEVAM MODELLERİ"group=g4)
    cont_flag input.bool(true"├ FLAMA"group=g4)
    cont_pennant input.bool(true"├ FLAMALAR"group=g4)
    cont_wedge input.bool(true"├ TAKOZLAR"group=g4)
    cont_channel input.bool(true"├ KANALLAR"group=g4)
    cont_rectangle input.bool(true"└ DİKDÖRTGENLER"group=g4)

    g5 "HARMONİK MODELLER"
    detect_harmonic input.bool(true"▼ HARMONİK MODELLER"group=g5)
    harm_gartley input.bool(true"├ FİBO"group=g5)
    harm_butterfly input.bool(true"├ KELEBEK"group=g5)
    harm_bat input.bool(true"├ YARASA"group=g5)
    harm_crab input.bool(true"├ YENGEÇ"group=g5)
    harm_shark input.bool(true"├ KÖPEKBALIĞI"group=g5)
    harm_cypher input.bool(true"└ DÖRTLÜ"group=g5)

    g6 "FİYAT MODELLERİ"
    detect_price_action input.bool(true"▼ FİYAT MODELLERİ"group=g6)
    pa_pin_bar input.bool(true"├ PİN BAR"group=g6)
    pa_inside input.bool(true"├ İÇ BAR"group=g6)
    pa_outside input.bool(true"├ DIŞ BAR"group=g6)
    pa_engulfing input.bool(true"├ YUTMA"group=g6)
    pa_doji input.bool(true"├ DOJİ"group=g6)
    pa_hammer input.bool(true"└ ÇEKİÇ"group=g6)

    g7 "ÖZEL MODELLER"
    detect_special input.bool(true"▼ ÖZEL MODELLER"group=g7)
    spec_diamond input.bool(true"├ ELMAS"group=g7)
    spec_cup input.bool(true"├ FİNCAN & KULP"group=g7)
    spec_vbottom input.bool(true"├ V-DİP/ZİRVE"group=g7)
    spec_broadening input.bool(true"├ GENİŞLEME"group=g7)
    spec_island input.bool(true"└ ADA DÖNÜŞ"group=g7)

    g8 "AYARLAR"
    show_patterns input.bool(true"MODEL"group=g8)
    show_confidence input.bool(true"OLASILIK"group=g8)
    show_table input.bool(true"ARAMA"group=g8)
    show_explanation input.bool(true"SEBEP"group=g8)
    show_pivot_points input.bool(true"PİVOT"group=g8)
    show_key_levels input.bool(true"GİRİŞ"group=g8)
    show_targets input.bool(true"HEDEF"group=g8)
    max_patterns input.int(5"SAYIM"minval=1maxval=10group=g8)

    g9 "Panel Position Settings"
    table_position input.string("top_right""Detection Table Position"options=["top_left""top_center""top_right""middle_left""middle_center""middle_right""bottom_left""bottom_center""bottom_right"], group=g9)
    explanation_position input.string("middle_right""Explanation Panel Position"options=["top_left""top_center""top_right""middle_left""middle_center""middle_right""bottom_left""bottom_center""bottom_right"], group=g9)
    panel_transparency input.int(80"Panel Transparency"minval=0maxval=100group=g9)
    panel_text_size input.string("normal""Text Size"options=["tiny""small""normal""large""huge"], group=g9)

    // ============================================
    // GLOBAL VARIABLES & STRUCTURES
    // ============================================
    type PatternInfo
        string name
        string direction  
    // bullish/bearish/neutral
        
    float confidence
        int start_bar
        int end_bar
        float level1
        float level2

    var array<PatternInfodetected_patterns = array.new<PatternInfo>()
    var 
    table pattern_table na
    var table explanation_table na
    var line[] pattern_lines = array.new_line()
    var 
    label[] pattern_labels = array.new_label()
    var 
    box[] pattern_boxes = array.new_box()

    // Position conversion function
    get_table_position(pos_string) =>
        switch 
    pos_string
            
    "top_left" => position.top_left
            
    "top_center" => position.top_center
            
    "top_right" => position.top_right
            
    "middle_left" => position.middle_left
            
    "middle_center" => position.middle_center
            
    "middle_right" => position.middle_right
            
    "bottom_left" => position.bottom_left
            
    "bottom_center" => position.bottom_center
            
    "bottom_right" => position.bottom_right
            
    => position.top_right

    // Table initialization
    if barstate.isfirst or barstate.isconfirmed
        
    if not na(pattern_table)
            
    table.delete(pattern_table)
        if 
    not na(explanation_table)
            
    table.delete(explanation_table)
        
        if 
    show_table
            pattern_table 
    := table.new(get_table_position(table_position), 4max_patterns 1bgcolor=color.new(color.blackpanel_transparency))
        if 
    show_explanation
            explanation_table 
    := table.new(get_table_position(explanation_position), 2max_patterns 1bgcolor=color.new(color.blackpanel_transparency), border_width=2)

    // ============================================
    // BASIC CALCULATIONS
    // ============================================
    highest_price ta.highest(highlookback)
    lowest_price ta.lowest(lowlookback)
    mid_price = (highest_price lowest_price) / 2

    // ATR for volatility
    atr ta.atr(14)
    volatility atr close

    // ============================================
    // PATTERN DETECTION FUNCTIONS
    // ============================================

    // Pivot detection
    findPivotPoints(len) =>
        var 
    pivotHighs = array.new_float()
        var 
    pivotLows = array.new_float()
        var 
    pivotHighBars = array.new_int()
        var 
    pivotLowBars = array.new_int()
        
        for 
    len to lookback len
            isHigh 
    true
            isLow 
    true
            
    for = -len to len
                
    if high[i+j] > high[i]
                    
    isHigh := false
                
    if low[i+j] < low[i]
                    
    isLow := false
            
            
    if isHigh
                
    array.push(pivotHighshigh[i])
                array.
    push(pivotHighBarsi)
            if 
    isLow
                
    array.push(pivotLowslow[i])
                array.
    push(pivotLowBarsi)
        
        [
    pivotHighspivotLowspivotHighBarspivotLowBars]

    // Fibonacci ratio check
    checkFibRatio(val1val2target_ratiotolerance) =>
        
    ratio val2 val1
        math
    .abs(ratio target_ratio) < tolerance

    // 1. Double Top/Bottom Detection
    detectDoublePatterns() =>
        if 
    not detect_classic or not classic_double
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            
    // Double Top
            
    if array.size(highs) >= 2
                
    for 0 to math.min(array.size(highs) - 210)
                    
    h1 = array.get(highsi)
                    
    h2 = array.get(highs1)
                    
    diff math.abs(h1 h2) / h1
                    
                    
    if diff sensitivity
                        neckline 
    lowest_price
                        
    if close neckline 0.995
                            PatternInfo
    .new("İKİLİ TEPE""AYI"85bar_index lookbackbar_indexh1neckline)
            
            
    // Double Bottom
            
    if array.size(lows) >= 2
                
    for 0 to math.min(array.size(lows) - 210)
                    
    l1 = array.get(lowsi)
                    
    l2 = array.get(lows1)
                    
    diff math.abs(l1 l2) / l1
                    
                    
    if diff sensitivity
                        neckline 
    highest_price
                        
    if close neckline 1.005
                            PatternInfo
    .new("İKİLİ DİP""BOĞA"85bar_index lookbackbar_indexnecklinel1)
            
            
    PatternInfo.new(""""00000)

    // 2. Triple Top/Bottom
    detectTriplePatterns() =>
        if 
    not detect_classic or not classic_triple
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= 3
                
    for 0 to math.min(array.size(highs) - 35)
                    
    h1 = array.get(highsi)
                    
    h2 = array.get(highs1)
                    
    h3 = array.get(highs2)
                    
                    
    diff1 math.abs(h1 h2) / h1
                    diff2 
    math.abs(h2 h3) / h2
                    
                    
    if diff1 sensitivity and diff2 sensitivity
                        PatternInfo
    .new("ÜÇLÜ TEPE""AYI"90bar_index lookbackbar_indexh1lowest_price)
            
            
    PatternInfo.new(""""00000)

    // 3. Head & Shoulders
    detectHeadShoulders() =>
        if 
    not detect_classic or not classic_hs
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= 3
                
    for 0 to math.min(array.size(highs) - 35)
                    
    left = array.get(highsi)
                    
    head = array.get(highs1)
                    
    right = array.get(highs2)
                    
                    if 
    head left and head right
                        shoulder_diff 
    math.abs(left right) / left
                        
    if shoulder_diff sensitivity 2
                            PatternInfo
    .new("BAŞ & OMUZLAR""AYI"88bar_index lookbackbar_indexheadmath.min(leftright))
            
            if array.
    size(highs) >= 5
                
    for 0 to math.min(array.size(highs) - 53)
                    
    ls1 = array.get(highsi)
                    
    ls2 = array.get(highs1)
                    
    head = array.get(highs2)
                    
    rs1 = array.get(highs3)
                    
    rs2 = array.get(highs4)
                    
                    
    avg_left = (ls1 ls2) / 2
                    avg_right 
    = (rs1 rs2) / 2
                    
                    
    if head avg_left and head avg_right
                        PatternInfo
    .new("BAŞ OMUZ""AYI"82bar_index lookbackbar_indexheadmath.min(avg_leftavg_right))
            
            
    PatternInfo.new(""""00000)

    // 4. Triangle Patterns
    detectTriangles() =>
        if 
    not detect_triangles
            PatternInfo
    .new(""""00000)
        else
            
    upper_trend ta.linreg(highlookback0) - ta.linreg(highlookbacklookback 1)
            
    lower_trend ta.linreg(lowlookback0) - ta.linreg(lowlookbacklookback 1)
            
            
    range_start highest_price lowest_price
            range_end 
    high low
            converging 
    range_end range_start 0.7
            diverging 
    range_end range_start 1.3
            
            
    if tri_ascending and math.abs(upper_trend) < volatility and lower_trend volatility and converging
                PatternInfo
    .new("YÜKSELEN ÜÇGEN""BOĞA"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_descending and upper_trend < -volatility and math.abs(lower_trend) < volatility and converging
                PatternInfo
    .new("ALÇALAN ÜÇGEN""AYI"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_symmetrical and math.abs(upper_trend lower_trend) < volatility and converging
                PatternInfo
    .new("SİMETRİK ÜÇGEN""BEKLE"75bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_expanding and diverging
                PatternInfo
    .new("GENİŞLEYEN ÜÇGEN""BEKLE"72bar_index lookbackbar_indexhighest_pricelowest_price)
            else
                
    PatternInfo.new(""""00000)

    // 5. Wedge Patterns
    detectWedges() =>
        if 
    not detect_continuation or not cont_wedge
            PatternInfo
    .new(""""00000)
        else
            
    upper_slope = (highest_price highest_price[lookback-1]) / lookback
            lower_slope 
    = (lowest_price lowest_price[lookback-1]) / lookback
            
            converging 
    = (high low) < (highest_price[lookback-1] - lowest_price[lookback-1]) * 0.7
            
            
    if upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("YÜKSELEN TAKOZ""AYI"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("DÜŞEN TAKOZ""BOĞA"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    math.abs(upper_slope) > volatility and math.abs(lower_slope) > volatility 2
                
    if upper_slope and lower_slope 0
                    PatternInfo
    .new("GENİŞLEYEN KAMA""AYI"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else if 
    upper_slope and lower_slope 0
                    PatternInfo
    .new("DARALAN KAMA""BOĞA"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 6. Flags & Pennants
    detectFlagsAndPennants() =>
        if 
    not detect_continuation or not (cont_flag or cont_pennant)
            
    PatternInfo.new(""""00000)
        else
            
    prior_trend close[lookback] - close[lookback 2]
            
    recent_slope ta.linreg(close100) - ta.linreg(close109)
            
    recent_high ta.highest(high10)
            
    recent_low ta.lowest(low10)
            
    recent_range recent_high recent_low
            prior_range 
    ta.highest(high20)[10] - ta.lowest(low20)[10]
            
            
    is_consolidation recent_range prior_range 0.5
            
            
    if cont_flag and is_consolidation
                
    if prior_trend and recent_slope 0
                    PatternInfo
    .new("FLAMA""BOĞA"74bar_index 10bar_indexrecent_highrecent_low)
                else if 
    prior_trend and recent_slope 0
                    PatternInfo
    .new("FLAMA""AYI"74bar_index 10bar_indexrecent_highrecent_low)
                else if 
    math.abs(recent_slope) < volatility
                    PatternInfo
    .new("FLAMA YATAY""BEKLE"72bar_index 10bar_indexrecent_highrecent_low)
                else
                    
    PatternInfo.new(""""00000)
            
            else if 
    cont_pennant and is_consolidation and recent_range recent_range[5] * 0.7
                
    if prior_trend 0
                    PatternInfo
    .new("BOĞA""BOĞA"73bar_index 10bar_indexrecent_highrecent_low)
                else if 
    prior_trend 0
                    PatternInfo
    .new("AYI""AYI"73bar_index 10bar_indexrecent_highrecent_low)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 7. Harmonic Patterns (simplified)
    detectHarmonicPatterns() =>
        if 
    not detect_harmonic
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= and array.size(lows) >= 3
                X 
    = array.get(lows0)
                
    = array.get(highs0)
                
    = array.get(lows1)
                
    = array.get(highs1)
                
    close
                
                XA 
    X
                AB 
    B
                BC 
    B
                CD 
    D
                
                
    if harm_gartley and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC0.7860.05)
                    
    PatternInfo.new("FİBO""BOĞA"80bar_index lookbackbar_indexCD)
                else if 
    harm_butterfly and checkFibRatio(XAAB0.7860.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("KELEBEK""BOĞA"78bar_index lookbackbar_indexCD)
                else if 
    harm_bat and checkFibRatio(XAAB0.3820.05) and checkFibRatio(ABBC0.8860.05)
                    
    PatternInfo.new("YARASA""BOĞA"77bar_index lookbackbar_indexCD)
                else if 
    harm_crab and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("YENGEÇ""BOĞA"76bar_index lookbackbar_indexCD)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 8. Price Action Patterns
    detectPriceAction() =>
        if 
    not detect_price_action
            PatternInfo
    .new(""""00000)
        else
            
    body math.abs(close open)
            
    upper_shadow high math.max(openclose)
            
    lower_shadow math.min(openclose) - low
            prev_body 
    math.abs(close[1] - open[1])
            
    avg_body ta.sma(math.abs(close open), 20)
            
    sma20 ta.sma(close20)
            
            if 
    pa_pin_bar and (upper_shadow body or lower_shadow body 2)
                
    direction lower_shadow upper_shadow "BOĞA" "AYI"
                
    PatternInfo.new("Pin Bar"direction70bar_indexbar_indexhighlow)
            else if 
    pa_inside and high high[1] and low low[1]
                
    PatternInfo.new("İÇ BAR""BEKLE"68bar_index 1bar_indexhigh[1], low[1])
            else if 
    pa_outside and high high[1] and low low[1]
                
    PatternInfo.new("DIŞ BAR""BEKLE"68bar_index 1bar_indexhighlow)
            else if 
    pa_engulfing and body prev_body 1.5
                
    if close open and close high[1] and open low[1]
                    
    PatternInfo.new("BOĞA YUTAN""BOĞA"72bar_index 1bar_indexhighlow)
                else if 
    close open and close low[1] and open high[1]
                    
    PatternInfo.new("AYI YUTAN""AYI"72bar_index 1bar_indexhighlow)
                else
                    
    PatternInfo.new(""""00000)
            else if 
    pa_doji and body avg_body 0.1
                
    if upper_shadow avg_body and lower_shadow avg_body
                    PatternInfo
    .new("Doji""BEKLE"65bar_indexbar_indexhighlow)
                else if 
    upper_shadow lower_shadow 2
                    PatternInfo
    .new("EJDERHA""BOĞA"66bar_indexbar_indexhighlow)
                else if 
    lower_shadow upper_shadow 2
                    PatternInfo
    .new("MEZARTAŞI""AYI"66bar_indexbar_indexhighlow)
                else
                    
    PatternInfo.new(""""00000)
            else if 
    pa_hammer and lower_shadow body and upper_shadow body 0.3
                
    if close sma20
                    PatternInfo
    .new("ÇEKİÇ""BOĞA"69bar_indexbar_indexhighlow)
                else
                    
    PatternInfo.new("ÇEKİÇ""AYI"69bar_indexbar_indexhighlow)
            else
                
    PatternInfo.new(""""00000)

    // 9. Special Patterns
    detectSpecialPatterns() =>
        if 
    not detect_special
            PatternInfo
    .new(""""00000)
        else
            if 
    spec_cup
                cup_depth 
    lowest_price[20] < lowest_price 0.85
                cup_recovery 
    close highest_price[20] * 0.95
                handle_forming 
    high highest_price[5] * 0.98
                
                
    if cup_depth and cup_recovery and handle_forming
                    PatternInfo
    .new("FİNCAN & KULP""BOĞA"82bar_index 30bar_indexhighest_pricelowest_price)
            
            if 
    spec_vbottom
                sharp_decline 
    lowest_price lowest_price[10] * 0.9
                sharp_recovery 
    close highest_price[5] * 0.95
                
                
    if sharp_decline and sharp_recovery
                    PatternInfo
    .new("V-DİP""BOĞA"75bar_index 10bar_indexhighest_price[10], lowest_price)
                else if 
    close lowest_price[5] * 1.05 and highest_price highest_price[10] * 1.1
                    PatternInfo
    .new("V-ZİRVE""AYI"75bar_index 10bar_indexhighest_pricelowest_price[10])
                else
                    
    PatternInfo.new(""""00000)
            
            else if 
    spec_diamond
                mid_expand 
    = (ta.highest(high25)[12] - ta.lowest(low25)[12]) > (ta.highest(high50)[25] - ta.lowest(low50)[25]) * 1.2
                end_contract 
    = (high low) < (ta.highest(high25)[12] - ta.lowest(low25)[12]) * 0.7
                
                
    if mid_expand and end_contract
                    PatternInfo
    .new("ELMAS""BEKLE"77bar_index lookbackbar_indexhighest_pricelowest_price)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // ============================================
    // MAIN PROCESSING
    // ============================================

    // Clear detected patterns
    array.clear(detected_patterns)

    // Execute detection functions
    patterns_to_check = array.new<PatternInfo>()
    array.
    push(patterns_to_checkdetectDoublePatterns())
    array.
    push(patterns_to_checkdetectTriplePatterns())
    array.
    push(patterns_to_checkdetectHeadShoulders())
    array.
    push(patterns_to_checkdetectTriangles())
    array.
    push(patterns_to_checkdetectWedges())
    array.
    push(patterns_to_checkdetectFlagsAndPennants())
    array.
    push(patterns_to_checkdetectHarmonicPatterns())
    array.
    push(patterns_to_checkdetectPriceAction())
    array.
    push(patterns_to_checkdetectSpecialPatterns())

    // Keep only valid patterns
    for 0 to array.size(patterns_to_check) - 1
        pattern 
    = array.get(patterns_to_checki)
        if 
    pattern.name != ""
            
    array.push(detected_patternspattern)

    // Sort by confidence (descending)
    if array.size(detected_patterns) > 1
        
    for 0 to array.size(detected_patterns) - 2
            
    for 0 to array.size(detected_patterns) - 2
                
    if < array.size(detected_patterns)
                    if array.
    get(detected_patternsj).confidence < array.get(detected_patterns1).confidence
                        temp 
    = array.get(detected_patternsj)
                        array.
    set(detected_patternsj, array.get(detected_patterns1))
                        array.
    set(detected_patterns1temp)

    // ============================================
    // VISUALIZATION
    // ============================================

    // Clear old drawings
    if barstate.islast
        
    for line in pattern_lines
            line
    .delete(line)
        array.
    clear(pattern_lines)
        
        for 
    lbl in pattern_labels
            label
    .delete(lbl)
        array.
    clear(pattern_labels)
        
        for 
    bx in pattern_boxes
            box
    .delete(bx)
        array.
    clear(pattern_boxes)

    // Draw patterns
    if show_patterns and barstate.islast and array.size(detected_patterns) > 0
        display_count 
    math.min(array.size(detected_patterns), max_patterns)
        for 
    0 to display_count 1
            pattern 
    = array.get(detected_patternsi)
            
            
    // Color settings
            
    pattern_color = switch pattern.direction
                
    "BOĞA" => color.new(color.lime20)
                
    "AYI" => color.new(color.red20)
                => 
    color.new(color.yellow20)
            
            
    // Target price calculation
            
    float target_price na
            float target_distance 
    0.0
            string target_label_text 
    ""
            
            
    // Pattern-specific drawing
            
    if str.contains(pattern.name"İKİLİ") or str.contains(pattern.name"ÜÇLÜ")
                [
    highslowshighBarslowBars] = findPivotPoints(5)
                if array.
    size(highs) >= 2
                    
    for 0 to math.min(array.size(highs) - 13)
                        
    high_point = array.get(highsj)
                        
    high_bar bar_index - array.get(highBarsj)
                        
    circle_label label.new(high_barhigh_point 1.01"●"color=color.new(color.red0), textcolor=color.redstyle=label.style_label_centersize=size.tiny)
                        array.
    push(pattern_labelscircle_label)
                if array.
    size(lows) >= 2
                    
    for 0 to math.min(array.size(lows) - 13)
                        
    low_point = array.get(lowsj)
                        
    low_bar bar_index - array.get(lowBarsj)
                        
    circle_label label.new(low_barlow_point 0.99"●"color=color.new(color.green0), textcolor=color.greenstyle=label.style_label_centersize=size.tiny)
                        array.
    push(pattern_labelscircle_label)
                
                
    // Neckline
                
    neckline str.contains(pattern.name"ZİRVE") ? pattern.level2 pattern.level1
                neck_line 
    line.new(pattern.start_barnecklinepattern.end_bar 10necklinecolor=color.new(color.orange0), width=2style=line.style_solid)
                array.
    push(pattern_linesneck_line)
                
    neck_label label.new(pattern.end_bar 5neckline"BOYUN"color=color.new(color.orange80), textcolor=color.whitestyle=label.style_label_leftsize=size.tiny)
                array.
    push(pattern_labelsneck_label)
                
                
    // Target calculation
                
    if str.contains(pattern.name"ZİRVE")
                    
    target_distance pattern.level1 neckline
                    target_price 
    := neckline target_distance
                    target_label_text 
    := "HEDEF ↓"
                
    else
                    
    target_distance neckline pattern.level2
                    target_price 
    := neckline target_distance
                    target_label_text 
    := "HEDEF ↑"
            
            
    else if str.contains(pattern.name"ÜÇGENLER") or str.contains(pattern.name"TAKOZLAR")
                
    upper_line line.new(pattern.start_barpattern.level1pattern.end_barpattern.level1 - (pattern.level1 pattern.level2) * 0.3color=pattern_colorwidth=2style=line.style_solid)
                
    lower_line line.new(pattern.start_barpattern.level2pattern.end_barpattern.level2 + (pattern.level1 pattern.level2) * 0.3color=pattern_colorwidth=2style=line.style_solid)
                array.
    push(pattern_linesupper_line)
                array.
    push(pattern_lineslower_line)
                
                
    convergence_label label.new(pattern.end_bar 5, (pattern.level1 pattern.level2) / 2str.contains(pattern.name"GENİŞLEYEN") ? "GENİŞLEYEN→" "←DARALAN→"color=color.new(pattern_color80), textcolor=color.whitestyle=label.style_label_centersize=size.tiny)
                array.
    push(pattern_labelsconvergence_label)
                
                
    // Target calculation
                
    pattern_height pattern.level1 pattern.level2
                
    if pattern.direction == "BOĞA"
                    
    target_price := pattern.level1 pattern_height
                    target_label_text 
    := "HEDEF ↑"
                
    else if pattern.direction == "AYI"
                    
    target_price := pattern.level2 pattern_height
                    target_label_text 
    := "HEDEF ↓"
                
    else
                    
    target_price := close > (pattern.level1 pattern.level2) / pattern.level1 pattern_height pattern.level2 pattern_height
                    target_label_text 
    := "HEDEF"
            
            
    else if str.contains(pattern.name"BAŞ") and str.contains(pattern.name"OMUZLAR")
                [
    highslowshighBarslowBars] = findPivotPoints(5)
                if array.
    size(highs) >= 3
                    max_high_idx 
    0
                    max_high_val 
    0.0
                    
    for 0 to math.min(array.size(highs) - 14)
                        if array.
    get(highsj) > max_high_val
                            max_high_val 
    := array.get(highsj)
                            
    max_high_idx := j
                    
                    head_bar 
    bar_index - array.get(highBarsmax_high_idx)
                    
    head_label label.new(head_barmax_high_val 1.01"BAŞ"color=color.redtextcolor=color.whitestyle=label.style_label_downsize=size.small)
                    array.
    push(pattern_labelshead_label)
                    
                    for 
    0 to math.min(array.size(highs) - 14)
                        if 
    != max_high_idx
                            shoulder_bar 
    bar_index - array.get(highBarsj)
                            
    shoulder_val = array.get(highsj)
                            
    shoulder_label label.new(shoulder_barshoulder_val 1.01"S"color=color.orangetextcolor=color.whitestyle=label.style_label_downsize=size.tiny)
                            array.
    push(pattern_labelsshoulder_label)
                    
                    
    // Target calculation
                    
    neckline_hs pattern.level2
                    head_distance 
    max_high_val neckline_hs
                    target_price 
    := neckline_hs head_distance
                    target_label_text 
    := "HEDEF ↓"
            
            
    else if str.contains(pattern.name"FLAMA") or str.contains(pattern.name"FLAMALAR")
                
    pole_start pattern.start_bar 20
                pole_end 
    pattern.start_bar
                pole_line 
    line.new(pole_startlowest_price[20], pole_endhighest_pricecolor=color.new(color.blue50), width=3style=line.style_solid)
                array.
    push(pattern_linespole_line)
                
    pole_label label.new(pole_start, (highest_price lowest_price[20]) / 2"@YÖRÜK@"color=color.bluetextcolor=color.whitestyle=label.style_label_rightsize=size.tiny)
                array.
    push(pattern_labelspole_label)
                
                
    flag_box box.new(pattern.start_barpattern.level1pattern.end_barpattern.level2bgcolor=color.new(pattern_color90), border_color=pattern_colorborder_width=2)
                array.
    push(pattern_boxesflag_box)
                
                
    // Target calculation
                
    pole_height highest_price lowest_price[20]
                if 
    str.contains(pattern.name"BOĞA")
                    
    target_price := pattern.level1 pole_height
                    target_label_text 
    := "HEDEF ↑"
                
    else if str.contains(pattern.name"AYI")
                    
    target_price := pattern.level2 pole_height
                    target_label_text 
    := "HEDEF ↓"
            
            
    else if str.contains(pattern.name"ÇEKİÇ") or str.contains(pattern.name"PİN BAR")
                
    body_box box.new(bar_index 1math.max(openclose), bar_indexmath.min(openclose), bgcolor=color.new(pattern_color50), border_color=pattern_color)
                array.
    push(pattern_boxesbody_box)
                
                
    shadow_line line.new(bar_indexhighbar_indexlowcolor=pattern_colorwidth=3style=line.style_solid)
                array.
    push(pattern_linesshadow_line)
                
                
    shadow_ratio str.contains(pattern.name"ÇEKİÇ") ? (math.min(openclose) - low) / math.abs(close open) : (high math.max(openclose)) / math.abs(close open)
                
                
    ratio_label label.new(bar_indexlow 0.99"FİTİL/BAR: " str.tostring(shadow_ratio"#.#") + "x"color=pattern_colortextcolor=color.whitestyle=label.style_label_upsize=size.tiny)
                array.
    push(pattern_labelsratio_label)
                
                
    // Target calculation
                
    candle_range high low
                
    if pattern.direction == "BOĞA"
                    
    target_price := close candle_range 2
                    target_label_text 
    := "HEDEF ↑"
                
    else
                    
    target_price := close candle_range 2
                    target_label_text 
    := "HEDEF ↓"
            
            
    // Display target prices
            
    if show_targets and not na(target_price)
                
    target_box box.new(bar_indexclosebar_index 30target_pricebgcolor=color.new(pattern.direction == "BOĞA" color.green color.red95), border_color=pattern.direction == "BOĞA" color.green color.redborder_width=1border_style=line.style_dashed)
                array.
    push(pattern_boxestarget_box)
                
                
    target_line line.new(bar_indextarget_pricebar_index 30target_pricecolor=pattern.direction == "BOĞA" color.green color.redwidth=2style=line.style_dashed)
                array.
    push(pattern_linestarget_line)
                
                
    price_change target_price close
                price_change_percent 
    = (price_change close) * 100
                target_text 
    target_label_text "\n$" str.tostring(target_price"#,###.##") + "\n(" str.tostring(price_change_percent"+#.##") + "%)"
                
    target_label label.new(bar_index 30target_pricetarget_textcolor=pattern.direction == "BOĞA" color.green color.redtextcolor=color.whitestyle=pattern.direction == "BOĞA" label.style_label_up label.style_label_downsize=size.normal)
                array.
    push(pattern_labelstarget_label)
                
                
    arrow_line line.new(bar_index 15closebar_index 15target_pricecolor=pattern.direction == "BOĞA" color.green color.redwidth=3style=line.style_arrow_right)
                array.
    push(pattern_linesarrow_line)
            
            
    // Pattern name and confidence
            
    if show_confidence
                label_text 
    pattern.name "\n" str.tostring(pattern.confidence"#") + "%"
                
    main_label label.new(bar_index 2high * (0.02 i), label_textcolor=pattern_colortextcolor=color.whitestyle=label.style_label_leftsize=size.normal)
                array.
    push(pattern_labelsmain_label)

    // Explanation panel
    if show_explanation and barstate.islast
        
    // Get text size
        
    text_size_val = switch panel_text_size
            
    "tiny" => size.tiny
            
    "small" => size.small
            
    "large" => size.large
            
    "huge" => size.huge
            
    => size.normal
        
        table
    .cell(explanation_table00"🔍 BULUNAN SONUÇ"bgcolor=color.new(color.purple30), text_color=color.whitetext_size=size.large)
        
    table.cell(explanation_table10"📊 ANALİZ"bgcolor=color.new(color.purple30), text_color=color.whitetext_size=size.large)
        
        if array.
    size(detected_patterns) > 0
            display_count 
    math.min(array.size(detected_patterns), max_patterns)
            for 
    0 to display_count 1
                pattern 
    = array.get(detected_patternsi)
                
                
    explanation ""
                
    if str.contains(pattern.name"İKİLİ TEPE")
                    
    explanation := "✓ İKİ ZİRVE YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ÇİZGİSİ KIRILIM ONAYI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"İKLİ DİP")
                    
    explanation := "✓ İKİ DİP YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ÇİZGİSİ KIRILIM ONAYI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"ÜÇGENLER")
                    
    range_compression = ((high low) / (highest_price lowest_price)) * 100
                    explanation 
    := "✓ ARALIK SIKIŞMASI " str.tostring(100 range_compression"#") + "%\n" +
                                  
    "✓ TREND OLUŞTU\n" +
                                  
    "✓ ÇIKIŞ BEKLENİYOR"
                
    else if str.contains(pattern.name"BAŞ") and str.contains(pattern.name"OMUZLAR")
                    
    explanation := "✓ BAŞ OLUŞTU\n" +
                                  
    "✓ OMUZLAR SİMETRİK\n" +
                                  
    "✓ BOYUN OLUŞTU"
                
    else if str.contains(pattern.name"FLAMALAR")
                    
    explanation := "✓ FLAMA OLUŞTU\n" +
                                  
    "✓ KONSİLDASYON ONAYLANDI\n" +
                                  
    "✓ DEVAM EDEBİLİR"
                
    else if str.contains(pattern.name"TAKOZLAR")
                    
    explanation := "✓ FİYAT SIKIŞIYOR\n" +
                                  
    "✓ EĞİLİM AYNI YÖNDE\n" +
                                  
    "✓ TERSE DÖNEBİLİR"
                
    else if str.contains(pattern.name"ÇEKİÇ")
                    
    explanation := "✓ BAR BOYU\n" +
                                  
    "✓ MİNUMUMDA\n" +
                                  
    "✓ DESTEKDE"
                
    else if str.contains(pattern.name"YUTAN BARLAR")
                    
    explanation := "✓ ÖNCEKİ BAR YUTULDU\n" +
                                  
    "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"PİN BAR")
                    
    explanation := "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ DİKKAT TERSE DÖNÜŞ\n" +
                                  
    "✓ SIKIŞMA ARTI"
                
    else if str.contains(pattern.name"İÇ BAR")
                    
    explanation := "✓ ÖNCEKİ BAR ARALIĞINDA\n" +
                                  
    "✓ FİYAT HAREKET AZALDI\n" +
                                  
    "✓ DİKKAT YÜKSELEBİLİR"
                
    else if str.contains(pattern.name"DIŞ BAR")
                    
    explanation := "✓ ÖNCEKİ BAR YUTULDU\n" +
                                  
    "✓ ARALIK ARTIYOR\n" +
                                  
    "✓ DİKKAT TREND DEĞİŞİMİ OLABİLİR"
                
    else
                    
    explanation := "✓ MODEL ONAYI\n" +
                                  
    "✓ OLASILIK: " str.tostring(pattern.confidence"#") + "%\n" +
                                  
    "✓ YÖN: " pattern.direction
                
                pattern_color 
    = switch pattern.direction
                    
    "BOĞA" => color.new(color.lime20)
                    
    "AYI" => color.new(color.red20)
                    => 
    color.new(color.yellow20)
                    
                
    table.cell(explanation_table01pattern.namebgcolor=pattern_colortext_color=color.whitetext_size=text_size_val)
                
    table.cell(explanation_table11explanationbgcolor=color.new(color.black60), text_color=color.whitetext_size=text_size_val)
        else
            
    table.cell(explanation_table01"TARANIYOR..."text_color=color.graytext_size=text_size_val)
            
    table.cell(explanation_table11"BULUNAMADI"text_color=color.graytext_size=text_size_val)

    // Table update
    if show_table and barstate.islast
        table
    .cell(pattern_table00"MODELLEME"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table10"YÖN"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table20"OLASILIK"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table30"DURUM"bgcolor=color.bluetext_color=color.white)
        
        if array.
    size(detected_patterns) > 0
            display_count 
    math.min(array.size(detected_patterns), max_patterns)
            for 
    0 to display_count 1
                pattern 
    = array.get(detected_patternsi)
                
                
    dir_color = switch pattern.direction
                    
    "BOĞA" => color.lime
                    
    "AYI" => color.red
                    
    => color.yellow
                
                conf_color 
    pattern.confidence >= 80 color.lime pattern.confidence >= 70 color.yellow color.gray
                
                table
    .cell(pattern_table01pattern.nametext_color=color.white)
                
    table.cell(pattern_table11pattern.directiontext_color=dir_color)
                
    table.cell(pattern_table21str.tostring(pattern.confidence"#") + "%"text_color=conf_color)
                
    table.cell(pattern_table31"AKTİF"text_color=color.aqua)
        else
            
    table.cell(pattern_table01"MODEL YOK"text_color=color.gray)
            
    table.cell(pattern_table11"-"text_color=color.gray)
            
    table.cell(pattern_table21"-"text_color=color.gray)
            
    table.cell(pattern_table31"BEKLE"text_color=color.gray)

    // Background color
    bg_color color(na)
    if array.
    size(detected_patterns) > 0
        top_pattern 
    = array.get(detected_patterns0)
        
    bg_color := switch top_pattern.direction
            
    "BOĞA" => color.new(color.green95)
            
    "AYI" => color.new(color.red95)
            => 
    color.new(color.yellow95)

    //bgcolor(bg_color)

    // S/R levels
    plot(highest_price"DİRENÇ"color=color.new(#ff5252, 100), linewidth=1, style=plot.style_stepline)
    plot(lowest_price"DESTEK"color=color.new(#4caf4f, 100), linewidth=1, style=plot.style_stepline)
    plot(mid_price"ORTALAMA"color=color.new(#787b86, 100), linewidth=1, style=plot.style_stepline)

    // Alerts
    if array.size(detected_patterns) > 0
        top_pattern 
    = array.get(detected_patterns0)
        
    alert_msg "MODEL BULUNDU: " top_pattern.name " [" top_pattern.direction "] OLASILIK: " str.tostring(top_pattern.confidence"#") + "%"
        
    if array.size(detected_patterns) > 1
            alert_msg 
    += " (+" str.tostring(array.size(detected_patterns) - 1) + " more)"
        
    alert(alert_msgalert.freq_once_per_bar)

    // Alert conditions
    alertcondition(array.size(detected_patterns) > and array.get(detected_patterns0).direction == "BOĞA""MODEL""BULUNDU")
    alertcondition(array.size(detected_patterns) > and array.get(detected_patterns0).direction == "AYI""MODEL""BULUNDU")
    alertcondition(array.size(detected_patterns) > 0"MODEL""YENİ MODEL VAR"

  5. swing için....
    PHP Code:
    //@version=6
    indicator("."overlay=truemax_bars_back=500)

    // ============================================
    // INPUT PARAMETERS
    // ============================================
    g1 "ARAMA AYARLARI"
    lookback input.int(100"MODEL PERİYOT"minval=20maxval=200group=g1)
    sensitivity input.float(0.0015"DUYARLILIK"minval=0.0005maxval=0.01step=0.0005group=g1)
    min_touches input.int(2"TEST ADET"minval=2maxval=5group=g1)

    g2 "KLASİK MODELLER"
    detect_classic input.bool(true"▼ KLASİK MODELLER"group=g2)
    classic_double input.bool(true"├ İKİLİ TEPE/DİP"group=g2)
    classic_triple input.bool(true"├ ÜÇLÜ TEPE/DİP"group=g2)
    classic_hs input.bool(true"├ BAŞ & OMUZLAR"group=g2)
    classic_rounding input.bool(true"└ YUVARLAMA"group=g2)

    g3 "ÜÇGEN MODELLER"
    detect_triangles input.bool(true"▼ ÜÇGEN MODELLER"group=g3)
    tri_ascending input.bool(true"├ YÜKSELEN ÜÇGEN"group=g3)
    tri_descending input.bool(true"├ ALÇALAN ÜÇGEN"group=g3)
    tri_symmetrical input.bool(true"├ SİMETRİK ÜÇGEN"group=g3)
    tri_expanding input.bool(true"└ GENİŞLEYEN ÜÇGEN"group=g3)

    g4 "DEVAM MODELLERİ"
    detect_continuation input.bool(true"▼ DEVAM MODELLERİ"group=g4)
    cont_flag input.bool(true"├ FLAMA"group=g4)
    cont_pennant input.bool(true"├ FLAMALAR"group=g4)
    cont_wedge input.bool(true"├ TAKOZLAR"group=g4)
    cont_channel input.bool(true"├ KANALLAR"group=g4)
    cont_rectangle input.bool(true"└ DİKDÖRTGENLER"group=g4)

    g5 "HARMONİK MODELLER"
    detect_harmonic input.bool(true"▼ HARMONİK MODELLER"group=g5)
    harm_gartley input.bool(true"├ FİBO"group=g5)
    harm_butterfly input.bool(true"├ KELEBEK"group=g5)
    harm_bat input.bool(true"├ YARASA"group=g5)
    harm_crab input.bool(true"├ YENGEÇ"group=g5)
    harm_shark input.bool(true"├ KÖPEKBALIĞI"group=g5)
    harm_cypher input.bool(true"└ DÖRTLÜ"group=g5)

    g6 "FİYAT MODELLERİ"
    detect_price_action input.bool(true"▼ FİYAT MODELLERİ"group=g6)
    pa_pin_bar input.bool(true"├ PİN BAR"group=g6)
    pa_inside input.bool(true"├ İÇ BAR"group=g6)
    pa_outside input.bool(true"├ DIŞ BAR"group=g6)
    pa_engulfing input.bool(true"├ YUTMA"group=g6)
    pa_doji input.bool(true"├ DOJİ"group=g6)
    pa_hammer input.bool(true"└ ÇEKİÇ"group=g6)

    g7 "ÖZEL MODELLER"
    detect_special input.bool(true"▼ ÖZEL MODELLER"group=g7)
    spec_diamond input.bool(true"├ ELMAS"group=g7)
    spec_cup input.bool(true"├ FİNCAN & KULP"group=g7)
    spec_vbottom input.bool(true"├ V-DİP/ZİRVE"group=g7)
    spec_broadening input.bool(true"├ GENİŞLEME"group=g7)
    spec_island input.bool(true"└ ADA DÖNÜŞ"group=g7)

    g8 "AYARLAR"
    show_patterns input.bool(true"MODEL"group=g8)
    show_confidence input.bool(true"OLASILIK"group=g8)
    show_table input.bool(true"ARAMA"group=g8)
    show_explanation input.bool(true"SEBEP"group=g8)
    show_pivot_points input.bool(true"PİVOT"group=g8)
    show_key_levels input.bool(true"GİRİŞ"group=g8)
    show_targets input.bool(true"HEDEF"group=g8)
    max_patterns input.int(5"SAYIM"minval=1maxval=10group=g8)

    g9 "Panel Position Settings"
    table_position input.string("top_right""Detection Table Position"options=["top_left""top_center""top_right""middle_left""middle_center""middle_right""bottom_left""bottom_center""bottom_right"], group=g9)
    explanation_position input.string("middle_right""Explanation Panel Position"options=["top_left""top_center""top_right""middle_left""middle_center""middle_right""bottom_left""bottom_center""bottom_right"], group=g9)
    panel_transparency input.int(80"Panel Transparency"minval=0maxval=100group=g9)
    panel_text_size input.string("normal""Text Size"options=["tiny""small""normal""large""huge"], group=g9)

    // ============================================
    // GLOBAL VARIABLES & STRUCTURES
    // ============================================
    type PatternInfo
        string name
        string direction  
    // bullish/bearish/neutral
        
    float confidence
        int start_bar
        int end_bar
        float level1
        float level2

    var array<PatternInfodetected_patterns = array.new<PatternInfo>()
    var 
    table pattern_table na
    var table explanation_table na
    var line[] pattern_lines = array.new_line()
    var 
    label[] pattern_labels = array.new_label()
    var 
    box[] pattern_boxes = array.new_box()

    // Position conversion function
    get_table_position(pos_string) =>
        switch 
    pos_string
            
    "top_left" => position.top_left
            
    "top_center" => position.top_center
            
    "top_right" => position.top_right
            
    "middle_left" => position.middle_left
            
    "middle_center" => position.middle_center
            
    "middle_right" => position.middle_right
            
    "bottom_left" => position.bottom_left
            
    "bottom_center" => position.bottom_center
            
    "bottom_right" => position.bottom_right
            
    => position.top_right

    // Table initialization
    if barstate.isfirst or barstate.isconfirmed
        
    if not na(pattern_table)
            
    table.delete(pattern_table)
        if 
    not na(explanation_table)
            
    table.delete(explanation_table)
        
        if 
    show_table
            pattern_table 
    := table.new(get_table_position(table_position), 4max_patterns 1bgcolor=color.new(color.blackpanel_transparency))
        if 
    show_explanation
            explanation_table 
    := table.new(get_table_position(explanation_position), 2max_patterns 1bgcolor=color.new(color.blackpanel_transparency), border_width=2)

    // ============================================
    // BASIC CALCULATIONS
    // ============================================
    highest_price ta.highest(highlookback)
    lowest_price ta.lowest(lowlookback)
    mid_price = (highest_price lowest_price) / 2

    // ATR for volatility
    atr ta.atr(14)
    volatility atr close

    // ============================================
    // PATTERN DETECTION FUNCTIONS
    // ============================================

    // Pivot detection
    findPivotPoints(len) =>
        var 
    pivotHighs = array.new_float()
        var 
    pivotLows = array.new_float()
        var 
    pivotHighBars = array.new_int()
        var 
    pivotLowBars = array.new_int()
        
        for 
    len to lookback len
            isHigh 
    true
            isLow 
    true
            
    for = -len to len
                
    if high[i+j] > high[i]
                    
    isHigh := false
                
    if low[i+j] < low[i]
                    
    isLow := false
            
            
    if isHigh
                
    array.push(pivotHighshigh[i])
                array.
    push(pivotHighBarsi)
            if 
    isLow
                
    array.push(pivotLowslow[i])
                array.
    push(pivotLowBarsi)
        
        [
    pivotHighspivotLowspivotHighBarspivotLowBars]

    // Fibonacci ratio check
    checkFibRatio(val1val2target_ratiotolerance) =>
        
    ratio val2 val1
        math
    .abs(ratio target_ratio) < tolerance

    // 1. Double Top/Bottom Detection
    detectDoublePatterns() =>
        if 
    not detect_classic or not classic_double
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            
    // Double Top
            
    if array.size(highs) >= 2
                
    for 0 to math.min(array.size(highs) - 210)
                    
    h1 = array.get(highsi)
                    
    h2 = array.get(highs1)
                    
    diff math.abs(h1 h2) / h1
                    
                    
    if diff sensitivity
                        neckline 
    lowest_price
                        
    if close neckline 0.995
                            PatternInfo
    .new("İKİLİ TEPE""AYI"85bar_index lookbackbar_indexh1neckline)
            
            
    // Double Bottom
            
    if array.size(lows) >= 2
                
    for 0 to math.min(array.size(lows) - 210)
                    
    l1 = array.get(lowsi)
                    
    l2 = array.get(lows1)
                    
    diff math.abs(l1 l2) / l1
                    
                    
    if diff sensitivity
                        neckline 
    highest_price
                        
    if close neckline 1.005
                            PatternInfo
    .new("İKİLİ DİP""BOĞA"85bar_index lookbackbar_indexnecklinel1)
            
            
    PatternInfo.new(""""00000)

    // 2. Triple Top/Bottom
    detectTriplePatterns() =>
        if 
    not detect_classic or not classic_triple
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= 3
                
    for 0 to math.min(array.size(highs) - 35)
                    
    h1 = array.get(highsi)
                    
    h2 = array.get(highs1)
                    
    h3 = array.get(highs2)
                    
                    
    diff1 math.abs(h1 h2) / h1
                    diff2 
    math.abs(h2 h3) / h2
                    
                    
    if diff1 sensitivity and diff2 sensitivity
                        PatternInfo
    .new("ÜÇLÜ TEPE""AYI"90bar_index lookbackbar_indexh1lowest_price)
            
            
    PatternInfo.new(""""00000)

    // 3. Head & Shoulders
    detectHeadShoulders() =>
        if 
    not detect_classic or not classic_hs
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= 3
                
    for 0 to math.min(array.size(highs) - 35)
                    
    left = array.get(highsi)
                    
    head = array.get(highs1)
                    
    right = array.get(highs2)
                    
                    if 
    head left and head right
                        shoulder_diff 
    math.abs(left right) / left
                        
    if shoulder_diff sensitivity 2
                            PatternInfo
    .new("BAŞ & OMUZLAR""AYI"88bar_index lookbackbar_indexheadmath.min(leftright))
            
            if array.
    size(highs) >= 5
                
    for 0 to math.min(array.size(highs) - 53)
                    
    ls1 = array.get(highsi)
                    
    ls2 = array.get(highs1)
                    
    head = array.get(highs2)
                    
    rs1 = array.get(highs3)
                    
    rs2 = array.get(highs4)
                    
                    
    avg_left = (ls1 ls2) / 2
                    avg_right 
    = (rs1 rs2) / 2
                    
                    
    if head avg_left and head avg_right
                        PatternInfo
    .new("BAŞ OMUZ""AYI"82bar_index lookbackbar_indexheadmath.min(avg_leftavg_right))
            
            
    PatternInfo.new(""""00000)

    // 4. Triangle Patterns
    detectTriangles() =>
        if 
    not detect_triangles
            PatternInfo
    .new(""""00000)
        else
            
    upper_trend ta.linreg(highlookback0) - ta.linreg(highlookbacklookback 1)
            
    lower_trend ta.linreg(lowlookback0) - ta.linreg(lowlookbacklookback 1)
            
            
    range_start highest_price lowest_price
            range_end 
    high low
            converging 
    range_end range_start 0.7
            diverging 
    range_end range_start 1.3
            
            
    if tri_ascending and math.abs(upper_trend) < volatility and lower_trend volatility and converging
                PatternInfo
    .new("YÜKSELEN ÜÇGEN""BOĞA"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_descending and upper_trend < -volatility and math.abs(lower_trend) < volatility and converging
                PatternInfo
    .new("ALÇALAN ÜÇGEN""AYI"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_symmetrical and math.abs(upper_trend lower_trend) < volatility and converging
                PatternInfo
    .new("SİMETRİK ÜÇGEN""BEKLE"75bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_expanding and diverging
                PatternInfo
    .new("GENİŞLEYEN ÜÇGEN""BEKLE"72bar_index lookbackbar_indexhighest_pricelowest_price)
            else
                
    PatternInfo.new(""""00000)

    // 5. Wedge Patterns
    detectWedges() =>
        if 
    not detect_continuation or not cont_wedge
            PatternInfo
    .new(""""00000)
        else
            
    upper_slope = (highest_price highest_price[lookback-1]) / lookback
            lower_slope 
    = (lowest_price lowest_price[lookback-1]) / lookback
            
            converging 
    = (high low) < (highest_price[lookback-1] - lowest_price[lookback-1]) * 0.7
            
            
    if upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("YÜKSELEN TAKOZ""AYI"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("DÜŞEN TAKOZ""BOĞA"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    math.abs(upper_slope) > volatility and math.abs(lower_slope) > volatility 2
                
    if upper_slope and lower_slope 0
                    PatternInfo
    .new("GENİŞLEYEN KAMA""AYI"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else if 
    upper_slope and lower_slope 0
                    PatternInfo
    .new("DARALAN KAMA""BOĞA"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 6. Flags & Pennants
    detectFlagsAndPennants() =>
        if 
    not detect_continuation or not (cont_flag or cont_pennant)
            
    PatternInfo.new(""""00000)
        else
            
    prior_trend close[lookback] - close[lookback 2]
            
    recent_slope ta.linreg(close100) - ta.linreg(close109)
            
    recent_high ta.highest(high10)
            
    recent_low ta.lowest(low10)
            
    recent_range recent_high recent_low
            prior_range 
    ta.highest(high20)[10] - ta.lowest(low20)[10]
            
            
    is_consolidation recent_range prior_range 0.5
            
            
    if cont_flag and is_consolidation
                
    if prior_trend and recent_slope 0
                    PatternInfo
    .new("FLAMA""BOĞA"74bar_index 10bar_indexrecent_highrecent_low)
                else if 
    prior_trend and recent_slope 0
                    PatternInfo
    .new("FLAMA""AYI"74bar_index 10bar_indexrecent_highrecent_low)
                else if 
    math.abs(recent_slope) < volatility
                    PatternInfo
    .new("FLAMA YATAY""BEKLE"72bar_index 10bar_indexrecent_highrecent_low)
                else
                    
    PatternInfo.new(""""00000)
            
            else if 
    cont_pennant and is_consolidation and recent_range recent_range[5] * 0.7
                
    if prior_trend 0
                    PatternInfo
    .new("BOĞA""BOĞA"73bar_index 10bar_indexrecent_highrecent_low)
                else if 
    prior_trend 0
                    PatternInfo
    .new("AYI""AYI"73bar_index 10bar_indexrecent_highrecent_low)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 7. Harmonic Patterns (simplified)
    detectHarmonicPatterns() =>
        if 
    not detect_harmonic
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= and array.size(lows) >= 3
                X 
    = array.get(lows0)
                
    = array.get(highs0)
                
    = array.get(lows1)
                
    = array.get(highs1)
                
    close
                
                XA 
    X
                AB 
    B
                BC 
    B
                CD 
    D
                
                
    if harm_gartley and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC0.7860.05)
                    
    PatternInfo.new("FİBO""BOĞA"80bar_index lookbackbar_indexCD)
                else if 
    harm_butterfly and checkFibRatio(XAAB0.7860.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("KELEBEK""BOĞA"78bar_index lookbackbar_indexCD)
                else if 
    harm_bat and checkFibRatio(XAAB0.3820.05) and checkFibRatio(ABBC0.8860.05)
                    
    PatternInfo.new("YARASA""BOĞA"77bar_index lookbackbar_indexCD)
                else if 
    harm_crab and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("YENGEÇ""BOĞA"76bar_index lookbackbar_indexCD)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 8. Price Action Patterns
    detectPriceAction() =>
        if 
    not detect_price_action
            PatternInfo
    .new(""""00000)
        else
            
    body math.abs(close open)
            
    upper_shadow high math.max(openclose)
            
    lower_shadow math.min(openclose) - low
            prev_body 
    math.abs(close[1] - open[1])
            
    avg_body ta.sma(math.abs(close open), 20)
            
    sma20 ta.sma(close20)
            
            if 
    pa_pin_bar and (upper_shadow body or lower_shadow body 2)
                
    direction lower_shadow upper_shadow "BOĞA" "AYI"
                
    PatternInfo.new("Pin Bar"direction70bar_indexbar_indexhighlow)
            else if 
    pa_inside and high high[1] and low low[1]
                
    PatternInfo.new("İÇ BAR""BEKLE"68bar_index 1bar_indexhigh[1], low[1])
            else if 
    pa_outside and high high[1] and low low[1]
                
    PatternInfo.new("DIŞ BAR""BEKLE"68bar_index 1bar_indexhighlow)
            else if 
    pa_engulfing and body prev_body 1.5
                
    if close open and close high[1] and open low[1]
                    
    PatternInfo.new("BOĞA YUTAN""BOĞA"72bar_index 1bar_indexhighlow)
                else if 
    close open and close low[1] and open high[1]
                    
    PatternInfo.new("AYI YUTAN""AYI"72bar_index 1bar_indexhighlow)
                else
                    
    PatternInfo.new(""""00000)
            else if 
    pa_doji and body avg_body 0.1
                
    if upper_shadow avg_body and lower_shadow avg_body
                    PatternInfo
    .new("Doji""BEKLE"65bar_indexbar_indexhighlow)
                else if 
    upper_shadow lower_shadow 2
                    PatternInfo
    .new("EJDERHA""BOĞA"66bar_indexbar_indexhighlow)
                else if 
    lower_shadow upper_shadow 2
                    PatternInfo
    .new("MEZARTAŞI""AYI"66bar_indexbar_indexhighlow)
                else
                    
    PatternInfo.new(""""00000)
            else if 
    pa_hammer and lower_shadow body and upper_shadow body 0.3
                
    if close sma20
                    PatternInfo
    .new("ÇEKİÇ""BOĞA"69bar_indexbar_indexhighlow)
                else
                    
    PatternInfo.new("ÇEKİÇ""AYI"69bar_indexbar_indexhighlow)
            else
                
    PatternInfo.new(""""00000)

    // 9. Special Patterns
    detectSpecialPatterns() =>
        if 
    not detect_special
            PatternInfo
    .new(""""00000)
        else
            if 
    spec_cup
                cup_depth 
    lowest_price[20] < lowest_price 0.85
                cup_recovery 
    close highest_price[20] * 0.95
                handle_forming 
    high highest_price[5] * 0.98
                
                
    if cup_depth and cup_recovery and handle_forming
                    PatternInfo
    .new("FİNCAN & KULP""BOĞA"82bar_index 30bar_indexhighest_pricelowest_price)
            
            if 
    spec_vbottom
                sharp_decline 
    lowest_price lowest_price[10] * 0.9
                sharp_recovery 
    close highest_price[5] * 0.95
                
                
    if sharp_decline and sharp_recovery
                    PatternInfo
    .new("V-DİP""BOĞA"75bar_index 10bar_indexhighest_price[10], lowest_price)
                else if 
    close lowest_price[5] * 1.05 and highest_price highest_price[10] * 1.1
                    PatternInfo
    .new("V-ZİRVE""AYI"75bar_index 10bar_indexhighest_pricelowest_price[10])
                else
                    
    PatternInfo.new(""""00000)
            
            else if 
    spec_diamond
                mid_expand 
    = (ta.highest(high25)[12] - ta.lowest(low25)[12]) > (ta.highest(high50)[25] - ta.lowest(low50)[25]) * 1.2
                end_contract 
    = (high low) < (ta.highest(high25)[12] - ta.lowest(low25)[12]) * 0.7
                
                
    if mid_expand and end_contract
                    PatternInfo
    .new("ELMAS""BEKLE"77bar_index lookbackbar_indexhighest_pricelowest_price)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // ============================================
    // MAIN PROCESSING
    // ============================================

    // Clear detected patterns
    array.clear(detected_patterns)

    // Execute detection functions
    patterns_to_check = array.new<PatternInfo>()
    array.
    push(patterns_to_checkdetectDoublePatterns())
    array.
    push(patterns_to_checkdetectTriplePatterns())
    array.
    push(patterns_to_checkdetectHeadShoulders())
    array.
    push(patterns_to_checkdetectTriangles())
    array.
    push(patterns_to_checkdetectWedges())
    array.
    push(patterns_to_checkdetectFlagsAndPennants())
    array.
    push(patterns_to_checkdetectHarmonicPatterns())
    array.
    push(patterns_to_checkdetectPriceAction())
    array.
    push(patterns_to_checkdetectSpecialPatterns())

    // Keep only valid patterns
    for 0 to array.size(patterns_to_check) - 1
        pattern 
    = array.get(patterns_to_checki)
        if 
    pattern.name != ""
            
    array.push(detected_patternspattern)

    // Sort by confidence (descending)
    if array.size(detected_patterns) > 1
        
    for 0 to array.size(detected_patterns) - 2
            
    for 0 to array.size(detected_patterns) - 2
                
    if < array.size(detected_patterns)
                    if array.
    get(detected_patternsj).confidence < array.get(detected_patterns1).confidence
                        temp 
    = array.get(detected_patternsj)
                        array.
    set(detected_patternsj, array.get(detected_patterns1))
                        array.
    set(detected_patterns1temp)

    // ============================================
    // VISUALIZATION
    // ============================================

    // Clear old drawings
    if barstate.islast
        
    for line in pattern_lines
            line
    .delete(line)
        array.
    clear(pattern_lines)
        
        for 
    lbl in pattern_labels
            label
    .delete(lbl)
        array.
    clear(pattern_labels)
        
        for 
    bx in pattern_boxes
            box
    .delete(bx)
        array.
    clear(pattern_boxes)

    // Draw patterns
    if show_patterns and barstate.islast and array.size(detected_patterns) > 0
        display_count 
    math.min(array.size(detected_patterns), max_patterns)
        for 
    0 to display_count 1
            pattern 
    = array.get(detected_patternsi)
            
            
    // Color settings
            
    pattern_color = switch pattern.direction
                
    "BOĞA" => color.new(color.lime20)
                
    "AYI" => color.new(color.red20)
                => 
    color.new(color.yellow20)
            
            
    // Target price calculation
            
    float target_price na
            float target_distance 
    0.0
            string target_label_text 
    ""
            
            
    // Pattern-specific drawing
            
    if str.contains(pattern.name"İKİLİ") or str.contains(pattern.name"ÜÇLÜ")
                [
    highslowshighBarslowBars] = findPivotPoints(5)
                if array.
    size(highs) >= 2
                    
    for 0 to math.min(array.size(highs) - 13)
                        
    high_point = array.get(highsj)
                        
    high_bar bar_index - array.get(highBarsj)
                        
    circle_label label.new(high_barhigh_point 1.01"●"color=color.new(color.red0), textcolor=color.redstyle=label.style_label_centersize=size.tiny)
                        array.
    push(pattern_labelscircle_label)
                if array.
    size(lows) >= 2
                    
    for 0 to math.min(array.size(lows) - 13)
                        
    low_point = array.get(lowsj)
                        
    low_bar bar_index - array.get(lowBarsj)
                        
    circle_label label.new(low_barlow_point 0.99"●"color=color.new(color.green0), textcolor=color.greenstyle=label.style_label_centersize=size.tiny)
                        array.
    push(pattern_labelscircle_label)
                
                
    // Neckline
                
    neckline str.contains(pattern.name"ZİRVE") ? pattern.level2 pattern.level1
                neck_line 
    line.new(pattern.start_barnecklinepattern.end_bar 10necklinecolor=color.new(color.orange0), width=2style=line.style_solid)
                array.
    push(pattern_linesneck_line)
                
    neck_label label.new(pattern.end_bar 5neckline"BOYUN"color=color.new(color.orange80), textcolor=color.whitestyle=label.style_label_leftsize=size.tiny)
                array.
    push(pattern_labelsneck_label)
                
                
    // Target calculation
                
    if str.contains(pattern.name"ZİRVE")
                    
    target_distance pattern.level1 neckline
                    target_price 
    := neckline target_distance
                    target_label_text 
    := "HEDEF ↓"
                
    else
                    
    target_distance neckline pattern.level2
                    target_price 
    := neckline target_distance
                    target_label_text 
    := "HEDEF ↑"
            
            
    else if str.contains(pattern.name"ÜÇGENLER") or str.contains(pattern.name"TAKOZLAR")
                
    upper_line line.new(pattern.start_barpattern.level1pattern.end_barpattern.level1 - (pattern.level1 pattern.level2) * 0.3color=pattern_colorwidth=2style=line.style_solid)
                
    lower_line line.new(pattern.start_barpattern.level2pattern.end_barpattern.level2 + (pattern.level1 pattern.level2) * 0.3color=pattern_colorwidth=2style=line.style_solid)
                array.
    push(pattern_linesupper_line)
                array.
    push(pattern_lineslower_line)
                
                
    convergence_label label.new(pattern.end_bar 5, (pattern.level1 pattern.level2) / 2str.contains(pattern.name"GENİŞLEYEN") ? "GENİŞLEYEN→" "←DARALAN→"color=color.new(pattern_color80), textcolor=color.whitestyle=label.style_label_centersize=size.tiny)
                array.
    push(pattern_labelsconvergence_label)
                
                
    // Target calculation
                
    pattern_height pattern.level1 pattern.level2
                
    if pattern.direction == "BOĞA"
                    
    target_price := pattern.level1 pattern_height
                    target_label_text 
    := "HEDEF ↑"
                
    else if pattern.direction == "AYI"
                    
    target_price := pattern.level2 pattern_height
                    target_label_text 
    := "HEDEF ↓"
                
    else
                    
    target_price := close > (pattern.level1 pattern.level2) / pattern.level1 pattern_height pattern.level2 pattern_height
                    target_label_text 
    := "HEDEF"
            
            
    else if str.contains(pattern.name"BAŞ") and str.contains(pattern.name"OMUZLAR")
                [
    highslowshighBarslowBars] = findPivotPoints(5)
                if array.
    size(highs) >= 3
                    max_high_idx 
    0
                    max_high_val 
    0.0
                    
    for 0 to math.min(array.size(highs) - 14)
                        if array.
    get(highsj) > max_high_val
                            max_high_val 
    := array.get(highsj)
                            
    max_high_idx := j
                    
                    head_bar 
    bar_index - array.get(highBarsmax_high_idx)
                    
    head_label label.new(head_barmax_high_val 1.01"BAŞ"color=color.redtextcolor=color.whitestyle=label.style_label_downsize=size.small)
                    array.
    push(pattern_labelshead_label)
                    
                    for 
    0 to math.min(array.size(highs) - 14)
                        if 
    != max_high_idx
                            shoulder_bar 
    bar_index - array.get(highBarsj)
                            
    shoulder_val = array.get(highsj)
                            
    shoulder_label label.new(shoulder_barshoulder_val 1.01"S"color=color.orangetextcolor=color.whitestyle=label.style_label_downsize=size.tiny)
                            array.
    push(pattern_labelsshoulder_label)
                    
                    
    // Target calculation
                    
    neckline_hs pattern.level2
                    head_distance 
    max_high_val neckline_hs
                    target_price 
    := neckline_hs head_distance
                    target_label_text 
    := "HEDEF ↓"
            
            
    else if str.contains(pattern.name"FLAMA") or str.contains(pattern.name"FLAMALAR")
                
    pole_start pattern.start_bar 20
                pole_end 
    pattern.start_bar
                pole_line 
    line.new(pole_startlowest_price[20], pole_endhighest_pricecolor=color.new(color.blue50), width=3style=line.style_solid)
                array.
    push(pattern_linespole_line)
                
    pole_label label.new(pole_start, (highest_price lowest_price[20]) / 2"@YÖRÜK@"color=color.bluetextcolor=color.whitestyle=label.style_label_rightsize=size.tiny)
                array.
    push(pattern_labelspole_label)
                
                
    flag_box box.new(pattern.start_barpattern.level1pattern.end_barpattern.level2bgcolor=color.new(pattern_color90), border_color=pattern_colorborder_width=2)
                array.
    push(pattern_boxesflag_box)
                
                
    // Target calculation
                
    pole_height highest_price lowest_price[20]
                if 
    str.contains(pattern.name"BOĞA")
                    
    target_price := pattern.level1 pole_height
                    target_label_text 
    := "HEDEF ↑"
                
    else if str.contains(pattern.name"AYI")
                    
    target_price := pattern.level2 pole_height
                    target_label_text 
    := "HEDEF ↓"
            
            
    else if str.contains(pattern.name"ÇEKİÇ") or str.contains(pattern.name"PİN BAR")
                
    body_box box.new(bar_index 1math.max(openclose), bar_indexmath.min(openclose), bgcolor=color.new(pattern_color50), border_color=pattern_color)
                array.
    push(pattern_boxesbody_box)
                
                
    shadow_line line.new(bar_indexhighbar_indexlowcolor=pattern_colorwidth=3style=line.style_solid)
                array.
    push(pattern_linesshadow_line)
                
                
    shadow_ratio str.contains(pattern.name"ÇEKİÇ") ? (math.min(openclose) - low) / math.abs(close open) : (high math.max(openclose)) / math.abs(close open)
                
                
    ratio_label label.new(bar_indexlow 0.99"FİTİL/BAR: " str.tostring(shadow_ratio"#.#") + "x"color=pattern_colortextcolor=color.whitestyle=label.style_label_upsize=size.tiny)
                array.
    push(pattern_labelsratio_label)
                
                
    // Target calculation
                
    candle_range high low
                
    if pattern.direction == "BOĞA"
                    
    target_price := close candle_range 2
                    target_label_text 
    := "HEDEF ↑"
                
    else
                    
    target_price := close candle_range 2
                    target_label_text 
    := "HEDEF ↓"
            
            
    // Display target prices
            
    if show_targets and not na(target_price)
                
    target_box box.new(bar_indexclosebar_index 30target_pricebgcolor=color.new(pattern.direction == "BOĞA" color.green color.red95), border_color=pattern.direction == "BOĞA" color.green color.redborder_width=1border_style=line.style_dashed)
                array.
    push(pattern_boxestarget_box)
                
                
    target_line line.new(bar_indextarget_pricebar_index 30target_pricecolor=pattern.direction == "BOĞA" color.green color.redwidth=2style=line.style_dashed)
                array.
    push(pattern_linestarget_line)
                
                
    price_change target_price close
                price_change_percent 
    = (price_change close) * 100
                target_text 
    target_label_text "\n$" str.tostring(target_price"#,###.##") + "\n(" str.tostring(price_change_percent"+#.##") + "%)"
                
    target_label label.new(bar_index 30target_pricetarget_textcolor=pattern.direction == "BOĞA" color.green color.redtextcolor=color.whitestyle=pattern.direction == "BOĞA" label.style_label_up label.style_label_downsize=size.normal)
                array.
    push(pattern_labelstarget_label)
                
                
    arrow_line line.new(bar_index 15closebar_index 15target_pricecolor=pattern.direction == "BOĞA" color.green color.redwidth=3style=line.style_arrow_right)
                array.
    push(pattern_linesarrow_line)
            
            
    // Pattern name and confidence
            
    if show_confidence
                label_text 
    pattern.name "\n" str.tostring(pattern.confidence"#") + "%"
                
    main_label label.new(bar_index 2high * (0.02 i), label_textcolor=pattern_colortextcolor=color.whitestyle=label.style_label_leftsize=size.normal)
                array.
    push(pattern_labelsmain_label)

    // Explanation panel
    if show_explanation and barstate.islast
        
    // Get text size
        
    text_size_val = switch panel_text_size
            
    "tiny" => size.tiny
            
    "small" => size.small
            
    "large" => size.large
            
    "huge" => size.huge
            
    => size.normal
        
        table
    .cell(explanation_table00"🔍 BULUNAN SONUÇ"bgcolor=color.new(color.purple30), text_color=color.whitetext_size=size.large)
        
    table.cell(explanation_table10"📊 ANALİZ"bgcolor=color.new(color.purple30), text_color=color.whitetext_size=size.large)
        
        if array.
    size(detected_patterns) > 0
            display_count 
    math.min(array.size(detected_patterns), max_patterns)
            for 
    0 to display_count 1
                pattern 
    = array.get(detected_patternsi)
                
                
    explanation ""
                
    if str.contains(pattern.name"İKİLİ TEPE")
                    
    explanation := "✓ İKİ ZİRVE YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ÇİZGİSİ KIRILIM ONAYI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"İKLİ DİP")
                    
    explanation := "✓ İKİ DİP YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ÇİZGİSİ KIRILIM ONAYI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"ÜÇGENLER")
                    
    range_compression = ((high low) / (highest_price lowest_price)) * 100
                    explanation 
    := "✓ ARALIK SIKIŞMASI " str.tostring(100 range_compression"#") + "%\n" +
                                  
    "✓ TREND OLUŞTU\n" +
                                  
    "✓ ÇIKIŞ BEKLENİYOR"
                
    else if str.contains(pattern.name"BAŞ") and str.contains(pattern.name"OMUZLAR")
                    
    explanation := "✓ BAŞ OLUŞTU\n" +
                                  
    "✓ OMUZLAR SİMETRİK\n" +
                                  
    "✓ BOYUN OLUŞTU"
                
    else if str.contains(pattern.name"FLAMALAR")
                    
    explanation := "✓ FLAMA OLUŞTU\n" +
                                  
    "✓ KONSİLDASYON ONAYLANDI\n" +
                                  
    "✓ DEVAM EDEBİLİR"
                
    else if str.contains(pattern.name"TAKOZLAR")
                    
    explanation := "✓ FİYAT SIKIŞIYOR\n" +
                                  
    "✓ EĞİLİM AYNI YÖNDE\n" +
                                  
    "✓ TERSE DÖNEBİLİR"
                
    else if str.contains(pattern.name"ÇEKİÇ")
                    
    explanation := "✓ BAR BOYU\n" +
                                  
    "✓ MİNUMUMDA\n" +
                                  
    "✓ DESTEKDE"
                
    else if str.contains(pattern.name"YUTAN BARLAR")
                    
    explanation := "✓ ÖNCEKİ BAR YUTULDU\n" +
                                  
    "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"PİN BAR")
                    
    explanation := "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ DİKKAT TERSE DÖNÜŞ\n" +
                                  
    "✓ SIKIŞMA ARTI"
                
    else if str.contains(pattern.name"İÇ BAR")
                    
    explanation := "✓ ÖNCEKİ BAR ARALIĞINDA\n" +
                                  
    "✓ FİYAT HAREKET AZALDI\n" +
                                  
    "✓ DİKKAT YÜKSELEBİLİR"
                
    else if str.contains(pattern.name"DIŞ BAR")
                    
    explanation := "✓ ÖNCEKİ BAR YUTULDU\n" +
                                  
    "✓ ARALIK ARTIYOR\n" +
                                  
    "✓ DİKKAT TREND DEĞİŞİMİ OLABİLİR"
                
    else
                    
    explanation := "✓ MODEL ONAYI\n" +
                                  
    "✓ OLASILIK: " str.tostring(pattern.confidence"#") + "%\n" +
                                  
    "✓ YÖN: " pattern.direction
                
                pattern_color 
    = switch pattern.direction
                    
    "BOĞA" => color.new(color.lime20)
                    
    "AYI" => color.new(color.red20)
                    => 
    color.new(color.yellow20)
                    
                
    table.cell(explanation_table01pattern.namebgcolor=pattern_colortext_color=color.whitetext_size=text_size_val)
                
    table.cell(explanation_table11explanationbgcolor=color.new(color.black60), text_color=color.whitetext_size=text_size_val)
        else
            
    table.cell(explanation_table01"TARANIYOR..."text_color=color.graytext_size=text_size_val)
            
    table.cell(explanation_table11"BULUNAMADI"text_color=color.graytext_size=text_size_val)

    // Table update
    if show_table and barstate.islast
        table
    .cell(pattern_table00"MODELLEME"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table10"YÖN"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table20"OLASILIK"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table30"DURUM"bgcolor=color.bluetext_color=color.white)
        
        if array.
    size(detected_patterns) > 0
            display_count 
    math.min(array.size(detected_patterns), max_patterns)
            for 
    0 to display_count 1
                pattern 
    = array.get(detected_patternsi)
                
                
    dir_color = switch pattern.direction
                    
    "BOĞA" => color.lime
                    
    "AYI" => color.red
                    
    => color.yellow
                
                conf_color 
    pattern.confidence >= 80 color.lime pattern.confidence >= 70 color.yellow color.gray
                
                table
    .cell(pattern_table01pattern.nametext_color=color.white)
                
    table.cell(pattern_table11pattern.directiontext_color=dir_color)
                
    table.cell(pattern_table21str.tostring(pattern.confidence"#") + "%"text_color=conf_color)
                
    table.cell(pattern_table31"AKTİF"text_color=color.aqua)
        else
            
    table.cell(pattern_table01"MODEL YOK"text_color=color.gray)
            
    table.cell(pattern_table11"-"text_color=color.gray)
            
    table.cell(pattern_table21"-"text_color=color.gray)
            
    table.cell(pattern_table31"BEKLE"text_color=color.gray)

    // Background color
    bg_color color(na)
    if array.
    size(detected_patterns) > 0
        top_pattern 
    = array.get(detected_patterns0)
        
    bg_color := switch top_pattern.direction
            
    "BOĞA" => color.new(color.green95)
            
    "AYI" => color.new(color.red95)
            => 
    color.new(color.yellow95)

    //bgcolor(bg_color)

    // S/R levels
    plot(highest_price"DİRENÇ"color=color.new(#ff5252, 100), linewidth=1, style=plot.style_stepline)
    plot(lowest_price"DESTEK"color=color.new(#4caf4f, 100), linewidth=1, style=plot.style_stepline)
    plot(mid_price"ORTALAMA"color=color.new(#787b86, 100), linewidth=1, style=plot.style_stepline)

    // Alerts
    if array.size(detected_patterns) > 0
        top_pattern 
    = array.get(detected_patterns0)
        
    alert_msg "MODEL BULUNDU: " top_pattern.name " [" top_pattern.direction "] OLASILIK: " str.tostring(top_pattern.confidence"#") + "%"
        
    if array.size(detected_patterns) > 1
            alert_msg 
    += " (+" str.tostring(array.size(detected_patterns) - 1) + " more)"
        
    alert(alert_msgalert.freq_once_per_bar)

    // Alert conditions
    alertcondition(array.size(detected_patterns) > and array.get(detected_patterns0).direction == "BOĞA""MODEL""BULUNDU")
    alertcondition(array.size(detected_patterns) > and array.get(detected_patterns0).direction == "AYI""MODEL""BULUNDU")
    alertcondition(array.size(detected_patterns) > 0"MODEL""YENİ MODEL VAR"

  6. scalp için...
    PHP Code:
    //@version=6
    indicator("."overlay=truemax_bars_back=500)

    // ============================================
    // INPUT PARAMETERS
    // ============================================
    g1 "ARAMA AYARLARI"
    lookback input.int(20"MODEL PERİYOT"minval=20maxval=200group=g1)
    sensitivity input.float(0.0025"DUYARLILIK"minval=0.0005maxval=0.01step=0.0005group=g1)
    min_touches input.int(2"TEST ADET"minval=2maxval=5group=g1)

    g2 "KLASİK MODELLER"
    detect_classic input.bool(true"▼ KLASİK MODELLER"group=g2)
    classic_double input.bool(true"├ İKİLİ TEPE/DİP"group=g2)
    classic_triple input.bool(true"├ ÜÇLÜ TEPE/DİP"group=g2)
    classic_hs input.bool(true"├ BAŞ & OMUZLAR"group=g2)
    classic_rounding input.bool(true"└ YUVARLAMA"group=g2)

    g3 "ÜÇGEN MODELLER"
    detect_triangles input.bool(true"▼ ÜÇGEN MODELLER"group=g3)
    tri_ascending input.bool(true"├ YÜKSELEN ÜÇGEN"group=g3)
    tri_descending input.bool(true"├ ALÇALAN ÜÇGEN"group=g3)
    tri_symmetrical input.bool(true"├ SİMETRİK ÜÇGEN"group=g3)
    tri_expanding input.bool(true"└ GENİŞLEYEN ÜÇGEN"group=g3)

    g4 "DEVAM MODELLERİ"
    detect_continuation input.bool(true"▼ DEVAM MODELLERİ"group=g4)
    cont_flag input.bool(true"├ FLAMA"group=g4)
    cont_pennant input.bool(true"├ FLAMALAR"group=g4)
    cont_wedge input.bool(true"├ TAKOZLAR"group=g4)
    cont_channel input.bool(true"├ KANALLAR"group=g4)
    cont_rectangle input.bool(true"└ DİKDÖRTGENLER"group=g4)

    g5 "HARMONİK MODELLER"
    detect_harmonic input.bool(true"▼ HARMONİK MODELLER"group=g5)
    harm_gartley input.bool(true"├ FİBO"group=g5)
    harm_butterfly input.bool(true"├ KELEBEK"group=g5)
    harm_bat input.bool(true"├ YARASA"group=g5)
    harm_crab input.bool(true"├ YENGEÇ"group=g5)
    harm_shark input.bool(true"├ KÖPEKBALIĞI"group=g5)
    harm_cypher input.bool(true"└ DÖRTLÜ"group=g5)

    g6 "FİYAT MODELLERİ"
    detect_price_action input.bool(true"▼ FİYAT MODELLERİ"group=g6)
    pa_pin_bar input.bool(true"├ PİN BAR"group=g6)
    pa_inside input.bool(true"├ İÇ BAR"group=g6)
    pa_outside input.bool(true"├ DIŞ BAR"group=g6)
    pa_engulfing input.bool(true"├ YUTMA"group=g6)
    pa_doji input.bool(true"├ DOJİ"group=g6)
    pa_hammer input.bool(true"└ ÇEKİÇ"group=g6)

    g7 "ÖZEL MODELLER"
    detect_special input.bool(true"▼ ÖZEL MODELLER"group=g7)
    spec_diamond input.bool(true"├ ELMAS"group=g7)
    spec_cup input.bool(true"├ FİNCAN & KULP"group=g7)
    spec_vbottom input.bool(true"├ V-DİP/ZİRVE"group=g7)
    spec_broadening input.bool(true"├ GENİŞLEME"group=g7)
    spec_island input.bool(true"└ ADA DÖNÜŞ"group=g7)

    g8 "AYARLAR"
    show_patterns input.bool(true"MODEL"group=g8)
    show_confidence input.bool(true"OLASILIK"group=g8)
    show_table input.bool(true"ARAMA"group=g8)
    show_explanation input.bool(true"SEBEP"group=g8)
    show_pivot_points input.bool(true"PİVOT"group=g8)
    show_key_levels input.bool(true"GİRİŞ"group=g8)
    show_targets input.bool(true"HEDEF"group=g8)
    max_patterns input.int(5"SAYIM"minval=1maxval=10group=g8)

    g9 "Panel Position Settings"
    table_position input.string("top_right""Detection Table Position"options=["top_left""top_center""top_right""middle_left""middle_center""middle_right""bottom_left""bottom_center""bottom_right"], group=g9)
    explanation_position input.string("middle_right""Explanation Panel Position"options=["top_left""top_center""top_right""middle_left""middle_center""middle_right""bottom_left""bottom_center""bottom_right"], group=g9)
    panel_transparency input.int(80"Panel Transparency"minval=0maxval=100group=g9)
    panel_text_size input.string("normal""Text Size"options=["tiny""small""normal""large""huge"], group=g9)

    // ============================================
    // GLOBAL VARIABLES & STRUCTURES
    // ============================================
    type PatternInfo
        string name
        string direction  
    // bullish/bearish/neutral
        
    float confidence
        int start_bar
        int end_bar
        float level1
        float level2

    var array<PatternInfodetected_patterns = array.new<PatternInfo>()
    var 
    table pattern_table na
    var table explanation_table na
    var line[] pattern_lines = array.new_line()
    var 
    label[] pattern_labels = array.new_label()
    var 
    box[] pattern_boxes = array.new_box()

    // Position conversion function
    get_table_position(pos_string) =>
        switch 
    pos_string
            
    "top_left" => position.top_left
            
    "top_center" => position.top_center
            
    "top_right" => position.top_right
            
    "middle_left" => position.middle_left
            
    "middle_center" => position.middle_center
            
    "middle_right" => position.middle_right
            
    "bottom_left" => position.bottom_left
            
    "bottom_center" => position.bottom_center
            
    "bottom_right" => position.bottom_right
            
    => position.top_right

    // Table initialization
    if barstate.isfirst or barstate.isconfirmed
        
    if not na(pattern_table)
            
    table.delete(pattern_table)
        if 
    not na(explanation_table)
            
    table.delete(explanation_table)
        
        if 
    show_table
            pattern_table 
    := table.new(get_table_position(table_position), 4max_patterns 1bgcolor=color.new(color.blackpanel_transparency))
        if 
    show_explanation
            explanation_table 
    := table.new(get_table_position(explanation_position), 2max_patterns 1bgcolor=color.new(color.blackpanel_transparency), border_width=2)

    // ============================================
    // BASIC CALCULATIONS
    // ============================================
    highest_price ta.highest(highlookback)
    lowest_price ta.lowest(lowlookback)
    mid_price = (highest_price lowest_price) / 2

    // ATR for volatility
    atr ta.atr(14)
    volatility atr close

    // ============================================
    // PATTERN DETECTION FUNCTIONS
    // ============================================

    // Pivot detection
    findPivotPoints(len) =>
        var 
    pivotHighs = array.new_float()
        var 
    pivotLows = array.new_float()
        var 
    pivotHighBars = array.new_int()
        var 
    pivotLowBars = array.new_int()
        
        for 
    len to lookback len
            isHigh 
    true
            isLow 
    true
            
    for = -len to len
                
    if high[i+j] > high[i]
                    
    isHigh := false
                
    if low[i+j] < low[i]
                    
    isLow := false
            
            
    if isHigh
                
    array.push(pivotHighshigh[i])
                array.
    push(pivotHighBarsi)
            if 
    isLow
                
    array.push(pivotLowslow[i])
                array.
    push(pivotLowBarsi)
        
        [
    pivotHighspivotLowspivotHighBarspivotLowBars]

    // Fibonacci ratio check
    checkFibRatio(val1val2target_ratiotolerance) =>
        
    ratio val2 val1
        math
    .abs(ratio target_ratio) < tolerance

    // 1. Double Top/Bottom Detection
    detectDoublePatterns() =>
        if 
    not detect_classic or not classic_double
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            
    // Double Top
            
    if array.size(highs) >= 2
                
    for 0 to math.min(array.size(highs) - 210)
                    
    h1 = array.get(highsi)
                    
    h2 = array.get(highs1)
                    
    diff math.abs(h1 h2) / h1
                    
                    
    if diff sensitivity
                        neckline 
    lowest_price
                        
    if close neckline 0.995
                            PatternInfo
    .new("İKİLİ TEPE""AYI"85bar_index lookbackbar_indexh1neckline)
            
            
    // Double Bottom
            
    if array.size(lows) >= 2
                
    for 0 to math.min(array.size(lows) - 210)
                    
    l1 = array.get(lowsi)
                    
    l2 = array.get(lows1)
                    
    diff math.abs(l1 l2) / l1
                    
                    
    if diff sensitivity
                        neckline 
    highest_price
                        
    if close neckline 1.005
                            PatternInfo
    .new("İKİLİ DİP""BOĞA"85bar_index lookbackbar_indexnecklinel1)
            
            
    PatternInfo.new(""""00000)

    // 2. Triple Top/Bottom
    detectTriplePatterns() =>
        if 
    not detect_classic or not classic_triple
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= 3
                
    for 0 to math.min(array.size(highs) - 35)
                    
    h1 = array.get(highsi)
                    
    h2 = array.get(highs1)
                    
    h3 = array.get(highs2)
                    
                    
    diff1 math.abs(h1 h2) / h1
                    diff2 
    math.abs(h2 h3) / h2
                    
                    
    if diff1 sensitivity and diff2 sensitivity
                        PatternInfo
    .new("ÜÇLÜ TEPE""AYI"90bar_index lookbackbar_indexh1lowest_price)
            
            
    PatternInfo.new(""""00000)

    // 3. Head & Shoulders
    detectHeadShoulders() =>
        if 
    not detect_classic or not classic_hs
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= 3
                
    for 0 to math.min(array.size(highs) - 35)
                    
    left = array.get(highsi)
                    
    head = array.get(highs1)
                    
    right = array.get(highs2)
                    
                    if 
    head left and head right
                        shoulder_diff 
    math.abs(left right) / left
                        
    if shoulder_diff sensitivity 2
                            PatternInfo
    .new("BAŞ & OMUZLAR""AYI"88bar_index lookbackbar_indexheadmath.min(leftright))
            
            if array.
    size(highs) >= 5
                
    for 0 to math.min(array.size(highs) - 53)
                    
    ls1 = array.get(highsi)
                    
    ls2 = array.get(highs1)
                    
    head = array.get(highs2)
                    
    rs1 = array.get(highs3)
                    
    rs2 = array.get(highs4)
                    
                    
    avg_left = (ls1 ls2) / 2
                    avg_right 
    = (rs1 rs2) / 2
                    
                    
    if head avg_left and head avg_right
                        PatternInfo
    .new("BAŞ OMUZ""AYI"82bar_index lookbackbar_indexheadmath.min(avg_leftavg_right))
            
            
    PatternInfo.new(""""00000)

    // 4. Triangle Patterns
    detectTriangles() =>
        if 
    not detect_triangles
            PatternInfo
    .new(""""00000)
        else
            
    upper_trend ta.linreg(highlookback0) - ta.linreg(highlookbacklookback 1)
            
    lower_trend ta.linreg(lowlookback0) - ta.linreg(lowlookbacklookback 1)
            
            
    range_start highest_price lowest_price
            range_end 
    high low
            converging 
    range_end range_start 0.7
            diverging 
    range_end range_start 1.3
            
            
    if tri_ascending and math.abs(upper_trend) < volatility and lower_trend volatility and converging
                PatternInfo
    .new("YÜKSELEN ÜÇGEN""BOĞA"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_descending and upper_trend < -volatility and math.abs(lower_trend) < volatility and converging
                PatternInfo
    .new("ALÇALAN ÜÇGEN""AYI"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_symmetrical and math.abs(upper_trend lower_trend) < volatility and converging
                PatternInfo
    .new("SİMETRİK ÜÇGEN""BEKLE"75bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_expanding and diverging
                PatternInfo
    .new("GENİŞLEYEN ÜÇGEN""BEKLE"72bar_index lookbackbar_indexhighest_pricelowest_price)
            else
                
    PatternInfo.new(""""00000)

    // 5. Wedge Patterns
    detectWedges() =>
        if 
    not detect_continuation or not cont_wedge
            PatternInfo
    .new(""""00000)
        else
            
    upper_slope = (highest_price highest_price[lookback-1]) / lookback
            lower_slope 
    = (lowest_price lowest_price[lookback-1]) / lookback
            
            converging 
    = (high low) < (highest_price[lookback-1] - lowest_price[lookback-1]) * 0.7
            
            
    if upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("YÜKSELEN TAKOZ""AYI"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("DÜŞEN TAKOZ""BOĞA"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    math.abs(upper_slope) > volatility and math.abs(lower_slope) > volatility 2
                
    if upper_slope and lower_slope 0
                    PatternInfo
    .new("GENİŞLEYEN KAMA""AYI"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else if 
    upper_slope and lower_slope 0
                    PatternInfo
    .new("DARALAN KAMA""BOĞA"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 6. Flags & Pennants
    detectFlagsAndPennants() =>
        if 
    not detect_continuation or not (cont_flag or cont_pennant)
            
    PatternInfo.new(""""00000)
        else
            
    prior_trend close[lookback] - close[lookback 2]
            
    recent_slope ta.linreg(close100) - ta.linreg(close109)
            
    recent_high ta.highest(high10)
            
    recent_low ta.lowest(low10)
            
    recent_range recent_high recent_low
            prior_range 
    ta.highest(high20)[10] - ta.lowest(low20)[10]
            
            
    is_consolidation recent_range prior_range 0.5
            
            
    if cont_flag and is_consolidation
                
    if prior_trend and recent_slope 0
                    PatternInfo
    .new("FLAMA""BOĞA"74bar_index 10bar_indexrecent_highrecent_low)
                else if 
    prior_trend and recent_slope 0
                    PatternInfo
    .new("FLAMA""AYI"74bar_index 10bar_indexrecent_highrecent_low)
                else if 
    math.abs(recent_slope) < volatility
                    PatternInfo
    .new("FLAMA YATAY""BEKLE"72bar_index 10bar_indexrecent_highrecent_low)
                else
                    
    PatternInfo.new(""""00000)
            
            else if 
    cont_pennant and is_consolidation and recent_range recent_range[5] * 0.7
                
    if prior_trend 0
                    PatternInfo
    .new("BOĞA""BOĞA"73bar_index 10bar_indexrecent_highrecent_low)
                else if 
    prior_trend 0
                    PatternInfo
    .new("AYI""AYI"73bar_index 10bar_indexrecent_highrecent_low)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 7. Harmonic Patterns (simplified)
    detectHarmonicPatterns() =>
        if 
    not detect_harmonic
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= and array.size(lows) >= 3
                X 
    = array.get(lows0)
                
    = array.get(highs0)
                
    = array.get(lows1)
                
    = array.get(highs1)
                
    close
                
                XA 
    X
                AB 
    B
                BC 
    B
                CD 
    D
                
                
    if harm_gartley and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC0.7860.05)
                    
    PatternInfo.new("FİBO""BOĞA"80bar_index lookbackbar_indexCD)
                else if 
    harm_butterfly and checkFibRatio(XAAB0.7860.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("KELEBEK""BOĞA"78bar_index lookbackbar_indexCD)
                else if 
    harm_bat and checkFibRatio(XAAB0.3820.05) and checkFibRatio(ABBC0.8860.05)
                    
    PatternInfo.new("YARASA""BOĞA"77bar_index lookbackbar_indexCD)
                else if 
    harm_crab and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("YENGEÇ""BOĞA"76bar_index lookbackbar_indexCD)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 8. Price Action Patterns
    detectPriceAction() =>
        if 
    not detect_price_action
            PatternInfo
    .new(""""00000)
        else
            
    body math.abs(close open)
            
    upper_shadow high math.max(openclose)
            
    lower_shadow math.min(openclose) - low
            prev_body 
    math.abs(close[1] - open[1])
            
    avg_body ta.sma(math.abs(close open), 20)
            
    sma20 ta.sma(close20)
            
            if 
    pa_pin_bar and (upper_shadow body or lower_shadow body 2)
                
    direction lower_shadow upper_shadow "BOĞA" "AYI"
                
    PatternInfo.new("Pin Bar"direction70bar_indexbar_indexhighlow)
            else if 
    pa_inside and high high[1] and low low[1]
                
    PatternInfo.new("İÇ BAR""BEKLE"68bar_index 1bar_indexhigh[1], low[1])
            else if 
    pa_outside and high high[1] and low low[1]
                
    PatternInfo.new("DIŞ BAR""BEKLE"68bar_index 1bar_indexhighlow)
            else if 
    pa_engulfing and body prev_body 1.5
                
    if close open and close high[1] and open low[1]
                    
    PatternInfo.new("BOĞA YUTAN""BOĞA"72bar_index 1bar_indexhighlow)
                else if 
    close open and close low[1] and open high[1]
                    
    PatternInfo.new("AYI YUTAN""AYI"72bar_index 1bar_indexhighlow)
                else
                    
    PatternInfo.new(""""00000)
            else if 
    pa_doji and body avg_body 0.1
                
    if upper_shadow avg_body and lower_shadow avg_body
                    PatternInfo
    .new("Doji""BEKLE"65bar_indexbar_indexhighlow)
                else if 
    upper_shadow lower_shadow 2
                    PatternInfo
    .new("EJDERHA""BOĞA"66bar_indexbar_indexhighlow)
                else if 
    lower_shadow upper_shadow 2
                    PatternInfo
    .new("MEZARTAŞI""AYI"66bar_indexbar_indexhighlow)
                else
                    
    PatternInfo.new(""""00000)
            else if 
    pa_hammer and lower_shadow body and upper_shadow body 0.3
                
    if close sma20
                    PatternInfo
    .new("ÇEKİÇ""BOĞA"69bar_indexbar_indexhighlow)
                else
                    
    PatternInfo.new("ÇEKİÇ""AYI"69bar_indexbar_indexhighlow)
            else
                
    PatternInfo.new(""""00000)

    // 9. Special Patterns
    detectSpecialPatterns() =>
        if 
    not detect_special
            PatternInfo
    .new(""""00000)
        else
            if 
    spec_cup
                cup_depth 
    lowest_price[20] < lowest_price 0.85
                cup_recovery 
    close highest_price[20] * 0.95
                handle_forming 
    high highest_price[5] * 0.98
                
                
    if cup_depth and cup_recovery and handle_forming
                    PatternInfo
    .new("FİNCAN & KULP""BOĞA"82bar_index 30bar_indexhighest_pricelowest_price)
            
            if 
    spec_vbottom
                sharp_decline 
    lowest_price lowest_price[10] * 0.9
                sharp_recovery 
    close highest_price[5] * 0.95
                
                
    if sharp_decline and sharp_recovery
                    PatternInfo
    .new("V-DİP""BOĞA"75bar_index 10bar_indexhighest_price[10], lowest_price)
                else if 
    close lowest_price[5] * 1.05 and highest_price highest_price[10] * 1.1
                    PatternInfo
    .new("V-ZİRVE""AYI"75bar_index 10bar_indexhighest_pricelowest_price[10])
                else
                    
    PatternInfo.new(""""00000)
            
            else if 
    spec_diamond
                mid_expand 
    = (ta.highest(high25)[12] - ta.lowest(low25)[12]) > (ta.highest(high50)[25] - ta.lowest(low50)[25]) * 1.2
                end_contract 
    = (high low) < (ta.highest(high25)[12] - ta.lowest(low25)[12]) * 0.7
                
                
    if mid_expand and end_contract
                    PatternInfo
    .new("ELMAS""BEKLE"77bar_index lookbackbar_indexhighest_pricelowest_price)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // ============================================
    // MAIN PROCESSING
    // ============================================

    // Clear detected patterns
    array.clear(detected_patterns)

    // Execute detection functions
    patterns_to_check = array.new<PatternInfo>()
    array.
    push(patterns_to_checkdetectDoublePatterns())
    array.
    push(patterns_to_checkdetectTriplePatterns())
    array.
    push(patterns_to_checkdetectHeadShoulders())
    array.
    push(patterns_to_checkdetectTriangles())
    array.
    push(patterns_to_checkdetectWedges())
    array.
    push(patterns_to_checkdetectFlagsAndPennants())
    array.
    push(patterns_to_checkdetectHarmonicPatterns())
    array.
    push(patterns_to_checkdetectPriceAction())
    array.
    push(patterns_to_checkdetectSpecialPatterns())

    // Keep only valid patterns
    for 0 to array.size(patterns_to_check) - 1
        pattern 
    = array.get(patterns_to_checki)
        if 
    pattern.name != ""
            
    array.push(detected_patternspattern)

    // Sort by confidence (descending)
    if array.size(detected_patterns) > 1
        
    for 0 to array.size(detected_patterns) - 2
            
    for 0 to array.size(detected_patterns) - 2
                
    if < array.size(detected_patterns)
                    if array.
    get(detected_patternsj).confidence < array.get(detected_patterns1).confidence
                        temp 
    = array.get(detected_patternsj)
                        array.
    set(detected_patternsj, array.get(detected_patterns1))
                        array.
    set(detected_patterns1temp)

    // ============================================
    // VISUALIZATION
    // ============================================

    // Clear old drawings
    if barstate.islast
        
    for line in pattern_lines
            line
    .delete(line)
        array.
    clear(pattern_lines)
        
        for 
    lbl in pattern_labels
            label
    .delete(lbl)
        array.
    clear(pattern_labels)
        
        for 
    bx in pattern_boxes
            box
    .delete(bx)
        array.
    clear(pattern_boxes)

    // Draw patterns
    if show_patterns and barstate.islast and array.size(detected_patterns) > 0
        display_count 
    math.min(array.size(detected_patterns), max_patterns)
        for 
    0 to display_count 1
            pattern 
    = array.get(detected_patternsi)
            
            
    // Color settings
            
    pattern_color = switch pattern.direction
                
    "BOĞA" => color.new(color.lime20)
                
    "AYI" => color.new(color.red20)
                => 
    color.new(color.yellow20)
            
            
    // Target price calculation
            
    float target_price na
            float target_distance 
    0.0
            string target_label_text 
    ""
            
            
    // Pattern-specific drawing
            
    if str.contains(pattern.name"İKİLİ") or str.contains(pattern.name"ÜÇLÜ")
                [
    highslowshighBarslowBars] = findPivotPoints(5)
                if array.
    size(highs) >= 2
                    
    for 0 to math.min(array.size(highs) - 13)
                        
    high_point = array.get(highsj)
                        
    high_bar bar_index - array.get(highBarsj)
                        
    circle_label label.new(high_barhigh_point 1.01"●"color=color.new(color.red0), textcolor=color.redstyle=label.style_label_centersize=size.tiny)
                        array.
    push(pattern_labelscircle_label)
                if array.
    size(lows) >= 2
                    
    for 0 to math.min(array.size(lows) - 13)
                        
    low_point = array.get(lowsj)
                        
    low_bar bar_index - array.get(lowBarsj)
                        
    circle_label label.new(low_barlow_point 0.99"●"color=color.new(color.green0), textcolor=color.greenstyle=label.style_label_centersize=size.tiny)
                        array.
    push(pattern_labelscircle_label)
                
                
    // Neckline
                
    neckline str.contains(pattern.name"ZİRVE") ? pattern.level2 pattern.level1
                neck_line 
    line.new(pattern.start_barnecklinepattern.end_bar 10necklinecolor=color.new(color.orange0), width=2style=line.style_solid)
                array.
    push(pattern_linesneck_line)
                
    neck_label label.new(pattern.end_bar 5neckline"BOYUN"color=color.new(color.orange80), textcolor=color.whitestyle=label.style_label_leftsize=size.tiny)
                array.
    push(pattern_labelsneck_label)
                
                
    // Target calculation
                
    if str.contains(pattern.name"ZİRVE")
                    
    target_distance pattern.level1 neckline
                    target_price 
    := neckline target_distance
                    target_label_text 
    := "HEDEF ↓"
                
    else
                    
    target_distance neckline pattern.level2
                    target_price 
    := neckline target_distance
                    target_label_text 
    := "HEDEF ↑"
            
            
    else if str.contains(pattern.name"ÜÇGENLER") or str.contains(pattern.name"TAKOZLAR")
                
    upper_line line.new(pattern.start_barpattern.level1pattern.end_barpattern.level1 - (pattern.level1 pattern.level2) * 0.3color=pattern_colorwidth=2style=line.style_solid)
                
    lower_line line.new(pattern.start_barpattern.level2pattern.end_barpattern.level2 + (pattern.level1 pattern.level2) * 0.3color=pattern_colorwidth=2style=line.style_solid)
                array.
    push(pattern_linesupper_line)
                array.
    push(pattern_lineslower_line)
                
                
    convergence_label label.new(pattern.end_bar 5, (pattern.level1 pattern.level2) / 2str.contains(pattern.name"GENİŞLEYEN") ? "GENİŞLEYEN→" "←DARALAN→"color=color.new(pattern_color80), textcolor=color.whitestyle=label.style_label_centersize=size.tiny)
                array.
    push(pattern_labelsconvergence_label)
                
                
    // Target calculation
                
    pattern_height pattern.level1 pattern.level2
                
    if pattern.direction == "BOĞA"
                    
    target_price := pattern.level1 pattern_height
                    target_label_text 
    := "HEDEF ↑"
                
    else if pattern.direction == "AYI"
                    
    target_price := pattern.level2 pattern_height
                    target_label_text 
    := "HEDEF ↓"
                
    else
                    
    target_price := close > (pattern.level1 pattern.level2) / pattern.level1 pattern_height pattern.level2 pattern_height
                    target_label_text 
    := "HEDEF"
            
            
    else if str.contains(pattern.name"BAŞ") and str.contains(pattern.name"OMUZLAR")
                [
    highslowshighBarslowBars] = findPivotPoints(5)
                if array.
    size(highs) >= 3
                    max_high_idx 
    0
                    max_high_val 
    0.0
                    
    for 0 to math.min(array.size(highs) - 14)
                        if array.
    get(highsj) > max_high_val
                            max_high_val 
    := array.get(highsj)
                            
    max_high_idx := j
                    
                    head_bar 
    bar_index - array.get(highBarsmax_high_idx)
                    
    head_label label.new(head_barmax_high_val 1.01"BAŞ"color=color.redtextcolor=color.whitestyle=label.style_label_downsize=size.small)
                    array.
    push(pattern_labelshead_label)
                    
                    for 
    0 to math.min(array.size(highs) - 14)
                        if 
    != max_high_idx
                            shoulder_bar 
    bar_index - array.get(highBarsj)
                            
    shoulder_val = array.get(highsj)
                            
    shoulder_label label.new(shoulder_barshoulder_val 1.01"S"color=color.orangetextcolor=color.whitestyle=label.style_label_downsize=size.tiny)
                            array.
    push(pattern_labelsshoulder_label)
                    
                    
    // Target calculation
                    
    neckline_hs pattern.level2
                    head_distance 
    max_high_val neckline_hs
                    target_price 
    := neckline_hs head_distance
                    target_label_text 
    := "HEDEF ↓"
            
            
    else if str.contains(pattern.name"FLAMA") or str.contains(pattern.name"FLAMALAR")
                
    pole_start pattern.start_bar 20
                pole_end 
    pattern.start_bar
                pole_line 
    line.new(pole_startlowest_price[20], pole_endhighest_pricecolor=color.new(color.blue50), width=3style=line.style_solid)
                array.
    push(pattern_linespole_line)
                
    pole_label label.new(pole_start, (highest_price lowest_price[20]) / 2"@YÖRÜK@"color=color.bluetextcolor=color.whitestyle=label.style_label_rightsize=size.tiny)
                array.
    push(pattern_labelspole_label)
                
                
    flag_box box.new(pattern.start_barpattern.level1pattern.end_barpattern.level2bgcolor=color.new(pattern_color90), border_color=pattern_colorborder_width=2)
                array.
    push(pattern_boxesflag_box)
                
                
    // Target calculation
                
    pole_height highest_price lowest_price[20]
                if 
    str.contains(pattern.name"BOĞA")
                    
    target_price := pattern.level1 pole_height
                    target_label_text 
    := "HEDEF ↑"
                
    else if str.contains(pattern.name"AYI")
                    
    target_price := pattern.level2 pole_height
                    target_label_text 
    := "HEDEF ↓"
            
            
    else if str.contains(pattern.name"ÇEKİÇ") or str.contains(pattern.name"PİN BAR")
                
    body_box box.new(bar_index 1math.max(openclose), bar_indexmath.min(openclose), bgcolor=color.new(pattern_color50), border_color=pattern_color)
                array.
    push(pattern_boxesbody_box)
                
                
    shadow_line line.new(bar_indexhighbar_indexlowcolor=pattern_colorwidth=3style=line.style_solid)
                array.
    push(pattern_linesshadow_line)
                
                
    shadow_ratio str.contains(pattern.name"ÇEKİÇ") ? (math.min(openclose) - low) / math.abs(close open) : (high math.max(openclose)) / math.abs(close open)
                
                
    ratio_label label.new(bar_indexlow 0.99"FİTİL/BAR: " str.tostring(shadow_ratio"#.#") + "x"color=pattern_colortextcolor=color.whitestyle=label.style_label_upsize=size.tiny)
                array.
    push(pattern_labelsratio_label)
                
                
    // Target calculation
                
    candle_range high low
                
    if pattern.direction == "BOĞA"
                    
    target_price := close candle_range 2
                    target_label_text 
    := "HEDEF ↑"
                
    else
                    
    target_price := close candle_range 2
                    target_label_text 
    := "HEDEF ↓"
            
            
    // Display target prices
            
    if show_targets and not na(target_price)
                
    target_box box.new(bar_indexclosebar_index 30target_pricebgcolor=color.new(pattern.direction == "BOĞA" color.green color.red95), border_color=pattern.direction == "BOĞA" color.green color.redborder_width=1border_style=line.style_dashed)
                array.
    push(pattern_boxestarget_box)
                
                
    target_line line.new(bar_indextarget_pricebar_index 30target_pricecolor=pattern.direction == "BOĞA" color.green color.redwidth=2style=line.style_dashed)
                array.
    push(pattern_linestarget_line)
                
                
    price_change target_price close
                price_change_percent 
    = (price_change close) * 100
                target_text 
    target_label_text "\n$" str.tostring(target_price"#,###.##") + "\n(" str.tostring(price_change_percent"+#.##") + "%)"
                
    target_label label.new(bar_index 30target_pricetarget_textcolor=pattern.direction == "BOĞA" color.green color.redtextcolor=color.whitestyle=pattern.direction == "BOĞA" label.style_label_up label.style_label_downsize=size.normal)
                array.
    push(pattern_labelstarget_label)
                
                
    arrow_line line.new(bar_index 15closebar_index 15target_pricecolor=pattern.direction == "BOĞA" color.green color.redwidth=3style=line.style_arrow_right)
                array.
    push(pattern_linesarrow_line)
            
            
    // Pattern name and confidence
            
    if show_confidence
                label_text 
    pattern.name "\n" str.tostring(pattern.confidence"#") + "%"
                
    main_label label.new(bar_index 2high * (0.02 i), label_textcolor=pattern_colortextcolor=color.whitestyle=label.style_label_leftsize=size.normal)
                array.
    push(pattern_labelsmain_label)

    // Explanation panel
    if show_explanation and barstate.islast
        
    // Get text size
        
    text_size_val = switch panel_text_size
            
    "tiny" => size.tiny
            
    "small" => size.small
            
    "large" => size.large
            
    "huge" => size.huge
            
    => size.normal
        
        table
    .cell(explanation_table00"🔍 BULUNAN SONUÇ"bgcolor=color.new(color.purple30), text_color=color.whitetext_size=size.large)
        
    table.cell(explanation_table10"📊 ANALİZ"bgcolor=color.new(color.purple30), text_color=color.whitetext_size=size.large)
        
        if array.
    size(detected_patterns) > 0
            display_count 
    math.min(array.size(detected_patterns), max_patterns)
            for 
    0 to display_count 1
                pattern 
    = array.get(detected_patternsi)
                
                
    explanation ""
                
    if str.contains(pattern.name"İKİLİ TEPE")
                    
    explanation := "✓ İKİ ZİRVE YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ÇİZGİSİ KIRILIM ONAYI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"İKLİ DİP")
                    
    explanation := "✓ İKİ DİP YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ÇİZGİSİ KIRILIM ONAYI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"ÜÇGENLER")
                    
    range_compression = ((high low) / (highest_price lowest_price)) * 100
                    explanation 
    := "✓ ARALIK SIKIŞMASI " str.tostring(100 range_compression"#") + "%\n" +
                                  
    "✓ TREND OLUŞTU\n" +
                                  
    "✓ ÇIKIŞ BEKLENİYOR"
                
    else if str.contains(pattern.name"BAŞ") and str.contains(pattern.name"OMUZLAR")
                    
    explanation := "✓ BAŞ OLUŞTU\n" +
                                  
    "✓ OMUZLAR SİMETRİK\n" +
                                  
    "✓ BOYUN OLUŞTU"
                
    else if str.contains(pattern.name"FLAMALAR")
                    
    explanation := "✓ FLAMA OLUŞTU\n" +
                                  
    "✓ KONSİLDASYON ONAYLANDI\n" +
                                  
    "✓ DEVAM EDEBİLİR"
                
    else if str.contains(pattern.name"TAKOZLAR")
                    
    explanation := "✓ FİYAT SIKIŞIYOR\n" +
                                  
    "✓ EĞİLİM AYNI YÖNDE\n" +
                                  
    "✓ TERSE DÖNEBİLİR"
                
    else if str.contains(pattern.name"ÇEKİÇ")
                    
    explanation := "✓ BAR BOYU\n" +
                                  
    "✓ MİNUMUMDA\n" +
                                  
    "✓ DESTEKDE"
                
    else if str.contains(pattern.name"YUTAN BARLAR")
                    
    explanation := "✓ ÖNCEKİ BAR YUTULDU\n" +
                                  
    "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"PİN BAR")
                    
    explanation := "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ DİKKAT TERSE DÖNÜŞ\n" +
                                  
    "✓ SIKIŞMA ARTI"
                
    else if str.contains(pattern.name"İÇ BAR")
                    
    explanation := "✓ ÖNCEKİ BAR ARALIĞINDA\n" +
                                  
    "✓ FİYAT HAREKET AZALDI\n" +
                                  
    "✓ DİKKAT YÜKSELEBİLİR"
                
    else if str.contains(pattern.name"DIŞ BAR")
                    
    explanation := "✓ ÖNCEKİ BAR YUTULDU\n" +
                                  
    "✓ ARALIK ARTIYOR\n" +
                                  
    "✓ DİKKAT TREND DEĞİŞİMİ OLABİLİR"
                
    else
                    
    explanation := "✓ MODEL ONAYI\n" +
                                  
    "✓ OLASILIK: " str.tostring(pattern.confidence"#") + "%\n" +
                                  
    "✓ YÖN: " pattern.direction
                
                pattern_color 
    = switch pattern.direction
                    
    "BOĞA" => color.new(color.lime20)
                    
    "AYI" => color.new(color.red20)
                    => 
    color.new(color.yellow20)
                    
                
    table.cell(explanation_table01pattern.namebgcolor=pattern_colortext_color=color.whitetext_size=text_size_val)
                
    table.cell(explanation_table11explanationbgcolor=color.new(color.black60), text_color=color.whitetext_size=text_size_val)
        else
            
    table.cell(explanation_table01"TARANIYOR..."text_color=color.graytext_size=text_size_val)
            
    table.cell(explanation_table11"BULUNAMADI"text_color=color.graytext_size=text_size_val)

    // Table update
    if show_table and barstate.islast
        table
    .cell(pattern_table00"MODELLEME"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table10"YÖN"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table20"OLASILIK"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table30"DURUM"bgcolor=color.bluetext_color=color.white)
        
        if array.
    size(detected_patterns) > 0
            display_count 
    math.min(array.size(detected_patterns), max_patterns)
            for 
    0 to display_count 1
                pattern 
    = array.get(detected_patternsi)
                
                
    dir_color = switch pattern.direction
                    
    "BOĞA" => color.lime
                    
    "AYI" => color.red
                    
    => color.yellow
                
                conf_color 
    pattern.confidence >= 80 color.lime pattern.confidence >= 70 color.yellow color.gray
                
                table
    .cell(pattern_table01pattern.nametext_color=color.white)
                
    table.cell(pattern_table11pattern.directiontext_color=dir_color)
                
    table.cell(pattern_table21str.tostring(pattern.confidence"#") + "%"text_color=conf_color)
                
    table.cell(pattern_table31"AKTİF"text_color=color.aqua)
        else
            
    table.cell(pattern_table01"MODEL YOK"text_color=color.gray)
            
    table.cell(pattern_table11"-"text_color=color.gray)
            
    table.cell(pattern_table21"-"text_color=color.gray)
            
    table.cell(pattern_table31"BEKLE"text_color=color.gray)

    // Background color
    bg_color color(na)
    if array.
    size(detected_patterns) > 0
        top_pattern 
    = array.get(detected_patterns0)
        
    bg_color := switch top_pattern.direction
            
    "BOĞA" => color.new(color.green95)
            
    "AYI" => color.new(color.red95)
            => 
    color.new(color.yellow95)

    //bgcolor(bg_color)

    // S/R levels
    plot(highest_price"DİRENÇ"color=color.new(#ff5252, 100), linewidth=1, style=plot.style_stepline)
    plot(lowest_price"DESTEK"color=color.new(#4caf4f, 100), linewidth=1, style=plot.style_stepline)
    plot(mid_price"ORTALAMA"color=color.new(#787b86, 100), linewidth=1, style=plot.style_stepline)

    // Alerts
    if array.size(detected_patterns) > 0
        top_pattern 
    = array.get(detected_patterns0)
        
    alert_msg "MODEL BULUNDU: " top_pattern.name " [" top_pattern.direction "] OLASILIK: " str.tostring(top_pattern.confidence"#") + "%"
        
    if array.size(detected_patterns) > 1
            alert_msg 
    += " (+" str.tostring(array.size(detected_patterns) - 1) + " more)"
        
    alert(alert_msgalert.freq_once_per_bar)

    // Alert conditions
    alertcondition(array.size(detected_patterns) > and array.get(detected_patterns0).direction == "BOĞA""MODEL""BULUNDU")
    alertcondition(array.size(detected_patterns) > and array.get(detected_patterns0).direction == "AYI""MODEL""BULUNDU")
    alertcondition(array.size(detected_patterns) > 0"MODEL""YENİ MODEL VAR"

  7. 0.0005 duyarlılık ve 1 atr hesaplamalı olan...

    PHP Code:
    //@version=6
    indicator("."overlay=truemax_bars_back=100)

    // ============================================
    // INPUT PARAMETERS
    // ============================================
    g1 "ARAMA AYARLARI"
    lookback input.int(20"MODEL PERİYOT"minval=20maxval=200group=g1)
    sensitivity input.float(0.0005"DUYARLILIK"minval=0.0005maxval=0.01step=0.0005group=g1)
    min_touches input.int(2"TEST ADET"minval=2maxval=5group=g1)

    g2 "KLASİK MODELLER"
    detect_classic input.bool(true"▼ KLASİK MODELLER"group=g2)
    classic_double input.bool(true"├ İKİLİ TEPE/DİP"group=g2)
    classic_triple input.bool(true"├ ÜÇLÜ TEPE/DİP"group=g2)
    classic_hs input.bool(true"├ BAŞ & OMUZLAR"group=g2)
    classic_rounding input.bool(true"└ YUVARLAMA"group=g2)

    g3 "ÜÇGEN MODELLER"
    detect_triangles input.bool(true"▼ ÜÇGEN MODELLER"group=g3)
    tri_ascending input.bool(true"├ YÜKSELEN ÜÇGEN"group=g3)
    tri_descending input.bool(true"├ ALÇALAN ÜÇGEN"group=g3)
    tri_symmetrical input.bool(true"├ SİMETRİK ÜÇGEN"group=g3)
    tri_expanding input.bool(true"└ GENİŞLEYEN ÜÇGEN"group=g3)

    g4 "DEVAM MODELLERİ"
    detect_continuation input.bool(true"▼ DEVAM MODELLERİ"group=g4)
    cont_flag input.bool(true"├ FLAMA"group=g4)
    cont_pennant input.bool(true"├ FLAMALAR"group=g4)
    cont_wedge input.bool(true"├ TAKOZLAR"group=g4)
    cont_channel input.bool(true"├ KANALLAR"group=g4)
    cont_rectangle input.bool(true"└ DİKDÖRTGENLER"group=g4)

    g5 "HARMONİK MODELLER"
    detect_harmonic input.bool(true"▼ HARMONİK MODELLER"group=g5)
    harm_gartley input.bool(true"├ FİBO"group=g5)
    harm_butterfly input.bool(true"├ KELEBEK"group=g5)
    harm_bat input.bool(true"├ YARASA"group=g5)
    harm_crab input.bool(true"├ YENGEÇ"group=g5)
    harm_shark input.bool(true"├ KÖPEKBALIĞI"group=g5)
    harm_cypher input.bool(true"└ DÖRTLÜ"group=g5)

    g6 "FİYAT MODELLERİ"
    detect_price_action input.bool(true"▼ FİYAT MODELLERİ"group=g6)
    pa_pin_bar input.bool(true"├ PİN BAR"group=g6)
    pa_inside input.bool(true"├ İÇ BAR"group=g6)
    pa_outside input.bool(true"├ DIŞ BAR"group=g6)
    pa_engulfing input.bool(true"├ YUTMA"group=g6)
    pa_doji input.bool(true"├ DOJİ"group=g6)
    pa_hammer input.bool(true"└ ÇEKİÇ"group=g6)

    g7 "ÖZEL MODELLER"
    detect_special input.bool(true"▼ ÖZEL MODELLER"group=g7)
    spec_diamond input.bool(true"├ ELMAS"group=g7)
    spec_cup input.bool(true"├ FİNCAN & KULP"group=g7)
    spec_vbottom input.bool(true"├ V-DİP/ZİRVE"group=g7)
    spec_broadening input.bool(true"├ GENİŞLEME"group=g7)
    spec_island input.bool(true"└ ADA DÖNÜŞ"group=g7)

    g8 "AYARLAR"
    show_patterns input.bool(true"MODEL"group=g8)
    show_confidence input.bool(true"OLASILIK"group=g8)
    show_table input.bool(true"ARAMA"group=g8)
    show_explanation input.bool(true"SEBEP"group=g8)
    show_pivot_points input.bool(true"PİVOT"group=g8)
    show_key_levels input.bool(true"GİRİŞ"group=g8)
    show_targets input.bool(true"HEDEF"group=g8)
    max_patterns input.int(5"SAYIM"minval=1maxval=10group=g8)

    g9 "Panel Position Settings"
    table_position input.string("top_right""Detection Table Position"options=["top_left""top_center""top_right""middle_left""middle_center""middle_right""bottom_left""bottom_center""bottom_right"], group=g9)
    explanation_position input.string("middle_right""Explanation Panel Position"options=["top_left""top_center""top_right""middle_left""middle_center""middle_right""bottom_left""bottom_center""bottom_right"], group=g9)
    panel_transparency input.int(80"Panel Transparency"minval=0maxval=100group=g9)
    panel_text_size input.string("normal""Text Size"options=["tiny""small""normal""large""huge"], group=g9)

    // ============================================
    // GLOBAL VARIABLES & STRUCTURES
    // ============================================
    type PatternInfo
        string name
        string direction  
    // bullish/bearish/neutral
        
    float confidence
        int start_bar
        int end_bar
        float level1
        float level2

    var array<PatternInfodetected_patterns = array.new<PatternInfo>()
    var 
    table pattern_table na
    var table explanation_table na
    var line[] pattern_lines = array.new_line()
    var 
    label[] pattern_labels = array.new_label()
    var 
    box[] pattern_boxes = array.new_box()

    // Position conversion function
    get_table_position(pos_string) =>
        switch 
    pos_string
            
    "top_left" => position.top_left
            
    "top_center" => position.top_center
            
    "top_right" => position.top_right
            
    "middle_left" => position.middle_left
            
    "middle_center" => position.middle_center
            
    "middle_right" => position.middle_right
            
    "bottom_left" => position.bottom_left
            
    "bottom_center" => position.bottom_center
            
    "bottom_right" => position.bottom_right
            
    => position.top_right

    // Table initialization
    if barstate.isfirst or barstate.isconfirmed
        
    if not na(pattern_table)
            
    table.delete(pattern_table)
        if 
    not na(explanation_table)
            
    table.delete(explanation_table)
        
        if 
    show_table
            pattern_table 
    := table.new(get_table_position(table_position), 4max_patterns 1bgcolor=color.new(color.blackpanel_transparency))
        if 
    show_explanation
            explanation_table 
    := table.new(get_table_position(explanation_position), 2max_patterns 1bgcolor=color.new(color.blackpanel_transparency), border_width=2)

    // ============================================
    // BASIC CALCULATIONS
    // ============================================
    highest_price ta.highest(highlookback)
    lowest_price ta.lowest(lowlookback)
    mid_price = (highest_price lowest_price) / 2

    // ATR for volatility
    atr ta.atr(1)
    volatility atr close

    // ============================================
    // PATTERN DETECTION FUNCTIONS
    // ============================================

    // Pivot detection
    findPivotPoints(len) =>
        var 
    pivotHighs = array.new_float()
        var 
    pivotLows = array.new_float()
        var 
    pivotHighBars = array.new_int()
        var 
    pivotLowBars = array.new_int()
        
        for 
    len to lookback len
            isHigh 
    true
            isLow 
    true
            
    for = -len to len
                
    if high[i+j] > high[i]
                    
    isHigh := false
                
    if low[i+j] < low[i]
                    
    isLow := false
            
            
    if isHigh
                
    array.push(pivotHighshigh[i])
                array.
    push(pivotHighBarsi)
            if 
    isLow
                
    array.push(pivotLowslow[i])
                array.
    push(pivotLowBarsi)
        
        [
    pivotHighspivotLowspivotHighBarspivotLowBars]

    // Fibonacci ratio check
    checkFibRatio(val1val2target_ratiotolerance) =>
        
    ratio val2 val1
        math
    .abs(ratio target_ratio) < tolerance

    // 1. Double Top/Bottom Detection
    detectDoublePatterns() =>
        if 
    not detect_classic or not classic_double
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            
    // Double Top
            
    if array.size(highs) >= 2
                
    for 0 to math.min(array.size(highs) - 210)
                    
    h1 = array.get(highsi)
                    
    h2 = array.get(highs1)
                    
    diff math.abs(h1 h2) / h1
                    
                    
    if diff sensitivity
                        neckline 
    lowest_price
                        
    if close neckline 0.995
                            PatternInfo
    .new("İKİLİ TEPE""AYI"85bar_index lookbackbar_indexh1neckline)
            
            
    // Double Bottom
            
    if array.size(lows) >= 2
                
    for 0 to math.min(array.size(lows) - 210)
                    
    l1 = array.get(lowsi)
                    
    l2 = array.get(lows1)
                    
    diff math.abs(l1 l2) / l1
                    
                    
    if diff sensitivity
                        neckline 
    highest_price
                        
    if close neckline 1.005
                            PatternInfo
    .new("İKİLİ DİP""BOĞA"85bar_index lookbackbar_indexnecklinel1)
            
            
    PatternInfo.new(""""00000)

    // 2. Triple Top/Bottom
    detectTriplePatterns() =>
        if 
    not detect_classic or not classic_triple
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= 3
                
    for 0 to math.min(array.size(highs) - 35)
                    
    h1 = array.get(highsi)
                    
    h2 = array.get(highs1)
                    
    h3 = array.get(highs2)
                    
                    
    diff1 math.abs(h1 h2) / h1
                    diff2 
    math.abs(h2 h3) / h2
                    
                    
    if diff1 sensitivity and diff2 sensitivity
                        PatternInfo
    .new("ÜÇLÜ TEPE""AYI"90bar_index lookbackbar_indexh1lowest_price)
            
            
    PatternInfo.new(""""00000)

    // 3. Head & Shoulders
    detectHeadShoulders() =>
        if 
    not detect_classic or not classic_hs
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= 3
                
    for 0 to math.min(array.size(highs) - 35)
                    
    left = array.get(highsi)
                    
    head = array.get(highs1)
                    
    right = array.get(highs2)
                    
                    if 
    head left and head right
                        shoulder_diff 
    math.abs(left right) / left
                        
    if shoulder_diff sensitivity 2
                            PatternInfo
    .new("BAŞ & OMUZLAR""AYI"88bar_index lookbackbar_indexheadmath.min(leftright))
            
            if array.
    size(highs) >= 5
                
    for 0 to math.min(array.size(highs) - 53)
                    
    ls1 = array.get(highsi)
                    
    ls2 = array.get(highs1)
                    
    head = array.get(highs2)
                    
    rs1 = array.get(highs3)
                    
    rs2 = array.get(highs4)
                    
                    
    avg_left = (ls1 ls2) / 2
                    avg_right 
    = (rs1 rs2) / 2
                    
                    
    if head avg_left and head avg_right
                        PatternInfo
    .new("BAŞ OMUZ""AYI"82bar_index lookbackbar_indexheadmath.min(avg_leftavg_right))
            
            
    PatternInfo.new(""""00000)

    // 4. Triangle Patterns
    detectTriangles() =>
        if 
    not detect_triangles
            PatternInfo
    .new(""""00000)
        else
            
    upper_trend ta.linreg(highlookback0) - ta.linreg(highlookbacklookback 1)
            
    lower_trend ta.linreg(lowlookback0) - ta.linreg(lowlookbacklookback 1)
            
            
    range_start highest_price lowest_price
            range_end 
    high low
            converging 
    range_end range_start 0.7
            diverging 
    range_end range_start 1.3
            
            
    if tri_ascending and math.abs(upper_trend) < volatility and lower_trend volatility and converging
                PatternInfo
    .new("YÜKSELEN ÜÇGEN""BOĞA"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_descending and upper_trend < -volatility and math.abs(lower_trend) < volatility and converging
                PatternInfo
    .new("ALÇALAN ÜÇGEN""AYI"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_symmetrical and math.abs(upper_trend lower_trend) < volatility and converging
                PatternInfo
    .new("SİMETRİK ÜÇGEN""BEKLE"75bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_expanding and diverging
                PatternInfo
    .new("GENİŞLEYEN ÜÇGEN""BEKLE"72bar_index lookbackbar_indexhighest_pricelowest_price)
            else
                
    PatternInfo.new(""""00000)

    // 5. Wedge Patterns
    detectWedges() =>
        if 
    not detect_continuation or not cont_wedge
            PatternInfo
    .new(""""00000)
        else
            
    upper_slope = (highest_price highest_price[lookback-1]) / lookback
            lower_slope 
    = (lowest_price lowest_price[lookback-1]) / lookback
            
            converging 
    = (high low) < (highest_price[lookback-1] - lowest_price[lookback-1]) * 0.7
            
            
    if upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("YÜKSELEN TAKOZ""AYI"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("DÜŞEN TAKOZ""BOĞA"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    math.abs(upper_slope) > volatility and math.abs(lower_slope) > volatility 2
                
    if upper_slope and lower_slope 0
                    PatternInfo
    .new("GENİŞLEYEN KAMA""AYI"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else if 
    upper_slope and lower_slope 0
                    PatternInfo
    .new("DARALAN KAMA""BOĞA"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 6. Flags & Pennants
    detectFlagsAndPennants() =>
        if 
    not detect_continuation or not (cont_flag or cont_pennant)
            
    PatternInfo.new(""""00000)
        else
            
    prior_trend close[lookback] - close[lookback 2]
            
    recent_slope ta.linreg(close100) - ta.linreg(close109)
            
    recent_high ta.highest(high10)
            
    recent_low ta.lowest(low10)
            
    recent_range recent_high recent_low
            prior_range 
    ta.highest(high20)[10] - ta.lowest(low20)[10]
            
            
    is_consolidation recent_range prior_range 0.5
            
            
    if cont_flag and is_consolidation
                
    if prior_trend and recent_slope 0
                    PatternInfo
    .new("FLAMA""BOĞA"74bar_index 10bar_indexrecent_highrecent_low)
                else if 
    prior_trend and recent_slope 0
                    PatternInfo
    .new("FLAMA""AYI"74bar_index 10bar_indexrecent_highrecent_low)
                else if 
    math.abs(recent_slope) < volatility
                    PatternInfo
    .new("FLAMA YATAY""BEKLE"72bar_index 10bar_indexrecent_highrecent_low)
                else
                    
    PatternInfo.new(""""00000)
            
            else if 
    cont_pennant and is_consolidation and recent_range recent_range[5] * 0.7
                
    if prior_trend 0
                    PatternInfo
    .new("BOĞA""BOĞA"73bar_index 10bar_indexrecent_highrecent_low)
                else if 
    prior_trend 0
                    PatternInfo
    .new("AYI""AYI"73bar_index 10bar_indexrecent_highrecent_low)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 7. Harmonic Patterns (simplified)
    detectHarmonicPatterns() =>
        if 
    not detect_harmonic
            PatternInfo
    .new(""""00000)
        else
            [
    highslowshighBarslowBars] = findPivotPoints(5)
            
            if array.
    size(highs) >= and array.size(lows) >= 3
                X 
    = array.get(lows0)
                
    = array.get(highs0)
                
    = array.get(lows1)
                
    = array.get(highs1)
                
    close
                
                XA 
    X
                AB 
    B
                BC 
    B
                CD 
    D
                
                
    if harm_gartley and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC0.7860.05)
                    
    PatternInfo.new("FİBO""BOĞA"80bar_index lookbackbar_indexCD)
                else if 
    harm_butterfly and checkFibRatio(XAAB0.7860.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("KELEBEK""BOĞA"78bar_index lookbackbar_indexCD)
                else if 
    harm_bat and checkFibRatio(XAAB0.3820.05) and checkFibRatio(ABBC0.8860.05)
                    
    PatternInfo.new("YARASA""BOĞA"77bar_index lookbackbar_indexCD)
                else if 
    harm_crab and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("YENGEÇ""BOĞA"76bar_index lookbackbar_indexCD)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // 8. Price Action Patterns
    detectPriceAction() =>
        if 
    not detect_price_action
            PatternInfo
    .new(""""00000)
        else
            
    body math.abs(close open)
            
    upper_shadow high math.max(openclose)
            
    lower_shadow math.min(openclose) - low
            prev_body 
    math.abs(close[1] - open[1])
            
    avg_body ta.sma(math.abs(close open), 20)
            
    sma20 ta.sma(close20)
            
            if 
    pa_pin_bar and (upper_shadow body or lower_shadow body 2)
                
    direction lower_shadow upper_shadow "BOĞA" "AYI"
                
    PatternInfo.new("Pin Bar"direction70bar_indexbar_indexhighlow)
            else if 
    pa_inside and high high[1] and low low[1]
                
    PatternInfo.new("İÇ BAR""BEKLE"68bar_index 1bar_indexhigh[1], low[1])
            else if 
    pa_outside and high high[1] and low low[1]
                
    PatternInfo.new("DIŞ BAR""BEKLE"68bar_index 1bar_indexhighlow)
            else if 
    pa_engulfing and body prev_body 1.5
                
    if close open and close high[1] and open low[1]
                    
    PatternInfo.new("BOĞA YUTAN""BOĞA"72bar_index 1bar_indexhighlow)
                else if 
    close open and close low[1] and open high[1]
                    
    PatternInfo.new("AYI YUTAN""AYI"72bar_index 1bar_indexhighlow)
                else
                    
    PatternInfo.new(""""00000)
            else if 
    pa_doji and body avg_body 0.1
                
    if upper_shadow avg_body and lower_shadow avg_body
                    PatternInfo
    .new("Doji""BEKLE"65bar_indexbar_indexhighlow)
                else if 
    upper_shadow lower_shadow 2
                    PatternInfo
    .new("EJDERHA""BOĞA"66bar_indexbar_indexhighlow)
                else if 
    lower_shadow upper_shadow 2
                    PatternInfo
    .new("MEZARTAŞI""AYI"66bar_indexbar_indexhighlow)
                else
                    
    PatternInfo.new(""""00000)
            else if 
    pa_hammer and lower_shadow body and upper_shadow body 0.3
                
    if close sma20
                    PatternInfo
    .new("ÇEKİÇ""BOĞA"69bar_indexbar_indexhighlow)
                else
                    
    PatternInfo.new("ÇEKİÇ""AYI"69bar_indexbar_indexhighlow)
            else
                
    PatternInfo.new(""""00000)

    // 9. Special Patterns
    detectSpecialPatterns() =>
        if 
    not detect_special
            PatternInfo
    .new(""""00000)
        else
            if 
    spec_cup
                cup_depth 
    lowest_price[20] < lowest_price 0.85
                cup_recovery 
    close highest_price[20] * 0.95
                handle_forming 
    high highest_price[5] * 0.98
                
                
    if cup_depth and cup_recovery and handle_forming
                    PatternInfo
    .new("FİNCAN & KULP""BOĞA"82bar_index 30bar_indexhighest_pricelowest_price)
            
            if 
    spec_vbottom
                sharp_decline 
    lowest_price lowest_price[10] * 0.9
                sharp_recovery 
    close highest_price[5] * 0.95
                
                
    if sharp_decline and sharp_recovery
                    PatternInfo
    .new("V-DİP""BOĞA"75bar_index 10bar_indexhighest_price[10], lowest_price)
                else if 
    close lowest_price[5] * 1.05 and highest_price highest_price[10] * 1.1
                    PatternInfo
    .new("V-ZİRVE""AYI"75bar_index 10bar_indexhighest_pricelowest_price[10])
                else
                    
    PatternInfo.new(""""00000)
            
            else if 
    spec_diamond
                mid_expand 
    = (ta.highest(high25)[12] - ta.lowest(low25)[12]) > (ta.highest(high50)[25] - ta.lowest(low50)[25]) * 1.2
                end_contract 
    = (high low) < (ta.highest(high25)[12] - ta.lowest(low25)[12]) * 0.7
                
                
    if mid_expand and end_contract
                    PatternInfo
    .new("ELMAS""BEKLE"77bar_index lookbackbar_indexhighest_pricelowest_price)
                else
                    
    PatternInfo.new(""""00000)
            else
                
    PatternInfo.new(""""00000)

    // ============================================
    // MAIN PROCESSING
    // ============================================

    // Clear detected patterns
    array.clear(detected_patterns)

    // Execute detection functions
    patterns_to_check = array.new<PatternInfo>()
    array.
    push(patterns_to_checkdetectDoublePatterns())
    array.
    push(patterns_to_checkdetectTriplePatterns())
    array.
    push(patterns_to_checkdetectHeadShoulders())
    array.
    push(patterns_to_checkdetectTriangles())
    array.
    push(patterns_to_checkdetectWedges())
    array.
    push(patterns_to_checkdetectFlagsAndPennants())
    array.
    push(patterns_to_checkdetectHarmonicPatterns())
    array.
    push(patterns_to_checkdetectPriceAction())
    array.
    push(patterns_to_checkdetectSpecialPatterns())

    // Keep only valid patterns
    for 0 to array.size(patterns_to_check) - 1
        pattern 
    = array.get(patterns_to_checki)
        if 
    pattern.name != ""
            
    array.push(detected_patternspattern)

    // Sort by confidence (descending)
    if array.size(detected_patterns) > 1
        
    for 0 to array.size(detected_patterns) - 2
            
    for 0 to array.size(detected_patterns) - 2
                
    if < array.size(detected_patterns)
                    if array.
    get(detected_patternsj).confidence < array.get(detected_patterns1).confidence
                        temp 
    = array.get(detected_patternsj)
                        array.
    set(detected_patternsj, array.get(detected_patterns1))
                        array.
    set(detected_patterns1temp)

    // ============================================
    // VISUALIZATION
    // ============================================

    // Clear old drawings
    if barstate.islast
        
    for line in pattern_lines
            line
    .delete(line)
        array.
    clear(pattern_lines)
        
        for 
    lbl in pattern_labels
            label
    .delete(lbl)
        array.
    clear(pattern_labels)
        
        for 
    bx in pattern_boxes
            box
    .delete(bx)
        array.
    clear(pattern_boxes)

    // Draw patterns
    if show_patterns and barstate.islast and array.size(detected_patterns) > 0
        display_count 
    math.min(array.size(detected_patterns), max_patterns)
        for 
    0 to display_count 1
            pattern 
    = array.get(detected_patternsi)
            
            
    // Color settings
            
    pattern_color = switch pattern.direction
                
    "BOĞA" => color.new(color.lime20)
                
    "AYI" => color.new(color.red20)
                => 
    color.new(color.yellow20)
            
            
    // Target price calculation
            
    float target_price na
            float target_distance 
    0.0
            string target_label_text 
    ""
            
            
    // Pattern-specific drawing
            
    if str.contains(pattern.name"İKİLİ") or str.contains(pattern.name"ÜÇLÜ")
                [
    highslowshighBarslowBars] = findPivotPoints(5)
                if array.
    size(highs) >= 2
                    
    for 0 to math.min(array.size(highs) - 13)
                        
    high_point = array.get(highsj)
                        
    high_bar bar_index - array.get(highBarsj)
                        
    circle_label label.new(high_barhigh_point 1.01"●"color=color.new(color.red0), textcolor=color.redstyle=label.style_label_centersize=size.tiny)
                        array.
    push(pattern_labelscircle_label)
                if array.
    size(lows) >= 2
                    
    for 0 to math.min(array.size(lows) - 13)
                        
    low_point = array.get(lowsj)
                        
    low_bar bar_index - array.get(lowBarsj)
                        
    circle_label label.new(low_barlow_point 0.99"●"color=color.new(color.green0), textcolor=color.greenstyle=label.style_label_centersize=size.tiny)
                        array.
    push(pattern_labelscircle_label)
                
                
    // Neckline
                
    neckline str.contains(pattern.name"ZİRVE") ? pattern.level2 pattern.level1
                neck_line 
    line.new(pattern.start_barnecklinepattern.end_bar 10necklinecolor=color.new(color.orange0), width=2style=line.style_solid)
                array.
    push(pattern_linesneck_line)
                
    neck_label label.new(pattern.end_bar 5neckline"BOYUN"color=color.new(color.orange80), textcolor=color.whitestyle=label.style_label_leftsize=size.tiny)
                array.
    push(pattern_labelsneck_label)
                
                
    // Target calculation
                
    if str.contains(pattern.name"ZİRVE")
                    
    target_distance pattern.level1 neckline
                    target_price 
    := neckline target_distance
                    target_label_text 
    := "HEDEF ↓"
                
    else
                    
    target_distance neckline pattern.level2
                    target_price 
    := neckline target_distance
                    target_label_text 
    := "HEDEF ↑"
            
            
    else if str.contains(pattern.name"ÜÇGENLER") or str.contains(pattern.name"TAKOZLAR")
                
    upper_line line.new(pattern.start_barpattern.level1pattern.end_barpattern.level1 - (pattern.level1 pattern.level2) * 0.3color=pattern_colorwidth=2style=line.style_solid)
                
    lower_line line.new(pattern.start_barpattern.level2pattern.end_barpattern.level2 + (pattern.level1 pattern.level2) * 0.3color=pattern_colorwidth=2style=line.style_solid)
                array.
    push(pattern_linesupper_line)
                array.
    push(pattern_lineslower_line)
                
                
    convergence_label label.new(pattern.end_bar 5, (pattern.level1 pattern.level2) / 2str.contains(pattern.name"GENİŞLEYEN") ? "GENİŞLEYEN→" "←DARALAN→"color=color.new(pattern_color80), textcolor=color.whitestyle=label.style_label_centersize=size.tiny)
                array.
    push(pattern_labelsconvergence_label)
                
                
    // Target calculation
                
    pattern_height pattern.level1 pattern.level2
                
    if pattern.direction == "BOĞA"
                    
    target_price := pattern.level1 pattern_height
                    target_label_text 
    := "HEDEF ↑"
                
    else if pattern.direction == "AYI"
                    
    target_price := pattern.level2 pattern_height
                    target_label_text 
    := "HEDEF ↓"
                
    else
                    
    target_price := close > (pattern.level1 pattern.level2) / pattern.level1 pattern_height pattern.level2 pattern_height
                    target_label_text 
    := "HEDEF"
            
            
    else if str.contains(pattern.name"BAŞ") and str.contains(pattern.name"OMUZLAR")
                [
    highslowshighBarslowBars] = findPivotPoints(5)
                if array.
    size(highs) >= 3
                    max_high_idx 
    0
                    max_high_val 
    0.0
                    
    for 0 to math.min(array.size(highs) - 14)
                        if array.
    get(highsj) > max_high_val
                            max_high_val 
    := array.get(highsj)
                            
    max_high_idx := j
                    
                    head_bar 
    bar_index - array.get(highBarsmax_high_idx)
                    
    head_label label.new(head_barmax_high_val 1.01"BAŞ"color=color.redtextcolor=color.whitestyle=label.style_label_downsize=size.small)
                    array.
    push(pattern_labelshead_label)
                    
                    for 
    0 to math.min(array.size(highs) - 14)
                        if 
    != max_high_idx
                            shoulder_bar 
    bar_index - array.get(highBarsj)
                            
    shoulder_val = array.get(highsj)
                            
    shoulder_label label.new(shoulder_barshoulder_val 1.01"S"color=color.orangetextcolor=color.whitestyle=label.style_label_downsize=size.tiny)
                            array.
    push(pattern_labelsshoulder_label)
                    
                    
    // Target calculation
                    
    neckline_hs pattern.level2
                    head_distance 
    max_high_val neckline_hs
                    target_price 
    := neckline_hs head_distance
                    target_label_text 
    := "HEDEF ↓"
            
            
    else if str.contains(pattern.name"FLAMA") or str.contains(pattern.name"FLAMALAR")
                
    pole_start pattern.start_bar 20
                pole_end 
    pattern.start_bar
                pole_line 
    line.new(pole_startlowest_price[20], pole_endhighest_pricecolor=color.new(color.blue50), width=3style=line.style_solid)
                array.
    push(pattern_linespole_line)
                
    pole_label label.new(pole_start, (highest_price lowest_price[20]) / 2"@YÖRÜK@"color=color.bluetextcolor=color.whitestyle=label.style_label_rightsize=size.tiny)
                array.
    push(pattern_labelspole_label)
                
                
    flag_box box.new(pattern.start_barpattern.level1pattern.end_barpattern.level2bgcolor=color.new(pattern_color90), border_color=pattern_colorborder_width=2)
                array.
    push(pattern_boxesflag_box)
                
                
    // Target calculation
                
    pole_height highest_price lowest_price[20]
                if 
    str.contains(pattern.name"BOĞA")
                    
    target_price := pattern.level1 pole_height
                    target_label_text 
    := "HEDEF ↑"
                
    else if str.contains(pattern.name"AYI")
                    
    target_price := pattern.level2 pole_height
                    target_label_text 
    := "HEDEF ↓"
            
            
    else if str.contains(pattern.name"ÇEKİÇ") or str.contains(pattern.name"PİN BAR")
                
    body_box box.new(bar_index 1math.max(openclose), bar_indexmath.min(openclose), bgcolor=color.new(pattern_color50), border_color=pattern_color)
                array.
    push(pattern_boxesbody_box)
                
                
    shadow_line line.new(bar_indexhighbar_indexlowcolor=pattern_colorwidth=3style=line.style_solid)
                array.
    push(pattern_linesshadow_line)
                
                
    shadow_ratio str.contains(pattern.name"ÇEKİÇ") ? (math.min(openclose) - low) / math.abs(close open) : (high math.max(openclose)) / math.abs(close open)
                
                
    ratio_label label.new(bar_indexlow 0.99"FİTİL/BAR: " str.tostring(shadow_ratio"#.#") + "x"color=pattern_colortextcolor=color.whitestyle=label.style_label_upsize=size.tiny)
                array.
    push(pattern_labelsratio_label)
                
                
    // Target calculation
                
    candle_range high low
                
    if pattern.direction == "BOĞA"
                    
    target_price := close candle_range 2
                    target_label_text 
    := "HEDEF ↑"
                
    else
                    
    target_price := close candle_range 2
                    target_label_text 
    := "HEDEF ↓"
            
            
    // Display target prices
            
    if show_targets and not na(target_price)
                
    target_box box.new(bar_indexclosebar_index 30target_pricebgcolor=color.new(pattern.direction == "BOĞA" color.green color.red95), border_color=pattern.direction == "BOĞA" color.green color.redborder_width=1border_style=line.style_dashed)
                array.
    push(pattern_boxestarget_box)
                
                
    target_line line.new(bar_indextarget_pricebar_index 30target_pricecolor=pattern.direction == "BOĞA" color.green color.redwidth=2style=line.style_dashed)
                array.
    push(pattern_linestarget_line)
                
                
    price_change target_price close
                price_change_percent 
    = (price_change close) * 100
                target_text 
    target_label_text "\n$" str.tostring(target_price"#,###.##") + "\n(" str.tostring(price_change_percent"+#.##") + "%)"
                
    target_label label.new(bar_index 30target_pricetarget_textcolor=pattern.direction == "BOĞA" color.green color.redtextcolor=color.whitestyle=pattern.direction == "BOĞA" label.style_label_up label.style_label_downsize=size.normal)
                array.
    push(pattern_labelstarget_label)
                
                
    arrow_line line.new(bar_index 15closebar_index 15target_pricecolor=pattern.direction == "BOĞA" color.green color.redwidth=3style=line.style_arrow_right)
                array.
    push(pattern_linesarrow_line)
            
            
    // Pattern name and confidence
            
    if show_confidence
                label_text 
    pattern.name "\n" str.tostring(pattern.confidence"#") + "%"
                
    main_label label.new(bar_index 2high * (0.02 i), label_textcolor=pattern_colortextcolor=color.whitestyle=label.style_label_leftsize=size.normal)
                array.
    push(pattern_labelsmain_label)

    // Explanation panel
    if show_explanation and barstate.islast
        
    // Get text size
        
    text_size_val = switch panel_text_size
            
    "tiny" => size.tiny
            
    "small" => size.small
            
    "large" => size.large
            
    "huge" => size.huge
            
    => size.normal
        
        table
    .cell(explanation_table00"🔍 BULUNAN SONUÇ"bgcolor=color.new(color.purple30), text_color=color.whitetext_size=size.large)
        
    table.cell(explanation_table10"📊 ANALİZ"bgcolor=color.new(color.purple30), text_color=color.whitetext_size=size.large)
        
        if array.
    size(detected_patterns) > 0
            display_count 
    math.min(array.size(detected_patterns), max_patterns)
            for 
    0 to display_count 1
                pattern 
    = array.get(detected_patternsi)
                
                
    explanation ""
                
    if str.contains(pattern.name"İKİLİ TEPE")
                    
    explanation := "✓ İKİ ZİRVE YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ÇİZGİSİ KIRILIM ONAYI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"İKLİ DİP")
                    
    explanation := "✓ İKİ DİP YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ÇİZGİSİ KIRILIM ONAYI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"ÜÇGENLER")
                    
    range_compression = ((high low) / (highest_price lowest_price)) * 100
                    explanation 
    := "✓ ARALIK SIKIŞMASI " str.tostring(100 range_compression"#") + "%\n" +
                                  
    "✓ TREND OLUŞTU\n" +
                                  
    "✓ ÇIKIŞ BEKLENİYOR"
                
    else if str.contains(pattern.name"BAŞ") and str.contains(pattern.name"OMUZLAR")
                    
    explanation := "✓ BAŞ OLUŞTU\n" +
                                  
    "✓ OMUZLAR SİMETRİK\n" +
                                  
    "✓ BOYUN OLUŞTU"
                
    else if str.contains(pattern.name"FLAMALAR")
                    
    explanation := "✓ FLAMA OLUŞTU\n" +
                                  
    "✓ KONSİLDASYON ONAYLANDI\n" +
                                  
    "✓ DEVAM EDEBİLİR"
                
    else if str.contains(pattern.name"TAKOZLAR")
                    
    explanation := "✓ FİYAT SIKIŞIYOR\n" +
                                  
    "✓ EĞİLİM AYNI YÖNDE\n" +
                                  
    "✓ TERSE DÖNEBİLİR"
                
    else if str.contains(pattern.name"ÇEKİÇ")
                    
    explanation := "✓ BAR BOYU\n" +
                                  
    "✓ MİNUMUMDA\n" +
                                  
    "✓ DESTEKDE"
                
    else if str.contains(pattern.name"YUTAN BARLAR")
                    
    explanation := "✓ ÖNCEKİ BAR YUTULDU\n" +
                                  
    "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ GERİ DÖNÜŞ SİNYAL ONAYLI"
                
    else if str.contains(pattern.name"PİN BAR")
                    
    explanation := "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ DİKKAT TERSE DÖNÜŞ\n" +
                                  
    "✓ SIKIŞMA ARTI"
                
    else if str.contains(pattern.name"İÇ BAR")
                    
    explanation := "✓ ÖNCEKİ BAR ARALIĞINDA\n" +
                                  
    "✓ FİYAT HAREKET AZALDI\n" +
                                  
    "✓ DİKKAT YÜKSELEBİLİR"
                
    else if str.contains(pattern.name"DIŞ BAR")
                    
    explanation := "✓ ÖNCEKİ BAR YUTULDU\n" +
                                  
    "✓ ARALIK ARTIYOR\n" +
                                  
    "✓ DİKKAT TREND DEĞİŞİMİ OLABİLİR"
                
    else
                    
    explanation := "✓ MODEL ONAYI\n" +
                                  
    "✓ OLASILIK: " str.tostring(pattern.confidence"#") + "%\n" +
                                  
    "✓ YÖN: " pattern.direction
                
                pattern_color 
    = switch pattern.direction
                    
    "BOĞA" => color.new(color.lime20)
                    
    "AYI" => color.new(color.red20)
                    => 
    color.new(color.yellow20)
                    
                
    table.cell(explanation_table01pattern.namebgcolor=pattern_colortext_color=color.whitetext_size=text_size_val)
                
    table.cell(explanation_table11explanationbgcolor=color.new(color.black60), text_color=color.whitetext_size=text_size_val)
        else
            
    table.cell(explanation_table01"TARANIYOR..."text_color=color.graytext_size=text_size_val)
            
    table.cell(explanation_table11"BULUNAMADI"text_color=color.graytext_size=text_size_val)

    // Table update
    if show_table and barstate.islast
        table
    .cell(pattern_table00"MODELLEME"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table10"YÖN"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table20"OLASILIK"bgcolor=color.bluetext_color=color.white)
        
    table.cell(pattern_table30"DURUM"bgcolor=color.bluetext_color=color.white)
        
        if array.
    size(detected_patterns) > 0
            display_count 
    math.min(array.size(detected_patterns), max_patterns)
            for 
    0 to display_count 1
                pattern 
    = array.get(detected_patternsi)
                
                
    dir_color = switch pattern.direction
                    
    "BOĞA" => color.lime
                    
    "AYI" => color.red
                    
    => color.yellow
                
                conf_color 
    pattern.confidence >= 80 color.lime pattern.confidence >= 70 color.yellow color.gray
                
                table
    .cell(pattern_table01pattern.nametext_color=color.white)
                
    table.cell(pattern_table11pattern.directiontext_color=dir_color)
                
    table.cell(pattern_table21str.tostring(pattern.confidence"#") + "%"text_color=conf_color)
                
    table.cell(pattern_table31"AKTİF"text_color=color.aqua)
        else
            
    table.cell(pattern_table01"MODEL YOK"text_color=color.gray)
            
    table.cell(pattern_table11"-"text_color=color.gray)
            
    table.cell(pattern_table21"-"text_color=color.gray)
            
    table.cell(pattern_table31"BEKLE"text_color=color.gray)

    // Background color
    bg_color color(na)
    if array.
    size(detected_patterns) > 0
        top_pattern 
    = array.get(detected_patterns0)
        
    bg_color := switch top_pattern.direction
            
    "BOĞA" => color.new(color.green95)
            
    "AYI" => color.new(color.red95)
            => 
    color.new(color.yellow95)

    //bgcolor(bg_color)

    // S/R levels
    plot(highest_price"DİRENÇ"color=color.new(#ff5252, 100), linewidth=1, style=plot.style_stepline)
    plot(lowest_price"DESTEK"color=color.new(#4caf4f, 100), linewidth=1, style=plot.style_stepline)
    plot(mid_price"ORTALAMA"color=color.new(#787b86, 100), linewidth=1, style=plot.style_stepline)

    // Alerts
    if array.size(detected_patterns) > 0
        top_pattern 
    = array.get(detected_patterns0)
        
    alert_msg "MODEL BULUNDU: " top_pattern.name " [" top_pattern.direction "] OLASILIK: " str.tostring(top_pattern.confidence"#") + "%"
        
    if array.size(detected_patterns) > 1
            alert_msg 
    += " (+" str.tostring(array.size(detected_patterns) - 1) + " more)"
        
    alert(alert_msgalert.freq_once_per_bar)

    // Alert conditions
    alertcondition(array.size(detected_patterns) > and array.get(detected_patterns0).direction == "BOĞA""MODEL""BULUNDU")
    alertcondition(array.size(detected_patterns) > and array.get(detected_patterns0).direction == "AYI""MODEL""BULUNDU")
    alertcondition(array.size(detected_patterns) > 0"MODEL""YENİ MODEL VAR"

Sayfa 309/309 İlkİlk ... 209259299307308309

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
  •