Artan
Azalan
lem
BIST 30
BIST 50
BIST 100
NASDAQ 100
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
119,90 10% 1,16 Mr 110,30 / 119,90
3,63 10% 501,00 Mn 3,31 / 3,63
8,14 10% 2,47 Mr 7,54 / 8,14
53,90 10% 982,81 Mn 47,32 / 53,90
34,80 9.99% 91,16 Mn 34,80 / 34,80
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
2,90 -9.94% 955,51 Mn 2,90 / 3,13
1.353,00 -9.68% 284,03 Mn 1.349,00 / 1.508,00
7,81 -8.12% 11,40 Mn 7,80 / 8,01
21,92 -7.74% 421,11 Mn 21,42 / 24,44
269,25 -7.16% 258,51 Mn 268,25 / 290,00
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
329,00 3.7% 35,57 Mr 317,75 / 335,00
3,14 2.61% 34,03 Mr 3,03 / 3,32
39,30 4.86% 15,25 Mr 37,14 / 39,36
15,11 4.64% 14,63 Mr 14,36 / 15,11
83,55 6.98% 13,83 Mr 77,40 / 83,85
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
19,42 4.52% 1,50 Mr 18,28 / 19,42
83,55 6.98% 13,83 Mr 77,40 / 83,85
414,00 0.73% 8,67 Mr 407,00 / 417,50
196,70 2.45% 9,71 Mr 189,40 / 197,60
765,00 2.55% 4,53 Mr 742,50 / 770,50
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
19,42 4.52% 1,50 Mr 18,28 / 19,42
83,55 6.98% 13,83 Mr 77,40 / 83,85
95,55 2.52% 697,12 Mn 92,75 / 95,95
118,70 2.33% 332,28 Mn 114,90 / 119,30
414,00 0.73% 8,67 Mr 407,00 / 417,50
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
19,42 4.52% 1,50 Mr 18,28 / 19,42
32,04 3.96% 257,43 Mn 30,62 / 32,14
83,55 6.98% 13,83 Mr 77,40 / 83,85
10,95 2.34% 240,15 Mn 10,71 / 10,95
80,10 -1.6% 845,03 Mn 78,55 / 82,95

Masrafsz Bankaclk + 1.000 TL Nakit! Enparadan ifte Avantaj

Masrafsz Bankaclk + 1.000 TL Nakit! Enparadan ifte Avantaj
Sayfa 309/393 lklk ... 209259299307308309310311319359 ... SonSon
Arama sonucu : 3139 madde; 2,465 - 2,472 aras.

Konu: Tradingview

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

    seeceiniz ema deerine gre range hesabn yzdeyle...ift ynl yapyor...destek diren misali...
    16.07.2024 - 10.12.2024

  2. https://tr.tradingview.com/script/zy8EETop/
    bilinen 50 patterni taryor... aklamal...

    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 ayaryla endeks saatlikte d diyor...

    scalp olursa... https://www.tradingview.com/x/GjAlejkF/ ykseli...

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

    bunu denemeli.... ve kodu trkeletirelim...
    16.07.2024 - 10.12.2024


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

    kodlar incelenecek....

    nk https://www.tradingview.com/x/SMnUrRtV/ bu kodu editrler semi....

    tam matematiksel..... hacim analizi ancak byle yaplr.... helal olsun....
    16.07.2024 - 10.12.2024

  4.  Alnt Originally Posted by @yrk@ Yazy Oku
    https://tr.tradingview.com/script/zy8EETop/
    bilinen 50 patterni taryor... aklamal...

    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 ayaryla endeks saatlikte d diyor...

    scalp olursa... https://www.tradingview.com/x/GjAlejkF/ ykseli...

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

    bunu denemeli.... ve kodu trkeletirelim...
    day trading iin...
    PHP Code:
    //@version=6
    indicator("."overlay=truemax_bars_back=500)

    // ============================================
    // INPUT PARAMETERS
    // ============================================
    g1 "ARAMA AYARLARI"
    lookback input.int(50"MODEL PERYOT"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 "KLASK MODELLER"
    detect_classic input.bool(true"▼ KLASK MODELLER"group=g2)
    classic_double input.bool(true"├ KL TEPE/DP"group=g2)
    classic_triple input.bool(true"├ L TEPE/DP"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"├ YKSELEN GEN"group=g3)
    tri_descending input.bool(true"├ ALALAN GEN"group=g3)
    tri_symmetrical input.bool(true"├ SMETRK GEN"group=g3)
    tri_expanding input.bool(true"└ GENLEYEN 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"└ DKDRTGENLER"group=g4)

    g5 "HARMONK MODELLER"
    detect_harmonic input.bool(true"▼ HARMONK MODELLER"group=g5)
    harm_gartley input.bool(true"├ FBO"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"├ KPEKBALII"group=g5)
    harm_cypher input.bool(true"└ DRTL"group=g5)

    g6 "FYAT MODELLER"
    detect_price_action input.bool(true"▼ FYAT MODELLER"group=g6)
    pa_pin_bar input.bool(true"├ PN 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"├ FNCAN & KULP"group=g7)
    spec_vbottom input.bool(true"├ V-DP/ZRVE"group=g7)
    spec_broadening input.bool(true"├ GENLEME"group=g7)
    spec_island input.bool(true"└ ADA DN"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"PVOT"group=g8)
    show_key_levels input.bool(true"GR"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("KL 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("KL DP""BOA"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("YKSELEN GEN""BOA"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_descending and upper_trend < -volatility and math.abs(lower_trend) < volatility and converging
                PatternInfo
    .new("ALALAN GEN""AYI"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_symmetrical and math.abs(upper_trend lower_trend) < volatility and converging
                PatternInfo
    .new("SMETRK GEN""BEKLE"75bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_expanding and diverging
                PatternInfo
    .new("GENLEYEN 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("YKSELEN TAKOZ""AYI"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("DEN TAKOZ""BOA"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("GENLEYEN KAMA""AYI"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else if 
    upper_slope and lower_slope 0
                    PatternInfo
    .new("DARALAN KAMA""BOA"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""BOA"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("BOA""BOA"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("FBO""BOA"80bar_index lookbackbar_indexCD)
                else if 
    harm_butterfly and checkFibRatio(XAAB0.7860.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("KELEBEK""BOA"78bar_index lookbackbar_indexCD)
                else if 
    harm_bat and checkFibRatio(XAAB0.3820.05) and checkFibRatio(ABBC0.8860.05)
                    
    PatternInfo.new("YARASA""BOA"77bar_index lookbackbar_indexCD)
                else if 
    harm_crab and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("YENGE""BOA"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 "BOA" "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("BOA YUTAN""BOA"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""BOA"66bar_indexbar_indexhighlow)
                else if 
    lower_shadow upper_shadow 2
                    PatternInfo
    .new("MEZARTAI""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""BOA"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("FNCAN & KULP""BOA"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-DP""BOA"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-ZRVE""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
                
    "BOA" => 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"KL") 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"ZRVE") ? 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"ZRVE")
                    
    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"GENLEYEN") ? "GENLEYEN→" "←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 == "BOA"
                    
    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"@YRK@"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"BOA")
                    
    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"PN 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"FTL/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 == "BOA"
                    
    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 == "BOA" color.green color.red95), border_color=pattern.direction == "BOA" 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 == "BOA" 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 == "BOA" color.green color.redtextcolor=color.whitestyle=pattern.direction == "BOA" 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 == "BOA" 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"📊 ANALZ"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"KL TEPE")
                    
    explanation := "✓ K ZRVE YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ZGS KIRILIM ONAYI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"KL DP")
                    
    explanation := "✓ K DP YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ZGS KIRILIM ONAYI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"GENLER")
                    
    range_compression = ((high low) / (highest_price lowest_price)) * 100
                    explanation 
    := "✓ ARALIK SIKIMASI " str.tostring(100 range_compression"#") + "%\n" +
                                  
    "✓ TREND OLUTU\n" +
                                  
    "✓ IKI BEKLENYOR"
                
    else if str.contains(pattern.name"BA") and str.contains(pattern.name"OMUZLAR")
                    
    explanation := "✓ BA OLUTU\n" +
                                  
    "✓ OMUZLAR SMETRK\n" +
                                  
    "✓ BOYUN OLUTU"
                
    else if str.contains(pattern.name"FLAMALAR")
                    
    explanation := "✓ FLAMA OLUTU\n" +
                                  
    "✓ KONSLDASYON ONAYLANDI\n" +
                                  
    "✓ DEVAM EDEBLR"
                
    else if str.contains(pattern.name"TAKOZLAR")
                    
    explanation := "✓ FYAT SIKIIYOR\n" +
                                  
    "✓ ELM AYNI YNDE\n" +
                                  
    "✓ TERSE DNEBLR"
                
    else if str.contains(pattern.name"EK")
                    
    explanation := "✓ BAR BOYU\n" +
                                  
    "✓ MNUMUMDA\n" +
                                  
    "✓ DESTEKDE"
                
    else if str.contains(pattern.name"YUTAN BARLAR")
                    
    explanation := "✓ NCEK BAR YUTULDU\n" +
                                  
    "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"PN BAR")
                    
    explanation := "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ DKKAT TERSE DN\n" +
                                  
    "✓ SIKIMA ARTI"
                
    else if str.contains(pattern.name" BAR")
                    
    explanation := "✓ NCEK BAR ARALIINDA\n" +
                                  
    "✓ FYAT HAREKET AZALDI\n" +
                                  
    "✓ DKKAT YKSELEBLR"
                
    else if str.contains(pattern.name"DI BAR")
                    
    explanation := "✓ NCEK BAR YUTULDU\n" +
                                  
    "✓ ARALIK ARTIYOR\n" +
                                  
    "✓ DKKAT TREND DEM OLABLR"
                
    else
                    
    explanation := "✓ MODEL ONAYI\n" +
                                  
    "✓ OLASILIK: " str.tostring(pattern.confidence"#") + "%\n" +
                                  
    "✓ YN: " pattern.direction
                
                pattern_color 
    = switch pattern.direction
                    
    "BOA" => 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"YN"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
                    
    "BOA" => 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"AKTF"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
            
    "BOA" => color.new(color.green95)
            
    "AYI" => color.new(color.red95)
            => 
    color.new(color.yellow95)

    //bgcolor(bg_color)

    // S/R levels
    plot(highest_price"DREN"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 == "BOA""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"
    16.07.2024 - 10.12.2024

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

    // ============================================
    // INPUT PARAMETERS
    // ============================================
    g1 "ARAMA AYARLARI"
    lookback input.int(100"MODEL PERYOT"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 "KLASK MODELLER"
    detect_classic input.bool(true"▼ KLASK MODELLER"group=g2)
    classic_double input.bool(true"├ KL TEPE/DP"group=g2)
    classic_triple input.bool(true"├ L TEPE/DP"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"├ YKSELEN GEN"group=g3)
    tri_descending input.bool(true"├ ALALAN GEN"group=g3)
    tri_symmetrical input.bool(true"├ SMETRK GEN"group=g3)
    tri_expanding input.bool(true"└ GENLEYEN 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"└ DKDRTGENLER"group=g4)

    g5 "HARMONK MODELLER"
    detect_harmonic input.bool(true"▼ HARMONK MODELLER"group=g5)
    harm_gartley input.bool(true"├ FBO"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"├ KPEKBALII"group=g5)
    harm_cypher input.bool(true"└ DRTL"group=g5)

    g6 "FYAT MODELLER"
    detect_price_action input.bool(true"▼ FYAT MODELLER"group=g6)
    pa_pin_bar input.bool(true"├ PN 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"├ FNCAN & KULP"group=g7)
    spec_vbottom input.bool(true"├ V-DP/ZRVE"group=g7)
    spec_broadening input.bool(true"├ GENLEME"group=g7)
    spec_island input.bool(true"└ ADA DN"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"PVOT"group=g8)
    show_key_levels input.bool(true"GR"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("KL 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("KL DP""BOA"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("YKSELEN GEN""BOA"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_descending and upper_trend < -volatility and math.abs(lower_trend) < volatility and converging
                PatternInfo
    .new("ALALAN GEN""AYI"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_symmetrical and math.abs(upper_trend lower_trend) < volatility and converging
                PatternInfo
    .new("SMETRK GEN""BEKLE"75bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_expanding and diverging
                PatternInfo
    .new("GENLEYEN 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("YKSELEN TAKOZ""AYI"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("DEN TAKOZ""BOA"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("GENLEYEN KAMA""AYI"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else if 
    upper_slope and lower_slope 0
                    PatternInfo
    .new("DARALAN KAMA""BOA"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""BOA"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("BOA""BOA"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("FBO""BOA"80bar_index lookbackbar_indexCD)
                else if 
    harm_butterfly and checkFibRatio(XAAB0.7860.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("KELEBEK""BOA"78bar_index lookbackbar_indexCD)
                else if 
    harm_bat and checkFibRatio(XAAB0.3820.05) and checkFibRatio(ABBC0.8860.05)
                    
    PatternInfo.new("YARASA""BOA"77bar_index lookbackbar_indexCD)
                else if 
    harm_crab and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("YENGE""BOA"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 "BOA" "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("BOA YUTAN""BOA"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""BOA"66bar_indexbar_indexhighlow)
                else if 
    lower_shadow upper_shadow 2
                    PatternInfo
    .new("MEZARTAI""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""BOA"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("FNCAN & KULP""BOA"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-DP""BOA"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-ZRVE""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
                
    "BOA" => 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"KL") 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"ZRVE") ? 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"ZRVE")
                    
    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"GENLEYEN") ? "GENLEYEN→" "←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 == "BOA"
                    
    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"@YRK@"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"BOA")
                    
    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"PN 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"FTL/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 == "BOA"
                    
    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 == "BOA" color.green color.red95), border_color=pattern.direction == "BOA" 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 == "BOA" 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 == "BOA" color.green color.redtextcolor=color.whitestyle=pattern.direction == "BOA" 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 == "BOA" 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"📊 ANALZ"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"KL TEPE")
                    
    explanation := "✓ K ZRVE YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ZGS KIRILIM ONAYI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"KL DP")
                    
    explanation := "✓ K DP YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ZGS KIRILIM ONAYI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"GENLER")
                    
    range_compression = ((high low) / (highest_price lowest_price)) * 100
                    explanation 
    := "✓ ARALIK SIKIMASI " str.tostring(100 range_compression"#") + "%\n" +
                                  
    "✓ TREND OLUTU\n" +
                                  
    "✓ IKI BEKLENYOR"
                
    else if str.contains(pattern.name"BA") and str.contains(pattern.name"OMUZLAR")
                    
    explanation := "✓ BA OLUTU\n" +
                                  
    "✓ OMUZLAR SMETRK\n" +
                                  
    "✓ BOYUN OLUTU"
                
    else if str.contains(pattern.name"FLAMALAR")
                    
    explanation := "✓ FLAMA OLUTU\n" +
                                  
    "✓ KONSLDASYON ONAYLANDI\n" +
                                  
    "✓ DEVAM EDEBLR"
                
    else if str.contains(pattern.name"TAKOZLAR")
                    
    explanation := "✓ FYAT SIKIIYOR\n" +
                                  
    "✓ ELM AYNI YNDE\n" +
                                  
    "✓ TERSE DNEBLR"
                
    else if str.contains(pattern.name"EK")
                    
    explanation := "✓ BAR BOYU\n" +
                                  
    "✓ MNUMUMDA\n" +
                                  
    "✓ DESTEKDE"
                
    else if str.contains(pattern.name"YUTAN BARLAR")
                    
    explanation := "✓ NCEK BAR YUTULDU\n" +
                                  
    "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"PN BAR")
                    
    explanation := "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ DKKAT TERSE DN\n" +
                                  
    "✓ SIKIMA ARTI"
                
    else if str.contains(pattern.name" BAR")
                    
    explanation := "✓ NCEK BAR ARALIINDA\n" +
                                  
    "✓ FYAT HAREKET AZALDI\n" +
                                  
    "✓ DKKAT YKSELEBLR"
                
    else if str.contains(pattern.name"DI BAR")
                    
    explanation := "✓ NCEK BAR YUTULDU\n" +
                                  
    "✓ ARALIK ARTIYOR\n" +
                                  
    "✓ DKKAT TREND DEM OLABLR"
                
    else
                    
    explanation := "✓ MODEL ONAYI\n" +
                                  
    "✓ OLASILIK: " str.tostring(pattern.confidence"#") + "%\n" +
                                  
    "✓ YN: " pattern.direction
                
                pattern_color 
    = switch pattern.direction
                    
    "BOA" => 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"YN"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
                    
    "BOA" => 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"AKTF"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
            
    "BOA" => color.new(color.green95)
            
    "AYI" => color.new(color.red95)
            => 
    color.new(color.yellow95)

    //bgcolor(bg_color)

    // S/R levels
    plot(highest_price"DREN"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 == "BOA""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"
    16.07.2024 - 10.12.2024

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

    // ============================================
    // INPUT PARAMETERS
    // ============================================
    g1 "ARAMA AYARLARI"
    lookback input.int(20"MODEL PERYOT"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 "KLASK MODELLER"
    detect_classic input.bool(true"▼ KLASK MODELLER"group=g2)
    classic_double input.bool(true"├ KL TEPE/DP"group=g2)
    classic_triple input.bool(true"├ L TEPE/DP"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"├ YKSELEN GEN"group=g3)
    tri_descending input.bool(true"├ ALALAN GEN"group=g3)
    tri_symmetrical input.bool(true"├ SMETRK GEN"group=g3)
    tri_expanding input.bool(true"└ GENLEYEN 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"└ DKDRTGENLER"group=g4)

    g5 "HARMONK MODELLER"
    detect_harmonic input.bool(true"▼ HARMONK MODELLER"group=g5)
    harm_gartley input.bool(true"├ FBO"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"├ KPEKBALII"group=g5)
    harm_cypher input.bool(true"└ DRTL"group=g5)

    g6 "FYAT MODELLER"
    detect_price_action input.bool(true"▼ FYAT MODELLER"group=g6)
    pa_pin_bar input.bool(true"├ PN 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"├ FNCAN & KULP"group=g7)
    spec_vbottom input.bool(true"├ V-DP/ZRVE"group=g7)
    spec_broadening input.bool(true"├ GENLEME"group=g7)
    spec_island input.bool(true"└ ADA DN"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"PVOT"group=g8)
    show_key_levels input.bool(true"GR"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("KL 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("KL DP""BOA"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("YKSELEN GEN""BOA"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_descending and upper_trend < -volatility and math.abs(lower_trend) < volatility and converging
                PatternInfo
    .new("ALALAN GEN""AYI"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_symmetrical and math.abs(upper_trend lower_trend) < volatility and converging
                PatternInfo
    .new("SMETRK GEN""BEKLE"75bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_expanding and diverging
                PatternInfo
    .new("GENLEYEN 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("YKSELEN TAKOZ""AYI"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("DEN TAKOZ""BOA"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("GENLEYEN KAMA""AYI"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else if 
    upper_slope and lower_slope 0
                    PatternInfo
    .new("DARALAN KAMA""BOA"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""BOA"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("BOA""BOA"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("FBO""BOA"80bar_index lookbackbar_indexCD)
                else if 
    harm_butterfly and checkFibRatio(XAAB0.7860.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("KELEBEK""BOA"78bar_index lookbackbar_indexCD)
                else if 
    harm_bat and checkFibRatio(XAAB0.3820.05) and checkFibRatio(ABBC0.8860.05)
                    
    PatternInfo.new("YARASA""BOA"77bar_index lookbackbar_indexCD)
                else if 
    harm_crab and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("YENGE""BOA"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 "BOA" "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("BOA YUTAN""BOA"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""BOA"66bar_indexbar_indexhighlow)
                else if 
    lower_shadow upper_shadow 2
                    PatternInfo
    .new("MEZARTAI""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""BOA"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("FNCAN & KULP""BOA"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-DP""BOA"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-ZRVE""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
                
    "BOA" => 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"KL") 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"ZRVE") ? 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"ZRVE")
                    
    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"GENLEYEN") ? "GENLEYEN→" "←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 == "BOA"
                    
    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"@YRK@"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"BOA")
                    
    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"PN 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"FTL/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 == "BOA"
                    
    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 == "BOA" color.green color.red95), border_color=pattern.direction == "BOA" 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 == "BOA" 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 == "BOA" color.green color.redtextcolor=color.whitestyle=pattern.direction == "BOA" 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 == "BOA" 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"📊 ANALZ"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"KL TEPE")
                    
    explanation := "✓ K ZRVE YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ZGS KIRILIM ONAYI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"KL DP")
                    
    explanation := "✓ K DP YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ZGS KIRILIM ONAYI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"GENLER")
                    
    range_compression = ((high low) / (highest_price lowest_price)) * 100
                    explanation 
    := "✓ ARALIK SIKIMASI " str.tostring(100 range_compression"#") + "%\n" +
                                  
    "✓ TREND OLUTU\n" +
                                  
    "✓ IKI BEKLENYOR"
                
    else if str.contains(pattern.name"BA") and str.contains(pattern.name"OMUZLAR")
                    
    explanation := "✓ BA OLUTU\n" +
                                  
    "✓ OMUZLAR SMETRK\n" +
                                  
    "✓ BOYUN OLUTU"
                
    else if str.contains(pattern.name"FLAMALAR")
                    
    explanation := "✓ FLAMA OLUTU\n" +
                                  
    "✓ KONSLDASYON ONAYLANDI\n" +
                                  
    "✓ DEVAM EDEBLR"
                
    else if str.contains(pattern.name"TAKOZLAR")
                    
    explanation := "✓ FYAT SIKIIYOR\n" +
                                  
    "✓ ELM AYNI YNDE\n" +
                                  
    "✓ TERSE DNEBLR"
                
    else if str.contains(pattern.name"EK")
                    
    explanation := "✓ BAR BOYU\n" +
                                  
    "✓ MNUMUMDA\n" +
                                  
    "✓ DESTEKDE"
                
    else if str.contains(pattern.name"YUTAN BARLAR")
                    
    explanation := "✓ NCEK BAR YUTULDU\n" +
                                  
    "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"PN BAR")
                    
    explanation := "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ DKKAT TERSE DN\n" +
                                  
    "✓ SIKIMA ARTI"
                
    else if str.contains(pattern.name" BAR")
                    
    explanation := "✓ NCEK BAR ARALIINDA\n" +
                                  
    "✓ FYAT HAREKET AZALDI\n" +
                                  
    "✓ DKKAT YKSELEBLR"
                
    else if str.contains(pattern.name"DI BAR")
                    
    explanation := "✓ NCEK BAR YUTULDU\n" +
                                  
    "✓ ARALIK ARTIYOR\n" +
                                  
    "✓ DKKAT TREND DEM OLABLR"
                
    else
                    
    explanation := "✓ MODEL ONAYI\n" +
                                  
    "✓ OLASILIK: " str.tostring(pattern.confidence"#") + "%\n" +
                                  
    "✓ YN: " pattern.direction
                
                pattern_color 
    = switch pattern.direction
                    
    "BOA" => 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"YN"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
                    
    "BOA" => 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"AKTF"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
            
    "BOA" => color.new(color.green95)
            
    "AYI" => color.new(color.red95)
            => 
    color.new(color.yellow95)

    //bgcolor(bg_color)

    // S/R levels
    plot(highest_price"DREN"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 == "BOA""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"
    16.07.2024 - 10.12.2024

  7. 0.0005 duyarllk 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 PERYOT"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 "KLASK MODELLER"
    detect_classic input.bool(true"▼ KLASK MODELLER"group=g2)
    classic_double input.bool(true"├ KL TEPE/DP"group=g2)
    classic_triple input.bool(true"├ L TEPE/DP"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"├ YKSELEN GEN"group=g3)
    tri_descending input.bool(true"├ ALALAN GEN"group=g3)
    tri_symmetrical input.bool(true"├ SMETRK GEN"group=g3)
    tri_expanding input.bool(true"└ GENLEYEN 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"└ DKDRTGENLER"group=g4)

    g5 "HARMONK MODELLER"
    detect_harmonic input.bool(true"▼ HARMONK MODELLER"group=g5)
    harm_gartley input.bool(true"├ FBO"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"├ KPEKBALII"group=g5)
    harm_cypher input.bool(true"└ DRTL"group=g5)

    g6 "FYAT MODELLER"
    detect_price_action input.bool(true"▼ FYAT MODELLER"group=g6)
    pa_pin_bar input.bool(true"├ PN 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"├ FNCAN & KULP"group=g7)
    spec_vbottom input.bool(true"├ V-DP/ZRVE"group=g7)
    spec_broadening input.bool(true"├ GENLEME"group=g7)
    spec_island input.bool(true"└ ADA DN"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"PVOT"group=g8)
    show_key_levels input.bool(true"GR"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("KL 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("KL DP""BOA"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("YKSELEN GEN""BOA"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_descending and upper_trend < -volatility and math.abs(lower_trend) < volatility and converging
                PatternInfo
    .new("ALALAN GEN""AYI"78bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_symmetrical and math.abs(upper_trend lower_trend) < volatility and converging
                PatternInfo
    .new("SMETRK GEN""BEKLE"75bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    tri_expanding and diverging
                PatternInfo
    .new("GENLEYEN 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("YKSELEN TAKOZ""AYI"76bar_index lookbackbar_indexhighest_pricelowest_price)
            else if 
    upper_slope and lower_slope and upper_slope lower_slope and converging
                PatternInfo
    .new("DEN TAKOZ""BOA"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("GENLEYEN KAMA""AYI"73bar_index lookbackbar_indexhighest_pricelowest_price)
                else if 
    upper_slope and lower_slope 0
                    PatternInfo
    .new("DARALAN KAMA""BOA"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""BOA"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("BOA""BOA"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("FBO""BOA"80bar_index lookbackbar_indexCD)
                else if 
    harm_butterfly and checkFibRatio(XAAB0.7860.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("KELEBEK""BOA"78bar_index lookbackbar_indexCD)
                else if 
    harm_bat and checkFibRatio(XAAB0.3820.05) and checkFibRatio(ABBC0.8860.05)
                    
    PatternInfo.new("YARASA""BOA"77bar_index lookbackbar_indexCD)
                else if 
    harm_crab and checkFibRatio(XAAB0.6180.05) and checkFibRatio(ABBC1.6180.1)
                    
    PatternInfo.new("YENGE""BOA"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 "BOA" "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("BOA YUTAN""BOA"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""BOA"66bar_indexbar_indexhighlow)
                else if 
    lower_shadow upper_shadow 2
                    PatternInfo
    .new("MEZARTAI""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""BOA"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("FNCAN & KULP""BOA"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-DP""BOA"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-ZRVE""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
                
    "BOA" => 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"KL") 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"ZRVE") ? 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"ZRVE")
                    
    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"GENLEYEN") ? "GENLEYEN→" "←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 == "BOA"
                    
    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"@YRK@"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"BOA")
                    
    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"PN 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"FTL/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 == "BOA"
                    
    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 == "BOA" color.green color.red95), border_color=pattern.direction == "BOA" 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 == "BOA" 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 == "BOA" color.green color.redtextcolor=color.whitestyle=pattern.direction == "BOA" 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 == "BOA" 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"📊 ANALZ"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"KL TEPE")
                    
    explanation := "✓ K ZRVE YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ZGS KIRILIM ONAYI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"KL DP")
                    
    explanation := "✓ K DP YAPTI " str.tostring(sensitivity 100"#.#") + "% tolerance\n" +
                                  
    "✓ BOYUN ZGS KIRILIM ONAYI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"GENLER")
                    
    range_compression = ((high low) / (highest_price lowest_price)) * 100
                    explanation 
    := "✓ ARALIK SIKIMASI " str.tostring(100 range_compression"#") + "%\n" +
                                  
    "✓ TREND OLUTU\n" +
                                  
    "✓ IKI BEKLENYOR"
                
    else if str.contains(pattern.name"BA") and str.contains(pattern.name"OMUZLAR")
                    
    explanation := "✓ BA OLUTU\n" +
                                  
    "✓ OMUZLAR SMETRK\n" +
                                  
    "✓ BOYUN OLUTU"
                
    else if str.contains(pattern.name"FLAMALAR")
                    
    explanation := "✓ FLAMA OLUTU\n" +
                                  
    "✓ KONSLDASYON ONAYLANDI\n" +
                                  
    "✓ DEVAM EDEBLR"
                
    else if str.contains(pattern.name"TAKOZLAR")
                    
    explanation := "✓ FYAT SIKIIYOR\n" +
                                  
    "✓ ELM AYNI YNDE\n" +
                                  
    "✓ TERSE DNEBLR"
                
    else if str.contains(pattern.name"EK")
                    
    explanation := "✓ BAR BOYU\n" +
                                  
    "✓ MNUMUMDA\n" +
                                  
    "✓ DESTEKDE"
                
    else if str.contains(pattern.name"YUTAN BARLAR")
                    
    explanation := "✓ NCEK BAR YUTULDU\n" +
                                  
    "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ GER DN SNYAL ONAYLI"
                
    else if str.contains(pattern.name"PN BAR")
                    
    explanation := "✓ BAR BOYU ARTTI\n" +
                                  
    "✓ DKKAT TERSE DN\n" +
                                  
    "✓ SIKIMA ARTI"
                
    else if str.contains(pattern.name" BAR")
                    
    explanation := "✓ NCEK BAR ARALIINDA\n" +
                                  
    "✓ FYAT HAREKET AZALDI\n" +
                                  
    "✓ DKKAT YKSELEBLR"
                
    else if str.contains(pattern.name"DI BAR")
                    
    explanation := "✓ NCEK BAR YUTULDU\n" +
                                  
    "✓ ARALIK ARTIYOR\n" +
                                  
    "✓ DKKAT TREND DEM OLABLR"
                
    else
                    
    explanation := "✓ MODEL ONAYI\n" +
                                  
    "✓ OLASILIK: " str.tostring(pattern.confidence"#") + "%\n" +
                                  
    "✓ YN: " pattern.direction
                
                pattern_color 
    = switch pattern.direction
                    
    "BOA" => 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"YN"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
                    
    "BOA" => 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"AKTF"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
            
    "BOA" => color.new(color.green95)
            
    "AYI" => color.new(color.red95)
            => 
    color.new(color.yellow95)

    //bgcolor(bg_color)

    // S/R levels
    plot(highest_price"DREN"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 == "BOA""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"
    16.07.2024 - 10.12.2024

Sayfa 309/393 lklk ... 209259299307308309310311319359 ... SonSon

Yer mleri

Yer mleri

Gnderi Kurallar

  • Yeni konu aamazsnz
  • Konulara cevap yazamazsnz
  • Yazlara ek gnderemezsiniz
  • Yazlarnz deitiremezsiniz
  •