Artan
Azalan
lem
BIST 30
BIST 50
BIST 100
NASDAQ 100
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
34,80 9.99% 77,78 Mn 34,80 / 34,80
85,95 9.98% 149,00 Mn 76,30 / 85,95
6,39 9.98% 496,36 Mn 6,02 / 6,39
7.000,00 9.98% 243,05 Mn 6.360,00 / 7.000,00
1.985,00 9.97% 107,60 Mn 1.805,00 / 1.985,00
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
103,00 -9.97% 103,11 Mn 103,00 / 113,10
2,91 -9.63% 471,73 Mn 2,90 / 3,13
3,62 -6.46% 1,55 Mn 3,62 / 3,62
6,67 -6.19% 39,83 Mn 6,59 / 6,88
8,01 -5.76% 1,59 Mn 8,01 / 8,01
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
3,30 7.84% 12,74 Mr 3,06 / 3,32
12,39 3.86% 2,90 Mr 11,64 / 12,69
319,50 0.71% 2,57 Mr 317,75 / 320,25
24,06 6.93% 2,36 Mr 22,36 / 24,18
412,25 0.3% 1,91 Mr 407,00 / 415,00
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
18,65 0.38% 203,68 Mn 18,47 / 18,66
78,00 -0.13% 1,68 Mr 77,40 / 78,50
412,25 0.3% 1,91 Mr 407,00 / 415,00
192,60 0.31% 1,49 Mr 189,40 / 193,10
751,00 0.67% 608,87 Mn 745,00 / 752,00
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
18,65 0.38% 203,68 Mn 18,47 / 18,66
78,00 -0.13% 1,68 Mr 77,40 / 78,50
93,70 0.54% 130,28 Mn 92,75 / 94,05
116,20 0.17% 46,41 Mn 114,90 / 116,30
412,25 0.3% 1,91 Mr 407,00 / 415,00
Hisse Fiyat Fark% Hacim (TL) Dk / Yksek
18,65 0.38% 203,68 Mn 18,47 / 18,66
31,04 0.71% 36,77 Mn 30,62 / 31,30
78,00 -0.13% 1,68 Mr 77,40 / 78,50
10,73 0.28% 46,22 Mn 10,71 / 10,82
81,75 0.43% 65,98 Mn 81,45 / 82,40

Masrafsz Bankaclk + 1.000 TL Nakit! Enparadan ifte Avantaj

Masrafsz Bankaclk + 1.000 TL Nakit! Enparadan ifte Avantaj
Sayfa 367/393 lklk ... 267317357365366367368369377 ... SonSon
Arama sonucu : 3138 madde; 2,929 - 2,936 aras.

Konu: Tradingview

  1. bu arada topiinde paylatn MTFIM kodunu aldm...denedim... ellerine salk ok gzel bir alma....

    kodu direk altrnca...gelen ayar grafii bozuyor...
    ayarlamasn bilmeyen.... kodu almyor zannedebilir....

    mk ayar cho bulut...st ve alat eklinde.... ksa periyotta olmuyor....

    sanrm scalping iin deil... swing trade iin ok kullanl gibi....

    zellikle mtf pivotlar ile... hisse belirlenip.....

    belirlenen hissede scalping yaplsa daha gzel olur dncesindeyim...

    selamlar...
    16.07.2024 - 10.12.2024

  2. https://www.tradingview.com/x/20Sf79tF/ vadeli aralk...14200-14600... 14450 takip yeri...
    16.07.2024 - 10.12.2024

  3.  Alnt Originally Posted by @yrk@ Yazy Oku
    bu arada topiinde paylatn MTFIM kodunu aldm...denedim... ellerine salk ok gzel bir alma....

    kodu direk altrnca...gelen ayar grafii bozuyor...
    ayarlamasn bilmeyen.... kodu almyor zannedebilir....

    mk ayar cho bulut...st ve alat eklinde.... ksa periyotta olmuyor....

    sanrm scalping iin deil... swing trade iin ok kullanl gibi....

    zellikle mtf pivotlar ile... hisse belirlenip.....

    belirlenen hissede scalping yaplsa daha gzel olur dncesindeyim...

    selamlar...
    Haklsn "her yiidin yourt yiyii..."
    O nedenle gstergeyi uzun uzun anlatmak iin yazmtm. Forum dar atnca hevesim kat bir daha yazmaya.
    Zaten senden baka da kimse ilgilenmeyecei iin endim.

    Ben yle kurgulamtm...
    Ayn gstergeyi 2 hatta 4 ayr gsterge penceresinde ap,
    Her biri farkl periyotlara ve gstergelere ait olacak ekilde, ilgili enstrman hangi periyotta alp-satacaksam...

    Bir rnei aada.
    Sz gelimi:
    1 numaral pencerede: Pivot ve direnleri, HLC, 60fk ortalama... Gerekiyorsa Bollinger.
    2 numaral Ichimoku 240-G-H kanallar, vb...




    Veya yle bir kombinasyon gibi...:


  4. kombine kod birletirme rnekleri (yedekleme)
    formasyon tarama...
    PHP Code:
    //@version=6

    indicator("."overlay=falsemax_lines_count=500max_labels_count=500max_polylines_count=100max_boxes_count=100)

    // LANGUAGE SETTINGS | إعدادات اللغة

    string g_lang "🌐 Language | اللغة"
    string i_lang input.string("English""Interface Language | لغة الواجهة"options=["English""العربية"], group=g_langtooltip="Select display language\nاختر لغة العرض")
    bool isAr i_lang == "العربية"

    // PATTERN SELECTION | اختيار الأنماط

    string g_patterns "📊 Pattern Selection | اختيار الأنماط"
    bool i_show_falling input.bool(true"Falling Wedge | الوتد الهابط"group=g_patternstooltip="Bullish reversal pattern\nنموذج انعكاسي صعودي")
    bool i_show_rising  input.bool(true"Rising Wedge | الوتد الصاعد"group=g_patternstooltip="Bearish reversal pattern\nنموذج انعكاسي هبوطي")

    // PIVOT SYSTEM | نظام المحاور

    string g_pivot "🧠 Pivot System | نظام المحاور"
    int i_pivot_min  input.int(5"Min Left Bars | الحد الأدنى"minval=3maxval=15group=g_pivottooltip="Minimum bars for pivot detection\nالحد الأدنى لشموع اكتشاف المحور")
    int i_pivot_max  input.int(10"Max Left Bars | الحد الأقصى"minval=10maxval=30group=g_pivottooltip="Maximum bars for pivot detection\nالحد الأقصى لشموع اكتشاف المحور")
    int i_right_bars input.int(2"Right Confirm | شموع التأكيد"minval=1maxval=5group=g_pivottooltip="Bars to confirm pivot\nعدد الشموع لتأكيد المحور")

    // DETECTION RULES | قواعد الكشف

    string g_rules "✓ Detection Rules | قواعد الكشف"
    int   i_min_bars    input.int(5"Min Bars Between Points | أقل مسافة بين النقاط"minval=2maxval=20group=g_rulestooltip="Minimum bars between P1-P2-P3-P4\nالحد الأدنى للشموع بين النقاط")
    int   i_min_width   input.int(20"Min Pattern Width | عرض النموذج الأدنى"minval=10maxval=100group=g_rulestooltip="Minimum width from P1 to P4\nالحد الأدنى لعرض النموذج")
    int   i_max_width   input.int(200"Max Pattern Width | عرض النموذج الأقصى"minval=50maxval=300group=g_rulestooltip="Maximum width from P1 to P4\nالحد الأقصى لعرض النموذج")
    int   i_lookback    input.int(100"Lookback Bars | شموع المراجعة"minval=50maxval=300group=g_rulestooltip="How far back to search for pivots\nعدد الشموع للبحث عن المحاور")
    float i_convergence input.float(0.75"Convergence Ratio | نسبة التقارب"minval=0.5maxval=0.95step=0.05group=g_rulestooltip="Max ratio of end gap to start gap\nأقصى نسبة للفجوة النهائية من البداية")
    int   i_max_wait    input.int(50"Max Wait Bars | أقصى انتظار للكسر"minval=10maxval=200group=g_rulestooltip="Cancel pattern if no breakout\nإلغاء النموذج إذا لم يحدث كسر")
    bool  i_strict_channel input.bool(true"Strict Channel | قناة صارمة"group=g_rulestooltip="ON = check high/low (reject wicks)\nOFF = check close only\nمفعّل = فحص القمة/القاع\nمعطّل = فحص الإغلاق فقط")
    float i_tolerance   input.float(0.1"Channel Tolerance % | نسبة التسامح"minval=0.0maxval=1.0step=0.05group=g_rulestooltip="Allow small breaches in strict mode\nالسماح بتجاوزات صغيرة في الوضع الصارم")

    // PRIOR TREND FILTER | فلتر الاتجاه السابق

    string g_trend "📈 Prior Trend Filter | فلتر الاتجاه السابق"
    bool  i_use_trend      input.bool(true"Enable | تفعيل"group=g_trendtooltip="Require trend before pattern\nيتطلب اتجاه قبل النموذج")
    int   i_trend_len      input.int(30"Trend Length | طول الاتجاه"minval=10maxval=100group=g_trendtooltip="Bars to measure prior trend\nعدد الشموع لقياس الاتجاه السابق")
    float i_trend_strength input.float(0.5"Min Strength | الحد الأدنى للقوة"minval=0.1maxval=2.0step=0.1group=g_trendtooltip="ATR multiplier for trend strength\nمضاعف ATR لقوة الاتجاه")

    // QUALITY FILTER | فلتر الجودة

    string g_quality "⭐ Quality Filter | فلتر الجودة"
    bool  i_use_quality  input.bool(true"Enable | تفعيل"group=g_qualitytooltip="Filter patterns by quality score\nتصفية الأنماط حسب درجة الجودة")
    float i_min_quality  input.float(50.0"Min Score | الحد الأدنى"minval=20maxval=90step=5group=g_qualitytooltip="Minimum quality score 0-100\nالحد الأدنى لدرجة الجودة")
    bool  i_show_quality input.bool(true"Show on Chart | عرض على الرسم"group=g_qualitytooltip="Display quality percentage\nعرض نسبة الجودة على الرسم")

    // TARGET SETTINGS | إعدادات الأهداف

    string g_target "🎯 Target Settings | إعدادات الأهداف"
    string i_target_mode input.string("Conservative""Target Mode | وضع الهدف"options=["Conservative""Balanced""Aggressive"], group=g_targettooltip="Conservative=0.618, Balanced=1.0, Aggressive=1.618\nمحافظ=0.618، متوازن=1.0، عدواني=1.618")
    float i_success_ratio input.float(0.5"Success Ratio | نسبة النجاح"minval=0.1maxval=1.0step=0.1group=g_targettooltip="Min move ratio for success\nالحد الأدنى لنسبة الحركة للنجاح")

    // 3D EFFECTS | التأثيرات ثلاثية الأبعاد

    string g_3d "🎨 3D Effects | التأثيرات ثلاثية الأبعاد"
    bool  i_enable_3d       input.bool(true"Enable 3D | تفعيل 3D"group=g_3dtooltip="Enable 3D rendering effect\nتفعيل تأثير الرسم ثلاثي الأبعاد")
    int   i_depth_bars      input.int(2"Depth Bars | عمق الشموع"minval=1maxval=5group=g_3dtooltip="3D depth in bars\nعمق 3D بالشموع")
    float i_depth_percent   input.float(3.0"Height % | نسبة الارتفاع"minval=1.0maxval=10.0step=0.5group=g_3dtooltip="3D height as % of pattern\nارتفاع 3D كنسبة من النموذج")
    int   i_3d_transp       input.int(55"Transparency | الشفافية"minval=30maxval=80group=g_3dtooltip="Base transparency for 3D\nالشفافية الأساسية للـ 3D")
    float i_target_zone_pct input.float(2.0"Target Zone % | نسبة منطقة الهدف"minval=1.0maxval=10.0step=0.5group=g_3dtooltip="Target zone height %\nنسبة ارتفاع منطقة الهدف")
    int   i_target_3d_depth input.int(2"Target 3D Depth | عمق الهدف"minval=1maxval=5group=g_3dtooltip="3D depth for target zone\nعمق 3D لمنطقة الهدف")

    // DISPLAY OPTIONS | خيارات العرض

    string g_display "🖼 Display | العرض"
    bool i_show_old      input.bool(true"Previous Patterns | الأنماط السابقة"group=g_displaytooltip="Show completed patterns history\nعرض تاريخ الأنماط المكتملة")
    bool i_show_old_tgt  input.bool(true"Historical Targets | الأهداف التاريخية"group=g_displaytooltip="Show targets for old patterns\nعرض أهداف الأنماط السابقة")
    bool i_show_points   input.bool(true"Point Labels | تسميات النقاط"group=g_displaytooltip="Show 1-2-3-4 labels\nعرض تسميات 1-2-3-4")
    bool i_show_legs     input.bool(true"Pattern Legs | أرجل النموذج"group=g_displaytooltip="Show connecting lines\nعرض الخطوط الواصلة")
    bool i_log_scale     input.bool(true"Logarithmic Scale | مقياس لوغاريتمي"group=g_displaytooltip="Use log scale for calculations\nاستخدام المقياس اللوغاريتمي")

    // COLORS | الألوان

    string g_colors "🎨 Colors | الألوان"
    color i_falling_color   input.color(color.new(#4CAF50, 0), "Falling Wedge | الوتد الهابط", group=g_colors, tooltip="Color for bullish pattern\nلون النموذج الصعودي")
    color i_rising_color    input.color(color.new(#F44336, 0), "Rising Wedge | الوتد الصاعد", group=g_colors, tooltip="Color for bearish pattern\nلون النموذج الهبوطي")
    color i_target_color    input.color(color.new(#2196F3, 0), "Target Zone | منطقة الهدف", group=g_colors, tooltip="Color for target area\nلون منطقة الهدف")
    color i_achieved_color  input.color(color.new(#FFD700, 0), "Target Hit | تحقق الهدف", group=g_colors, tooltip="Color when target reached\nلون عند تحقق الهدف")
    color i_quality_high    input.color(color.new(#4CAF50, 0), "Quality High | جودة عالية", group=g_colors, tooltip="Quality >= 70%\nالجودة >= 70%")
    color i_quality_med     input.color(color.new(#FF9800, 0), "Quality Medium | جودة متوسطة", group=g_colors, tooltip="Quality 50-70%\nالجودة 50-70%")
    color i_quality_low     input.color(color.new(#F44336, 0), "Quality Low | جودة منخفضة", group=g_colors, tooltip="Quality < 50%\nالجودة < 50%")
    color i_text_color      input.color(color.new(#FFFFFF, 0), "Text Color | لون النص", group=g_colors, tooltip="Label text color\nلون نص التسميات")

    // DATA TYPES | أنواع البيانات

    type Pivot
        bool   is_high
        float  price
        int    bar_idx

    type WedgeData
        bool     is_falling
        Pivot    p1
        Pivot    p2
        Pivot    p3
        Pivot    p4
        int      u1_bar
        float    u1_price
        int      u2_bar
        float    u2_price
        int      l1_bar
        float    l1_price
        int      l2_bar
        float    l2_price
        float    quality
        float    max_height
        float    height
        bool     broken
        bool     cancelled
        bool     target_hit
        bool     success_hit
        int      breakout_bar
        float    breakout_price
        float    target_price
        float    success_level
        int      achieved_bar
        line     line_upper
        line     line_lower
        line     line_sec_upper
        line     line_sec_lower
        line     leg2
        line     leg3
        polyline poly_top_face
        polyline poly_side_face
        polyline poly_bottom_edge
        polyline fill_main
        polyline fill_secondary
        box      target_box
        polyline target_top_face
        polyline target_side_face
        line     line_target_v
        label    lbl_target_price
        label    lbl_p1
        label    lbl_p2
        label    lbl_p3
        label    lbl_p4
        label    lbl_quality
        label    lbl_name

    var float atr_fast na
    var float atr_slow na
    var float atr_14 na

    atr_fast 
    := ta.atr(10)
    atr_slow := ta.atr(50)
    atr_14   := ta.atr(14)

    // ADX CALCULATION | حساب ADX

    calc_adx(int len) =>
        
    float up ta.change(high)
        
    float dn = -ta.change(low)
        
    float plus_dm na(up) ? na : (up dn and up up 0)
        
    float minus_dm na(dn) ? na : (dn up and dn dn 0)
        
    float tr_rma ta.rma(ta.trlen)
        
    float plus_di fixnan(100 ta.rma(plus_dmlen) / tr_rma)
        
    float minus_di fixnan(100 ta.rma(minus_dmlen) / tr_rma)
        
    float dx math.abs(plus_di minus_di) / math.max(plus_di minus_di1) * 100
        ta
    .rma(dxlen)
    float adx_val calc_adx(14)

    // ADAPTIVE PIVOT SYSTEM | نظام المحاور التكيفي

    calc_adaptive_pivot() =>
        
    float vol_score math.min(nz(atr_fast atr_slow1.0), 2.0) / 2.0
        float trend_score 
    math.min(adx_val 501.0)
        
    float atr_std ta.stdev(atr_fast20)
        
    float atr_mean ta.sma(atr_fast20)
        
    float stability_score math.min(nz(atr_std atr_mean0.5) * 21.0)
        
    float atr_pct ta.percentile_nearest_rank(atr_fast10050)
        
    float context_norm math.min(nz(atr_fast atr_pct1.0), 2.0) / 2.0
        float avg_range 
    ta.sma(high low10)
        
    float range_score math.min(nz((high low) / avg_range1.0), 2.0) / 2.0
        float final_score 
    = (vol_score 0.30) + (trend_score 0.25) + (stability_score 0.20) + (context_norm 0.15) + (range_score 0.10)
        
    math.max(i_pivot_minmath.min(i_pivot_maxi_pivot_min int((i_pivot_max i_pivot_min) * final_score)))

    // CORE FUNCTIONS | الدوال الأساسية

    calc_price(float p1int b1float p2int b2int target) =>
        if 
    b2 == b1 or p1 <= or p2 <= 0
            p2
        
    else if i_log_scale
            p2 
    math.exp((math.log(p2) - math.log(p1)) / (b2 b1) * (target b2))
        else
            
    p2 + (p2 p1) / (b2 b1) * (target b2)

    get_trend_data(int lookback_len) =>
        array<
    floattrend_vals = array.new<float>()
        for 
    0 to lookback_len
            int off_start 
    i_trend_len
            
    if off_start bar_index
                float price_start 
    close[off_start]
                
    float price_end close[i]
                
    float atr_at_i atr_14[i]
                
    float normalized atr_at_i ? (price_end price_start) / atr_at_i 0.0
                trend_vals
    .push(normalized)
            else
                
    trend_vals.push(0.0)
        
    trend_vals

    calc_max_height
    (int u1bfloat u1pint u2bfloat u2pint l1bfloat l1pint l2bfloat l2pint start_barint end_bar) =>
        
    float max_h 0.0
        
    for start_bar to end_bar by 5
            float u_at_b 
    calc_price(u1pu1bu2pu2bb)
            
    float l_at_b calc_price(l1pl1bl2pl2bb)
            
    float h math.abs(u_at_b l_at_b)
            if 
    max_h
                max_h 
    := h
        max_h

    calc_quality
    (float convfloat slope_ratioint widthfloat trend_strfloat max_hfloat atr) =>
        
    float conv_score = (conv) * 100
        float slope_score 
    math.max(0100 math.abs(slope_ratio 1) * 50)
        
    float width_score width >= 40 and width <= 100 100.0 width 40 width 40 100 math.max(0100 - (width 100) / 2)
        
    float trend_score math.min(math.abs(trend_str) / 21.0) * 100
        float height_score 
    math.min(max_h / (atr 3), 1.0) * 100
        
    (conv_score 0.30) + (slope_score 0.25) + (width_score 0.20) + (trend_score 0.15) + (height_score 0.10)

    get_target_mult() =>
        switch 
    i_target_mode
            
    "Conservative" => 0.618
            
    "Balanced" => 1.0
            
    => 1.618

    // 3D HELPER FUNCTIONS | دوال مساعدة للـ 3D

    create_3d_face(array<chart.pointpointscolor edge_colcolor fill_col) =>
        
    polyline.new(pointsclosed=trueline_color=edge_colfill_color=fill_colline_width=1)

    method draw_wedge_3d(WedgeData thisint end_barcolor col) =>
        
    line.delete(this.line_upper)
        
    line.delete(this.line_lower)
        
    line.delete(this.line_sec_upper)
        
    line.delete(this.line_sec_lower)
        
    polyline.delete(this.poly_top_face)
        
    polyline.delete(this.poly_side_face)
        
    polyline.delete(this.poly_bottom_edge)
        
    polyline.delete(this.fill_main)
        
    polyline.delete(this.fill_secondary)
        
        
    float upper_end calc_price(this.u1_pricethis.u1_barthis.u2_pricethis.u2_barend_bar)
        
    float lower_end calc_price(this.l1_pricethis.l1_barthis.l2_pricethis.l2_barend_bar)
        
        if 
    upper_end lower_end and lower_end 0
            float depth_3d 
    this.max_height * (i_depth_percent 100)
            
    int transp i_3d_transp
            
            color line_col 
    color.new(col20)
            
    color fill_col color.new(coltransp 20)
            
    color edge_col color.new(coltransp 10)
            
    color face_col color.new(coltransp 10)
            
            
    this.line_upper := line.new(this.u1_barthis.u1_pricethis.u2_barthis.u2_pricecolor=line_colwidth=2)
            
    this.line_lower := line.new(this.l1_barthis.l1_pricethis.l2_barthis.l2_pricecolor=line_colwidth=2)
            
    this.line_sec_upper := line.new(this.u2_barthis.u2_priceend_barupper_endcolor=line_colwidth=2style=line.style_dotted)
            
    this.line_sec_lower := line.new(this.l2_barthis.l2_priceend_barlower_endcolor=line_colwidth=2style=line.style_dotted)
            
            if 
    i_enable_3d
                this
    .poly_top_face := create_3d_face(array.from(chart.point.from_index(this.u1_barthis.u1_price), chart.point.from_index(this.u1_bar i_depth_barsthis.u1_price depth_3d), chart.point.from_index(end_bar i_depth_barsupper_end depth_3d), chart.point.from_index(end_barupper_end)), edge_colface_col)
                
    this.poly_side_face := create_3d_face(array.from(chart.point.from_index(end_barupper_end), chart.point.from_index(end_bar i_depth_barsupper_end depth_3d), chart.point.from_index(end_bar i_depth_barslower_end depth_3d), chart.point.from_index(end_barlower_end)), edge_colface_col)
                
    this.poly_bottom_edge := create_3d_face(array.from(chart.point.from_index(this.l1_barthis.l1_price), chart.point.from_index(this.l1_bar i_depth_barsthis.l1_price depth_3d), chart.point.from_index(end_bar i_depth_barslower_end depth_3d), chart.point.from_index(end_barlower_end)), edge_colface_col)
            
            
    this.fill_main := polyline.new(array.from(chart.point.from_index(this.p1.bar_idxthis.p1.price), chart.point.from_index(this.p2.bar_idxthis.p2.price), chart.point.from_index(this.p4.bar_idxthis.p4.price), chart.point.from_index(this.p3.bar_idxthis.p3.price)), closed=truefill_color=fill_colline_color=na)
            
    this.fill_secondary := polyline.new(array.from(chart.point.from_index(this.u2_barthis.u2_price), chart.point.from_index(this.l2_barthis.l2_price), chart.point.from_index(end_barlower_end), chart.point.from_index(end_barupper_end)), closed=truefill_color=fill_colline_color=na)
        
    this

    // DRAW TARGET 3D | رسم الهدف ثلاثي الأبعاد

    method draw_target_3d(WedgeData thiscolor col) =>
        
    box.delete(this.target_box)
        
    polyline.delete(this.target_top_face)
        
    polyline.delete(this.target_side_face)
        
    line.delete(this.line_target_v)
        
    label.delete(this.lbl_target_price)
        
        if 
    this.broken and not na(this.breakout_bar) and not na(this.target_price)
            
    float zone_height this.height * (i_target_zone_pct 100)
            
    float zone_top this.target_price zone_height 2
            float zone_bottom 
    this.target_price zone_height 2
            int zone_right 
    this.target_hit this.achieved_bar bar_index
            float depth_3d 
    zone_height 0.5
            
            color current_col 
    this.target_hit i_achieved_color col
            int transp 
    this.target_hit 65 75
            
            this
    .target_box := box.new(this.breakout_barzone_topzone_rightzone_bottomborder_color=color.new(current_col30), border_width=1border_style=line.style_solidbgcolor=color.new(current_coltransp))
            
            if 
    i_enable_3d
                this
    .target_top_face := create_3d_face(array.from(chart.point.from_index(this.breakout_barzone_top), chart.point.from_index(this.breakout_bar i_target_3d_depthzone_top depth_3d), chart.point.from_index(zone_right i_target_3d_depthzone_top depth_3d), chart.point.from_index(zone_rightzone_top)), color.new(current_col40), color.new(current_coltransp 5))
                
    this.target_side_face := create_3d_face(array.from(chart.point.from_index(zone_rightzone_top), chart.point.from_index(zone_right i_target_3d_depthzone_top depth_3d), chart.point.from_index(zone_right i_target_3d_depthzone_bottom depth_3d), chart.point.from_index(zone_rightzone_bottom)), color.new(current_col40), color.new(current_coltransp 3))
            
            
    this.line_target_v := line.new(this.breakout_barthis.breakout_pricethis.breakout_barthis.target_pricecolor=current_colstyle=line.style_dottedwidth=2)
            
            
    string price_txt str.tostring(this.target_priceformat.mintick)
            
    string status_txt this.target_hit " ✓" ""
            
    this.lbl_target_price := label.new(zone_right 2this.target_priceprice_txt status_txtcolor=color.new(current_col100), textcolor=current_colstyle=label.style_label_leftsize=size.small)
        
    this

    // DRAW LEGS | رسم الأرجل

    method draw_legs(WedgeData thiscolor col) =>
        
    line.delete(this.leg2)
        
    line.delete(this.leg3)
        if 
    i_show_legs
            this
    .leg2 := line.new(this.p2.bar_idxthis.p2.pricethis.p3.bar_idxthis.p3.pricecolor=color.new(col40), width=1style=line.style_dotted)
            
    this.leg3 := line.new(this.p3.bar_idxthis.p3.pricethis.p4.bar_idxthis.p4.pricecolor=color.new(col40), width=1style=line.style_dotted)
        
    this

    // DRAW POINTS & LABELS | رسم النقاط والتسميات

    method draw_points(WedgeData thiscolor col) =>
        
    label.delete(this.lbl_p1)
        
    label.delete(this.lbl_p2)
        
    label.delete(this.lbl_p3)
        
    label.delete(this.lbl_p4)
        
    label.delete(this.lbl_quality)
        
    label.delete(this.lbl_name)
        
        if 
    i_show_points
            color trans 
    color.new(col100)
            
    this.lbl_p1 := label.new(this.p1.bar_idxthis.p1.price"1"style=this.is_falling label.style_label_down label.style_label_upcolor=transtextcolor=colsize=size.normal)
            
    this.lbl_p2 := label.new(this.p2.bar_idxthis.p2.price"2"style=this.is_falling label.style_label_up label.style_label_downcolor=transtextcolor=colsize=size.normal)
            
    this.lbl_p3 := label.new(this.p3.bar_idxthis.p3.price"3"style=this.is_falling label.style_label_down label.style_label_upcolor=transtextcolor=colsize=size.normal)
            
    this.lbl_p4 := label.new(this.p4.bar_idxthis.p4.price"4"style=this.is_falling label.style_label_up label.style_label_downcolor=transtextcolor=colsize=size.normal)
        
        if 
    i_show_quality and i_use_quality
            color q_col 
    this.quality >= 70 i_quality_high this.quality >= 50 i_quality_med i_quality_low
            int mid_bar 
    = (this.p1.bar_idx this.p4.bar_idx) / 2
            float mid_price 
    = (this.p1.price this.p4.price) / 2
            this
    .lbl_quality := label.new(mid_barmid_price 0.997str.tostring(this.quality"#") + "%"color=color.new(q_col30), textcolor=i_text_colorstyle=label.style_label_centersize=size.small)
        
        
    string name this.is_falling ? (isAr "هابط" "D") : (isAr "صاعد" "YKSEL")
        
    int mid_bar = (this.u1_bar this.p4.bar_idx) / 2
        float upper_mid 
    calc_price(this.u1_pricethis.u1_barthis.u2_pricethis.u2_barmid_bar)
        
    float lower_mid calc_price(this.l1_pricethis.l1_barthis.l2_pricethis.l2_barmid_bar)
        
    float mid_price = (upper_mid lower_mid) / 2
        this
    .lbl_name := label.new(mid_barmid_pricenamecolor=color.new(col100), textcolor=color.new(i_text_color30), style=label.style_nonesize=size.large)
        
    this

    // DELETE ALL | حذف الكل

    method delete_all(WedgeData this) =>
        if 
    not na(this)
            
    line.delete(this.line_upper)
            
    line.delete(this.line_lower)
            
    line.delete(this.line_sec_upper)
            
    line.delete(this.line_sec_lower)
            
    line.delete(this.leg2)
            
    line.delete(this.leg3)
            
    line.delete(this.line_target_v)
            
    polyline.delete(this.poly_top_face)
            
    polyline.delete(this.poly_side_face)
            
    polyline.delete(this.poly_bottom_edge)
            
    polyline.delete(this.fill_main)
            
    polyline.delete(this.fill_secondary)
            
    polyline.delete(this.target_top_face)
            
    polyline.delete(this.target_side_face)
            
    box.delete(this.target_box)
            
    label.delete(this.lbl_p1)
            
    label.delete(this.lbl_p2)
            
    label.delete(this.lbl_p3)
            
    label.delete(this.lbl_p4)
            
    label.delete(this.lbl_quality)
            
    label.delete(this.lbl_name)
            
    label.delete(this.lbl_target_price)

    method delete_targets(WedgeData this) =>
        if 
    not na(this)
            
    line.delete(this.line_target_v)
            
    polyline.delete(this.target_top_face)
            
    polyline.delete(this.target_side_face)
            
    box.delete(this.target_box)
            
    label.delete(this.lbl_target_price)
            
    this.line_target_v := na
            this
    .target_top_face := na
            this
    .target_side_face := na
            this
    .target_box := na
            this
    .lbl_target_price := na

    // GLOBAL VARIABLES | المتغيرات العامة

    var array<Pivotpivots = array.new<Pivot>()
    var array<
    WedgeDatapatterns = array.new<WedgeData>()
    var 
    WedgeData active_fall na
    var WedgeData active_rise na
    var WedgeData last_broken_fall na
    var WedgeData last_broken_rise na
    var bool fall_brk false
    var bool rise_brk false

    int eff_left 
    calc_adaptive_pivot()
    array<
    floattrend_data get_trend_data(i_lookback)

    // COLLECT PIVOTS | جمع المحاور

    float ph ta.pivothigh(higheff_lefti_right_bars)
    float pl ta.pivotlow(loweff_lefti_right_bars)
    int pbar bar_index i_right_bars

    if not na(ph)
        
    pivots.push(Pivot.new(truephpbar))
    if 
    not na(pl)
        
    pivots.push(Pivot.new(falseplpbar))

    while 
    pivots.size() > and bar_index pivots.first().bar_idx i_lookback
        pivots
    .shift()

    // VALIDATION FUNCTIONS | دوال التحقق

    is_extreme_fast(int sint efloat refbool check_high, array<Pivotarr) =>
        
    bool ok true
        int n 
    arr.size()
        for 
    0 to n 1
            Pivot p 
    arr.get(i)
            if 
    p.bar_idx <= or p.bar_idx >= e
                
    continue
            if 
    p.is_high == check_high
                
    if (check_high and p.price ref) or (not check_high and p.price ref)
                    
    ok := false
                    
    break
        
    ok

    check_channel
    (int u1bfloat u1pint u2bfloat u2pint l1bfloat l1pint l2bfloat l2pint start_bint end_b) =>
        
    bool ok true
        
    for start_b to end_b
            int off 
    bar_index b
            
    if off >= and off bar_index
                float u 
    calc_price(u1pu1bu2pu2bb)
                
    float l calc_price(l1pl1bl2pl2bb)
                if 
    close[off] > or close[off] < l
                    ok 
    := false
                    
    break
        
    ok

    check_channel_strict
    (int u1bfloat u1pint u2bfloat u2pint l1bfloat l1pint l2bfloat l2pint start_bint end_b) =>
        
    bool ok true
        float d 
    i_tolerance 100.0
        
    for start_b to end_b
            int off 
    bar_index b
            
    if off >= and off bar_index and not na(high[off]) and not na(low[off])
                
    float u calc_price(u1pu1bu2pu2bb)
                
    float l calc_price(l1pl1bl2pl2bb)
                if 
    high[off] > * (d) or low[off] < * (d)
                    
    ok := false
                    
    break
        
    ok

    check_after_p4
    (int u1bfloat u1pint u2bfloat u2pint l1bfloat l1pint l2bfloat l2pint p4_barfloat p4_pricebool is_fall) =>
        
    bool ok true
        
    if p4_bar bar_index
            
    for p4_bar 1 to bar_index
                int off 
    bar_index b
                
    if off >= and off bar_index and not na(close[off])
                    
    float u calc_price(u1pu1bu2pu2bb)
                    
    float l calc_price(l1pl1bl2pl2bb)
                    if 
    is_fall
                        
    if close[off] < or close[off] < p4_price
                            ok 
    := false
                            
    break
                    else
                        if 
    close[off] > or close[off] > p4_price
                            ok 
    := false
                            
    break
        
    ok

    check_trend_from_data
    (int p1_barbool need_bullish, array<floatdata) =>
        if 
    not i_use_trend
            true
        
    else
            
    int off_p1 bar_index p1_bar
            
    if off_p1 >= and off_p1 data.size()
                
    float trend_val data.get(off_p1)
                
    need_bullish trend_val >= i_trend_strength trend_val <= -i_trend_strength
            
    else
                
    false

    // FIND WEDGE | البحث عن الوتد

    find_wedge(bool is_fall, array<floatt_data) =>
        
    WedgeData result na
        float best_quality 
    0.0
        int n 
    pivots.size()
        
        if 
    >= 4
            
    array<inthighs = array.new<int>()
            array<
    intlows = array.new<int>()
            for 
    0 to n 1
                
    if pivots.get(i).is_high
                    highs
    .push(i)
                else
                    
    lows.push(i)
            
            array<
    intp1_p3_arr is_fall highs lows
            
    array<intp2_p4_arr is_fall lows highs
            
            int n13 
    p1_p3_arr.size()
            
    int n24 p2_p4_arr.size()
            
            if 
    n13 >= and n24 >= 2
                
    for i4_idx n24 1 to 1
                    int i4 
    p2_p4_arr.get(i4_idx)
                    
    Pivot p4 pivots.get(i4)
                    
                    for 
    i3_idx n13 1 to 1
                        int i3 
    p1_p3_arr.get(i3_idx)
                        if 
    i3 >= i4
                            
    continue
                        
    Pivot p3 pivots.get(i3)
                        if 
    p4.bar_idx p3.bar_idx i_min_bars
                            
    continue
                        
                        for 
    i2_idx i4_idx 1 to 0
                            int i2 
    p2_p4_arr.get(i2_idx)
                            if 
    i2 >= i3
                                
    continue
                            
    Pivot p2 pivots.get(i2)
                            if 
    p3.bar_idx p2.bar_idx i_min_bars
                                
    continue
                            if 
    is_fall p2.price <= p4.price p2.price >= p4.price
                                
    continue
                            
                            for 
    i1_idx i3_idx 1 to 0
                                int i1 
    p1_p3_arr.get(i1_idx)
                                if 
    i1 >= i2
                                    
    continue
                                
    Pivot p1 pivots.get(i1)
                                if 
    p2.bar_idx p1.bar_idx i_min_bars
                                    
    continue
                                if 
    is_fall p1.price <= p3.price p1.price >= p3.price
                                    
    continue
                                
                                
    int width p4.bar_idx p1.bar_idx
                                
    if width i_min_width or width i_max_width
                                    
    continue
                                
                                if 
    not check_trend_from_data(p1.bar_idxis_fallt_data)
                                    continue
                                
                                
    int u1b is_fall p1.bar_idx p2.bar_idx
                                float u1p 
    is_fall p1.price p2.price
                                int u2b 
    is_fall p3.bar_idx p4.bar_idx
                                float u2p 
    is_fall p3.price p4.price
                                int l1b 
    is_fall p2.bar_idx p1.bar_idx
                                float l1p 
    is_fall p2.price p1.price
                                int l2b 
    is_fall p4.bar_idx p3.bar_idx
                                float l2p 
    is_fall p4.price p3.price
                                
                                float u_sl 
    = (u2p u1p) / (u2b u1b)
                                
    float l_sl = (l2p l1p) / (l2b l1b)
                                
                                if (
    is_fall and (u_sl >= or l_sl >= or u_sl >= l_sl)) or (not is_fall and (u_sl <= or l_sl <= or l_sl <= u_sl))
                                    continue
                                
                                
    float gap_s is_fall p1.price - (l1p l_sl * (p1.bar_idx l1b)) : (u1p u_sl * (p1.bar_idx u1b)) - p1.price
                                float gap_e 
    is_fall ? (u1p u_sl * (p4.bar_idx u1b)) - p4.price p4.price - (l1p l_sl * (p4.bar_idx l1b))
                                
                                if 
    gap_s <= or gap_e <= or gap_e >= gap_s
                                    
    continue
                                
                                
    float conv gap_e gap_s
                                
    if conv >= i_convergence
                                    
    continue
                                
                                if 
    not is_extreme_fast(p1.bar_idxp4.bar_idxis_fall p1.price p4.pricetruepivots)
                                    continue
                                if 
    not is_extreme_fast(p1.bar_idxp4.bar_idxis_fall p4.price p1.pricefalsepivots)
                                    continue
                                
                                
    bool channel_ok i_strict_channel check_channel_strict(u1bu1pu2bu2pl1bl1pl2bl2pp1.bar_idxp4.bar_idx) : check_channel(u1bu1pu2bu2pl1bl1pl2bl2pp1.bar_idxp4.bar_idx)
                                if 
    not channel_ok
                                    
    continue
                                
                                if 
    not check_after_p4(u1bu1pu2bu2pl1bl1pl2bl2pp4.bar_idxp4.priceis_fall)
                                    continue
                                
                                
    float max_h calc_max_height(u1bu1pu2bu2pl1bl1pl2bl2pp1.bar_idxp4.bar_idx)
                                
    int off_p1 bar_index p1.bar_idx
                                float trend_str 
    off_p1 >= and off_p1 t_data.size() ? t_data.get(off_p1) : 0.0
                                float slope_ratio 
    math.abs(u_sl) > math.abs(l_sl u_sl) : 1.0
                                float quality 
    calc_quality(convslope_ratiowidthtrend_strmax_hatr_14)
                                
                                if 
    i_use_quality and quality i_min_quality
                                    
    continue
                                
                                if 
    quality best_quality
                                    best_quality 
    := quality
                                    float pat_height 
    math.abs(p1.price p4.price)
                                    
    result := WedgeData.new(is_fallp1p2p3p4u1bu1pu2bu2pl1bl1pl2bl2pqualitymax_hpat_heightfalsefalsefalsefalsenanananananananananananananananananananananananananana)
        
    result

    // PROCESS PATTERN | معالجة النمط

    process(WedgeData activeWedgeData new_patcolor colbool is_fall) =>
        
    WedgeData result active
        WedgeData to_archive 
    na
        
    if not na(new_pat)
            
    bool dom not na(active) and (new_pat.p4.bar_idx == active.p4.bar_idx or (not (new_pat.p4.bar_idx active.p1.bar_idx or new_pat.p1.bar_idx active.p4.bar_idx) and new_pat.p4.bar_idx new_pat.p1.bar_idx <= active.p4.bar_idx active.p1.bar_idx))
            if 
    not dom
                
    if not na(active)
                    
    bool overlap not (new_pat.p4.bar_idx active.p1.bar_idx or new_pat.p1.bar_idx active.p4.bar_idx)
                    if 
    not overlap and active.broken
                        to_archive 
    := active
                    
    else
                        
    active.delete_all()
                
    result := new_pat
                result
    .draw_wedge_3d(bar_indexcol).draw_legs(col).draw_points(col)
        [
    resultto_archive]

    // PATTERN LIFECYCLE | دورة حياة النمط

    lifecycle(WedgeData patcolor col) =>
        
    WedgeData result pat
        bool brk_sig 
    false
        
    if not na(pat) and not pat.broken and not pat.cancelled
            int bars 
    bar_index pat.p4.bar_idx
            float u 
    calc_price(pat.u1_pricepat.u1_barpat.u2_pricepat.u2_barbar_index)
            
    float l calc_price(pat.l1_pricepat.l1_barpat.l2_pricepat.l2_barbar_index)
            
            
    bool brk pat.is_falling close close l
            bool cancel_line 
    pat.is_falling close close u
            bool cancel_p4 
    pat.is_falling close pat.p4.price close pat.p4.price
            bool cancel 
    cancel_line or cancel_p4 or bars i_max_wait
            
            
    if brk and barstate.isconfirmed
                pat
    .broken := true
                pat
    .breakout_bar := bar_index
                pat
    .breakout_price := pat.is_falling l
                pat
    .success_level := pat.is_falling pat.breakout_price pat.height i_success_ratio pat.breakout_price pat.height i_success_ratio
                pat
    .target_price := pat.is_falling pat.breakout_price pat.height get_target_mult() : pat.breakout_price pat.height get_target_mult()
                
    pat.draw_wedge_3d(bar_indexcol).draw_target_3d(i_target_color)
                
    brk_sig := true
            
    else if cancel and barstate.isconfirmed
                pat
    .cancelled := true
                pat
    .delete_all()
                
    result := na
            
    else
                
    pat.draw_wedge_3d(bar_indexcol)
        
        if 
    not na(pat) and pat.broken and not pat.success_hit
            bool success_condition 
    pat.is_falling high >= pat.success_level low <= pat.success_level
            
    if success_condition
                pat
    .success_hit := true
        
        
    if not na(pat) and pat.broken and not pat.target_hit
            float zone_top 
    pat.target_price pat.height * (i_target_zone_pct 100) / 2
            float zone_bottom 
    pat.target_price pat.height * (i_target_zone_pct 100) / 2
            bool hit 
    pat.is_falling high >= zone_bottom low <= zone_top
            
    if hit
                pat
    .target_hit := true
                pat
    .achieved_bar := bar_index
            pat
    .draw_target_3d(pat.target_hit i_achieved_color i_target_color)
        
        [
    resultbrk_sig]

    // MAIN EXECUTION | التنفيذ الرئيسي

    fall_brk := false
    rise_brk 
    := false

    if i_show_falling
        
    [upd_fallarch_fall] = process(active_fallfind_wedge(truetrend_data), i_falling_colortrue)
        
    active_fall := upd_fall
        
        
    if not na(arch_fall)
            if 
    not na(last_broken_fall)
                if 
    i_show_old
                    
    if not i_show_old_tgt
                        last_broken_fall
    .delete_targets()
                    
    patterns.push(last_broken_fall)
                else
                    
    last_broken_fall.delete_all()
            
    last_broken_fall := arch_fall
        
        
    [upd2sig] = lifecycle(active_falli_falling_color)
        
    active_fall := upd2
        fall_brk 
    := sig
        
        
    if not na(last_broken_fall) and last_broken_fall.broken and not last_broken_fall.target_hit
            float zone_top 
    last_broken_fall.target_price last_broken_fall.height * (i_target_zone_pct 100) / 2
            float zone_bottom 
    last_broken_fall.target_price last_broken_fall.height * (i_target_zone_pct 100) / 2
            bool hit 
    high >= zone_bottom
            
    if hit
                last_broken_fall
    .target_hit := true
                last_broken_fall
    .achieved_bar := bar_index
            last_broken_fall
    .draw_target_3d(last_broken_fall.target_hit i_achieved_color i_target_color)

    if 
    i_show_rising
        
    [upd_risearch_rise] = process(active_risefind_wedge(falsetrend_data), i_rising_colorfalse)
        
    active_rise := upd_rise
        
        
    if not na(arch_rise)
            if 
    not na(last_broken_rise)
                if 
    i_show_old
                    
    if not i_show_old_tgt
                        last_broken_rise
    .delete_targets()
                    
    patterns.push(last_broken_rise)
                else
                    
    last_broken_rise.delete_all()
            
    last_broken_rise := arch_rise
        
        
    [upd2sig] = lifecycle(active_risei_rising_color)
        
    active_rise := upd2
        rise_brk 
    := sig
        
        
    if not na(last_broken_rise) and last_broken_rise.broken and not last_broken_rise.target_hit
            float zone_top 
    last_broken_rise.target_price last_broken_rise.height * (i_target_zone_pct 100) / 2
            float zone_bottom 
    last_broken_rise.target_price last_broken_rise.height * (i_target_zone_pct 100) / 2
            bool hit 
    low <= zone_top
            
    if hit
                last_broken_rise
    .target_hit := true
                last_broken_rise
    .achieved_bar := bar_index
            last_broken_rise
    .draw_target_3d(last_broken_rise.target_hit i_achieved_color i_target_color)

    if 
    patterns.size() > 40
        patterns
    .shift().delete_all()

    // ALERTS | التنبيهات

    alertcondition(fall_brk"Falling Wedge Breakout""🟢 Bullish Breakout - Falling Wedge | كسر صعودي - وتد هابط {{ticker}} {{interval}}")
    alertcondition(rise_brk"Rising Wedge Breakout""🔴 Bearish Breakout - Rising Wedge | كسر هبوطي - وتد صاعد {{ticker}} {{interval}}")
    alertcondition(fall_brk or rise_brk"Any Wedge Breakout""⚡ Wedge Breakout | كسر وتد {{ticker}} {{interval}}")
    //////////////////////

    ma_tt '=== Moving Average Cycle ==='
    _source close
    _p 
    input(100title 'Period'inline 'set1'group ma_tt)
    _c ta.ema(close_p) - ta.sma(close_p)
    _m 0
    sr_group 
    '=== Support Resistance ==='
    Left input.int(4title '.'minval 1group sr_group)
    Right input.int(4title '.'minval 0group sr_group)
    trading_group '=== Trading Setup ==='
    trading_setup input.string('Both'title 'Setup'options = ['Long Only''Short Only''Both''MA Cycle''RSI_MACD''Gaussian_Filter'], group trading_group)

    var 
    Long false
    Short 
    false
    if trading_setup == 'Long Only'
        
    Long := true
        Short 
    := false
        Short
    else if trading_setup == 'Short Only'
        
    Long := false
        Short 
    := true
        Short
    else if trading_setup == 'MA Cycle'
        
    if _c 0
            Long 
    := true
            Short 
    := false
            Short
        
    else
            
    Long := false
            Short 
    := true
            Short
    //else if trading_setup == 'RSI_MACD'
        //if _m > 0
            //Long := true
            //Short := false
            //Short
        //else
            //Long := false
            //Short := true
            //Short
    //else if trading_setup == 'Gaussian_Filter'
        //if _g > 0
            //Long := true
            //Short := false
            //Short
        //else
            //Long := false
            //Short := true
            //Short
    else
        
    Long := true
        Short 
    := true
        Short
        
    //Background Filling
    ///

    isFractal(x) =>
        
    ta.highestbars(xLeft Right 1) == -Right
    sF 
    isFractal(-low)
    support low
    support 
    := sF low[Right] : support[1]
    rF isFractal(high)
    resistance high
    resistance 
    := rF high[Right] : resistance[1]
    //Value & Index
    ph35 rF
    ph_val 
    ta.valuewhen(ph35resistance0)
    res ph_val
    ph_index 
    ta.valuewhen(ph35bar_index Right0)

    pl35 sF
    pl_val 
    ta.valuewhen(pl35support0)
    sup pl_val
    pl_index 
    ta.valuewhen(pl35bar_index Right0)
    //Long setup
    var long_sup_index 0
    long_sup_val 
    0.0
    long_res_val 
    0.0
    if pl_index ph_index
        long_sup_index 
    := pl_index
        long_sup_val 
    := pl_val
        long_res_val 
    := ph_val
        long_res_val
    else
        
    long_sup_index := long_sup_index[1]
        
    long_sup_val := long_sup_val[1]
        
    long_sup_val
    if long_sup_index == long_sup_index[1]
        
    long_res_val := long_res_val[1]
        
    long_res_val
        
    //Long Condition
    long_cond close long_sup_val and Long
    //Resistance Line
    long_res_x1 long_sup_index
    long_res_y1 
    long_cond long_res_val na
    long_res_x2 
    bar_index
    long_res_y2 
    long_res_y1
    long_res_ext 
    extend.right
    long_res_clr 
    color.new(color.red0)
    long_res_textColor color.new(color.white0)
    long_res_sty line.style_dotted
    long_res_width 
    2
    plot
    (long_cond long_res_y1 natitle 'Long Arttr'color color.new(color.red100))

    //Support Line
    long_sup_x1 long_sup_index
    long_sup_y1 
    Long long_sup_val na
    long_sup_x2 
    bar_index
    long_sup_y2 
    long_sup_y1
    long_sup_ext 
    extend.right
    long_sup_clr 
    color.new(color.blue0)
    long_sup_textColor color.new(color.white0)
    long_sup_sty line.style_dotted
    long_sup_width 
    2
    plot
    (Long long_sup_val natitle 'Long DnME'color color.new(color.blue100))
    //Fib50 Line
    long_fib50_x1 long_sup_index
    long_fib50_y1 
    long_cond ? (long_res_y1 long_sup_y1) * 0.5 na
    long_fib50_x2 
    bar_index
    long_fib50_y2 
    long_fib50_y1
    long_fib50_ext 
    extend.right
    long_fib50_clr 
    color.new(color.blue0)
    long_fib50_textColor color.new(color.white0)
    long_fib50_sty line.style_dotted
    long_fib50_width 
    2
    plot
    (long_cond long_fib50_y1 natitle 'Long Bala'color color.new(color.blue100))
    //Fib618 Line
    long_fib618_x1 long_sup_index
    long_fib618_y1 
    long_cond long_res_y1 - (long_res_y1 long_sup_y1) * 0.618 na
    long_fib618_x2 
    bar_index
    long_fib618_y2 
    long_fib618_y1
    long_fib618_ext 
    extend.right
    long_fib618_clr 
    color.new(color.blue0)
    long_fib618_textColor color.new(color.white0)
    long_fib618_sty line.style_dotted
    long_fib618_width 
    2

    long_tp1_x1 
    long_sup_index
    long_tp1_y1 
    long_cond long_res_y1 + (long_res_y1 long_sup_y1) * 0.382 na
    long_tp1_x2 
    bar_index
    long_tp1_y2 
    long_tp1_y1
    long_tp1_ext 
    extend.right
    long_tp1_clr 
    color.new(color.blue0)
    long_tp1_textColor color.new(color.white0)
    long_tp1_sty line.style_dotted
    long_tp1_width 
    2
    plot
    (long_cond long_tp1_y1 natitle 'Long Kapat'color color.new(color.blue100))
    //tp2
    long_tp2_x1 long_sup_index
    long_tp2_y1 
    long_cond long_res_y1 long_res_y1 long_sup_y1 na
    long_tp2_x2 
    bar_index
    long_tp2_y2 
    long_tp2_y1
    long_tp2_ext 
    extend.right
    long_tp2_clr 
    color.new(color.blue0)
    long_tp2_textColor color.new(color.white0)
    long_tp2_sty line.style_dotted
    long_tp2_width 
    2
    plot
    (long_cond long_tp2_y1 natitle 'Long Kesin Kapat'color color.new(color.blue100))

    //Short setup
    var short_res_index 0
    short_res_val 
    0.0
    short_sup_val 
    0.0
    if pl_index ph_index
        short_res_index 
    := ph_index
        short_res_val 
    := ph_val
        short_sup_val 
    := pl_val
        short_sup_val
    else
        
    short_res_index := short_res_index[1]
        
    short_res_val := short_res_val[1]
        
    short_res_val
    if short_res_index == short_res_index[1]
        
    short_sup_val := short_sup_val[1]
        
    short_sup_val
        
    //Short Condition
    short_cond close short_res_val and Short
    //Resistance Line
    short_res_x1 short_res_index
    short_res_y1 
    Short short_res_val na
    short_res_x2 
    bar_index
    short_res_y2 
    short_res_y1
    short_res_ext 
    extend.right
    short_res_clr 
    color.new(color.red0)
    short_res_textColor color.new(color.white0)
    short_res_sty line.style_dotted
    short_res_width 
    2
    plot
    (Short short_res_val natitle 'Short DnME'color color.new(color.red100))

    //Support Line
    short_sup_x1 short_res_index
    short_sup_y1 
    short_cond short_sup_val na
    short_sup_x2 
    bar_index
    short_sup_y2 
    short_sup_y1
    short_sup_ext 
    extend.right
    short_sup_clr 
    color.new(color.blue0)
    short_sup_textColor color.new(color.white0)
    short_sup_sty line.style_dotted
    short_sup_width 
    2
    plot
    (short_cond short_sup_y1 natitle 'Short Arttr'color color.new(color.blue100))
    //Fib50 Line
    short_fib50_x1 short_res_index
    short_fib50_y1 
    short_cond ? (short_res_y1 short_sup_y1) * 0.5 na
    short_fib50_x2 
    bar_index
    short_fib50_y2 
    short_fib50_y1
    short_fib50_ext 
    extend.right
    short_fib50_clr 
    color.new(color.red0)
    short_fib50_textColor color.new(color.white0)
    short_fib50_sty line.style_dotted
    short_fib50_width 
    2
    plot
    (short_cond short_fib50_y1 natitle 'Short Bala'color color.new(color.red100))
    //Fib618 Line
    short_fib618_x1 short_res_index
    short_fib618_y1 
    short_cond short_sup_y1 + (short_res_y1 short_sup_y1) * 0.618 na
    short_fib618_x2 
    bar_index
    short_fib618_y2 
    short_fib618_y1
    short_fib618_ext 
    extend.right
    short_fib618_clr 
    color.new(color.red0)
    short_fib618_textColor color.new(color.white0)
    short_fib618_sty line.style_dotted
    short_fib618_width 
    2

    short_tp1_x1 
    short_res_index
    short_tp1_y1 
    short_cond short_sup_y1 - (short_res_y1 short_sup_y1) * 0.382 na
    short_tp1_x2 
    bar_index
    short_tp1_y2 
    short_tp1_y1
    short_tp1_ext 
    extend.right
    short_tp1_clr 
    color.new(color.red0)
    short_tp1_textColor color.new(color.white0)
    short_tp1_sty line.style_dotted
    short_tp1_width 
    2
    plot
    (short_cond short_tp1_y1 natitle 'Short Kapat'color color.new(color.red100))
    //tp2
    short_tp2_x1 short_res_index
    short_tp2_y1 
    short_cond short_sup_y1 - (short_res_y1 short_sup_y1) : na
    short_tp2_x2 
    bar_index
    short_tp2_y2 
    short_tp2_y1
    short_tp2_ext 
    extend.right
    short_tp2_clr 
    color.new(color.red0)
    short_tp2_textColor color.new(color.white0)
    short_tp2_sty line.style_dotted
    short_tp2_width 
    2
    plot
    (short_cond short_tp2_y1 natitle 'Short Kesin Kapat'color color.new(color.red100))

    // --------------------------------------------------------------------------------------------------------------------{

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

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

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

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

    sarChange ta.change(out44 High)

    var 
    prevSar out44

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

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

    //plot(sarChange ? na : prevSar, style = plot.style_linebr, offset = -1, color = out44 < high ? color.new(#363a45, 100) : color.new(#363a45, 100), title = 'KRL', linewidth = 1)
    //plot(out44, 'TREND1', style = plot.style_steplinebr, color = color.yellow)
    plot(out44'TREND1'color close out44 color.new(#f8f402, 50) : color.new(#c604f7, 50), style = plot.style_linebr)

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

    start88 input.float(0.'Starting value')
    inc88 input.float(0.01'Increment')
    max88 input.float(0.99'Max Value')
    width input.float(5.00'Zone width')

    atrs ta.atr(100) * width
    sarone 
    ta.sar(start88inc88max88)
    sarzone = if close sarone
        sarone 
    atrs
    else if close sarone
        sarone 
    atrs
    sartwo 
    ta.sar(start88 2inc88 2max88 2)

    p1 plot(sarone'Kanal'color close sarone #2962ff00 : #e91e6200, style = plot.style_circles)
    p3 plot(sarzone'Kanal'color close sarone #2962ff00 : #e91e6200, style = plot.style_circles)
    fill(p1p3color close sarone color.new(#ffffff, 90) : color.new(#e91e63, 100))

    plot(sartwo'TREND2'color close sartwo color.new(#f8f402, 0) : color.new(#c604f7, 0), style = plot.style_linebr) 
    range alan....
    PHP Code:
    //@version=6
    indicator("Trend"shorttitle=".."overlay=falsemax_lines_count=500max_labels_count=500max_boxes_count 500)

    // --- 1. VISUAL SETTINGS --- RANGE ALANINI BELRLEMEK N KULLANILAN KOD.////
    i_boxColor input.color(color.new(#e7e8ec, 95), 'Range Background', group = 'Visuals')
    i_gpBullishColor input.color(color.new(#03f70c, 50), 'Bullish GP Color', group = 'Visuals')
    i_gpBearishColor input.color(color.new(#fa1504, 50), 'Bearish GP Color', group = 'Visuals')
    i_liqColor input.color(color.new(#da04fb, 50), 'Liquidity Zones Color', group = 'Visuals')
    i_lineColor input.color(color.white'Boundary Line Color'group 'Visuals')
    i_whiteText color.white

    // Range Settings
    i_autoFit input.bool(true'Auto-Fit Box to last high and low'group 'Range Settings')
    i_lookback input.int(100'Lookback Period'minval 2group 'Range Settings')
    i_offsetR input.int(10'Box Offset Right'minval 0group 'Range Settings')

    // FVG Settings
    //i_showFVG = input.bool(true, 'Show Fair Value Gaps (FVG)', group = 'FVG Settings')
    //i_fvgLen = input.int(10, 'FVG Extension (Bars)', minval = 1, group = 'FVG Settings')
    //i_bullFVGColor = input.color(color.new(#4caf4f, 100), 'Bullish FVG Color', group = 'FVG Settings')
    //i_bearFVGColor = input.color(color.new(#f44336, 100), 'Bearish FVG Color', group = 'FVG Settings')

    i_showLabels input.bool(true'Show Price Lines & Labels'group 'Visuals')

    // --- 2. CORE CALCULATIONS ---
    int hOff ta.highestbars(highi_lookback)
    int lOff ta.lowestbars(lowi_lookback)

    float rHigh high[-hOff]
    float rLow low[-lOff]
    float rDiff rHigh rLow

    // KORREKTUR: anchorBar nutzt nun die korrekten Identifier lOff und hOff
    int anchorBar i_autoFit bar_index math.min(hOfflOff) : bar_index i_lookback

    float bUp 
    rLow rDiff 0.382
    float bLo 
    rLow rDiff 0.35
    float sUp 
    rHigh rDiff 0.35
    float sLo 
    rHigh rDiff 0.382

    // --- 3. FVG LOGIC ---
    //if i_showFVG
        //if low > high[2]
            //box.new(bar_index[1], low, bar_index + i_fvgLen, high[2], bgcolor = i_bullFVGColor, border_color = na)
        //if high < low[2]
            //box.new(bar_index[1], high, bar_index + i_fvgLen, low[2], bgcolor = i_bearFVGColor, border_color = na)

    // --- 4. VISUALS (BOXES) ---
    var box b_Range box.new(nanananaxloc xloc.bar_indexbgcolor i_boxColorborder_color color.fuchsia)
    var 
    box b_Bullish box.new(nanananaxloc xloc.bar_indexbgcolor i_gpBullishColorborder_color natext ''text_color color.whitetext_size size.small)
    var 
    box b_Bearish box.new(nanananaxloc xloc.bar_indexbgcolor i_gpBearishColorborder_color natext ''text_color color.whitetext_size size.small)
    var 
    box b_LiqTop box.new(nanananaxloc xloc.bar_indexbgcolor i_liqColorborder_color natext ' 'text_color i_whiteTexttext_size size.small)
    var 
    box b_LiqBot box.new(nanananaxloc xloc.bar_indexbgcolor i_liqColorborder_color natext ''text_color i_whiteTexttext_size size.small)

    var array<
    linel_levels = array.new_line()
    var array<
    labellb_prices = array.new_label()

    if 
    barstate.isfirst
        
    for 0 to 7 by 1
            
    array.push(l_levelsline.new(nanananaxloc xloc.bar_indexcolor i_lineColor))
            array.
    push(lb_priceslabel.new(nana''xloc xloc.bar_indexcolor color.new(color.black100), textcolor i_lineColorsize size.normalstyle label.style_label_left))

    if 
    barstate.islast
        int rightBar 
    bar_index i_offsetR
        box
    .set_lefttop(b_RangeanchorBarrHigh)
        
    box.set_rightbottom(b_RangerightBarrLow)
        
    box.set_lefttop(b_BullishanchorBarbUp)
        
    box.set_rightbottom(b_BullishrightBarbLo)
        
    box.set_lefttop(b_BearishanchorBarsUp)
        
    box.set_rightbottom(b_BearishrightBarsLo)
        
    box.set_lefttop(b_LiqTopanchorBarrHigh)
        
    box.set_rightbottom(b_LiqToprightBarrHigh rDiff 0.05)
        
    box.set_lefttop(b_LiqBotanchorBarrLow rDiff 0.05)
        
    box.set_rightbottom(b_LiqBotrightBarrLow)

        if 
    i_showLabels
            
    array<floatp_vals = array.from(rHighrHigh rDiff 0.05sUpsLobUpbLorLow rDiff 0.05rLow)
            for 
    0 to 7 by 1
                float v 
    = array.get(p_valsi)
                
    //line.set_xy1(array.get(l_levels, i), anchorBar, v)
                //line.set_xy2(array.get(l_levels, i), rightBar, v)
                //label.set_xy(array.get(lb_prices, i), rightBar, v)
                //label.set_text(array.get(lb_prices, i), ' ' + str.tostring(v, format.mintick))

    // --- 5. SIGNAL LOGIC ---
    bool sfpShort high rHigh and close rHigh
    bool sfpLong 
    low rLow and close rLow

    var bool tBear false
    var bool tBull false
    if high >= sLo and low <= sUp
        tBear 
    := true
        tBear
    if low <= bUp and high >= bLo
        tBull 
    := true
        tBull

    bool pL 
    close[2] < open[2] and close[1] > open[1] and close high[1]
    bool pS close[2] > open[2] and close[1] < open[1] and close low[1]

    bool signalLongOnly tBull and pL
    bool signalShortOnly 
    tBear and pS

    if signalShortOnly or tBear and high rHigh
        tBear 
    := false
        tBear
    if signalLongOnly or tBull and low rLow
        tBull 
    := false
        tBull

    //BU KODUN SONUDUR./////////////////////
    /////////////////KAMA KULLANARAK BAR RENKLENDRMEDR.////////
    //////////BEYAZ LONG, KIRMIZI LONG KAPA, TURKUAZ SHORT, SARI SHORT KAPA.////////
    // KAMA PARAMETERS
    // ============================================================================
    kama1_length input.int(2'KAMA 1 Length'minval 1group 'KAMA Settings')
    kama1_fast input.int(1'KAMA 1 Fast Length'minval 1group 'KAMA Settings')
    kama1_slow input.int(3'KAMA 1 Slow Length'minval 1group 'KAMA Settings')

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

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

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

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

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

    // ============================================================================
    // TREND COLORING PARAMETERS
    // ============================================================================
    color color_bearish_price_state input.color(color.rgb(224325130), 'Bearish Trend'group 'Colors')
    color color_bullish_price_state input.color(color.rgb(24124724830), 'Bullish Trend'group 'Colors')
    color color_bullish_resistance_state input.color(color.rgb(2433330), 'Bullish Resistance'group 'Colors')
    color color_bearish_support_state input.color(color.rgb(226247230), 'Bearish Support'group 'Colors')

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


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

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

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

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

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

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

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

    var bool was_bullish_stack false
    var bool was_bearish_stack false

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

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


    // ============================================================================
    plotcandle(openhighlowclosecolor kama_ribbon_colorwickcolor kama_ribbon_colorbordercolor kama_ribbon_colortitle 'BAR')
    ////////////////BU KODUN SONUDUR.///////////////
    // BAR BOYUNA GRE SNYAL RETMEDR.///////
    isClosed barstate.isconfirmed

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

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

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

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

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

    if isClosed and close open
        bearWaveLocked 
    := false
        bearWaveLocked

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

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

        
    bullWaveLocked := true
        bullWaveLocked

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

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

        
    bearWaveLocked := true
        bearWaveLocked
    /////////////////////BU KODUN SONUDUR.///////////
    ////////// TREND TAKB N KULLANILAN KOD.////////
    var string vanity_group "Visual Settings"

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

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

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

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

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

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

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

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

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

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

    chosen_style 
    decode_fashion_statement(fashion_choice)

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

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

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

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

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

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

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

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

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

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

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

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

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

    color active_crayon 
    vibes == shrek_mode blood_bath

    plot
    (magic_wand_toggle bagholder_entry na"Trend"color=active_crayonlinewidth=girth_unitsstyle=plot.style_stepline)
    //////////////////////BU KODUN SONUDUR./////////////////// 
    16.07.2024 - 10.12.2024

  5. sar mrtf...
    PHP Code:
    // This Pine Script code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    //  AlgoAlpha

    //@version=6
    indicator(".."overlay truemax_lines_count 500behind_chart false)
    var 
    tb table.new(position.bottom_center11bgcolor #161114)
    if barstate.isfirst 
        table
    .cell(tb00' Yatrm tavsiyesi olarak KULLANILAMAZ.'text_size size.normaltext_color #f4f2ef)

    //////////////////////////////////////////////////
    //@version=6
    start46 input(0.01)
    increment46 input(0.1)
    maximum46 input(0.99"Max Value")
    out55 ta.sar(start46increment46maximum46)
    plot_color close out55 color.rgb(518264) : close out55 color.rgb(16977) : na

    show_header 
    input(falsetitle="Show header?"group='Table Settings')
    dashboard_position input.string("Top center"title="Position"options=["Top right",  "Top center",  "Middle right"], group='Table Settings')
    text_size input.string('Normal'title="Size"options=["Tiny""Small""Normal""Large"], group='Table Settings')
    text_color input.color(color.rgb(1168224), title="Text color"group='Table Settings')
    table_color input.color(color.purpletitle="Border color"group='Table Settings')
    uptrend_indicator "🔵"
    downtrend_indicator "🟠"

    tf11 input.timeframe("1"title="Timeframe 1")
    tf22 input.timeframe("3"title="Timeframe 2")
    tf33 input.timeframe("5"title="Timeframe 3")
    tf4 input.timeframe("10"title="Timeframe 4")
    tf5 input.timeframe("15"title="Timeframe 5")
    tf6 input.timeframe("30"title="Timeframe 6")
    tf7 input.timeframe("60"title="Timeframe 7")
    tf8 input.timeframe("120"title="Timeframe 8")
    tf9 input.timeframe("240"title="Timeframe 9")
    tf10 input.timeframe("D"title="Timeframe 10")


    var 
    table_position dashboard_position == 'Top center' position.middle_left :
      
    dashboard_position == 'Top center' position.middle_right :
      
    dashboard_position == 'Middle right' position.middle_right position.middle_right
      
    var table_text_size text_size == 'Normal' size.normal :
      
    text_size == 'Small' size.small size.normal

    var table.new(position=table_positioncolumns=3rows=20frame_color=#cdcbcb, frame_width=5, border_color=table_color, border_width=1,bgcolor =color.rgb(21, 21, 21) )

    get_trend_status(trend_value) =>
        
    is_uptrend close trend_value
        candle_now 
    is_uptrend uptrend_indicator downtrend_indicator
        candle_now

    //--------------------------------------------------------------------------------------

    sar_1 request.security(syminfo.tickeridtf11ta.sar(start46increment46maximum46))
    sar_2 request.security(syminfo.tickeridtf22ta.sar(start46increment46maximum46))
    sar_3 request.security(syminfo.tickeridtf33ta.sar(start46increment46maximum46))
    sar_4 request.security(syminfo.tickeridtf4ta.sar(start46increment46maximum46))
    sar_5 request.security(syminfo.tickeridtf5ta.sar(start46increment46maximum46))
    sar_6 request.security(syminfo.tickeridtf6ta.sar(start46increment46maximum46))
    sar_7 request.security(syminfo.tickeridtf7ta.sar(start46increment46maximum46))
    sar_8 request.security(syminfo.tickeridtf8ta.sar(start46increment46maximum46))
    sar_9 request.security(syminfo.tickeridtf9ta.sar(start46increment46maximum46))
    sar_10 request.security(syminfo.tickeridtf10ta.sar(start46increment46maximum46))


    trend_indicator_1 get_trend_status(sar_1)
    trend_indicator_2 get_trend_status(sar_2)
    trend_indicator_3 get_trend_status(sar_3)
    trend_indicator_4 get_trend_status(sar_4)
    trend_indicator_5 get_trend_status(sar_5)
    trend_indicator_6 get_trend_status(sar_6)
    trend_indicator_7 get_trend_status(sar_7)
    trend_indicator_8 get_trend_status(sar_8)
    trend_indicator_9 get_trend_status(sar_9)
    trend_indicator_10 get_trend_status(sar_10)

    if 
    tf11 == "60"
        
    tf11 := "1H"
    if tf11 == "120"
        
    tf11 := "2H"
    if tf11 == "180"
        
    tf11 := "3H"
    if tf11 == "240"
        
    tf11 := "4H"

    if tf22 == "60"
        
    tf22 := "1H"
    if tf22 == "120"
        
    tf22 := "2H"
    if tf22 == "180"
        
    tf22 := "3H"
    if tf22 == "240"
        
    tf22 := "4H"

    if tf33 == "60"
        
    tf33 := "1H"
    if tf33 == "120"
        
    tf33 := "2H"
    if tf33 == "180"
        
    tf33 := "3H"
    if tf33 == "240"
        
    tf33 := "4H"

    if tf4 == "60"
        
    tf4 := "1H"
    if tf4 == "120"
        
    tf4 := "2H"
    if tf4 == "180"
        
    tf4 := "3H"
    if tf4 == "240"
        
    tf4 := "4H"

    if tf5 == "60"
        
    tf5 := "1H"
    if tf5 == "120"
        
    tf5 := "2H"
    if tf5 == "180"
        
    tf5 := "3H"
    if tf5 == "240"
        
    tf5 := "4H"

    if tf6 == "60"
        
    tf6 := "1H"
    if tf6 == "120"
        
    tf6 := "2H"
    if tf6 == "180"
        
    tf6 := "3H"
    if tf6 == "240"
        
    tf6 := "4H"

    if tf7 == "60"
        
    tf7 := "1H"
    if tf7 == "120"
        
    tf7 := "2H"
    if tf7 == "180"
        
    tf7 := "3H"
    if tf7 == "240"
        
    tf7 := "4H"

    if tf8 == "60"
        
    tf8 := "1H"
    if tf8 == "120"
        
    tf8 := "2H"
    if tf8 == "180"
        
    tf8 := "3H"
    if tf8 == "240"
        
    tf8 := "4H"

    if tf9 == "60"
        
    tf9 := "1H"
    if tf9 == "120"
        
    tf9 := "2H"
    if tf9 == "180"
        
    tf9 := "3H"
    if tf9 == "240"
        
    tf9 := "4H"

    if tf10 == "60"
        
    tf10 := "1H"
    if tf10 == "120"
        
    tf10 := "2H"
    if tf10 == "180"
        
    tf10 := "3H"
    if tf10 == "240"
        
    tf10 := "4H"


    //---------------------------------------------------------------------------------------------
    // Update table with trend data
    //---------------------------------------------------------------------------------------------
    if (barstate.islast)
       
        
    table.cell(t01tf11text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))
        
    table.cell(t11text="●"text_color=trend_indicator_1==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t21str.tostring(sar_1"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t02tf22text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))
        
    table.cell(t12text="●"text_color=trend_indicator_2==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t22str.tostring(sar_2"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))
        
        
    table.cell(t03tf33text_color=color.whitetext_size=table_text_size,bgcolorcolor.rgb(212121))
        
    table.cell(t13text="●"text_color=trend_indicator_3==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t23str.tostring(sar_3"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t04tf4text_color=color.whitetext_size=table_text_sizebgcolor color.rgb(212121))
        
    table.cell(t14text="●"text_color=trend_indicator_4==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t24str.tostring(sar_4"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t05tf5text_color=color.whitetext_size=table_text_sizebgcolor color.rgb(212121))
        
    table.cell(t15text="●"text_color=trend_indicator_5==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t25str.tostring(sar_5"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t06tf6text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))
        
    table.cell(t16text="●"text_color=trend_indicator_6==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t26str.tostring(sar_6"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t07tf7text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))
        
    table.cell(t17text="●"text_color=trend_indicator_7==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t27str.tostring(sar_7"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t08tf8text_color=color.whitetext_size=table_text_size,bgcolor =  color.rgb(212121))
        
    table.cell(t18text="●"text_color=trend_indicator_8==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t28str.tostring(sar_8"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t09tf9text_color=color.whitetext_size=table_text_size,bgcolor =  color.rgb(212121))
        
    table.cell(t19text="●"text_color=trend_indicator_9==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t29str.tostring(sar_9"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t010tf10text_color=color.whitetext_size=table_text_size,bgcolor =  color.rgb(212121))
        
    table.cell(t110text="●"text_color=trend_indicator_10==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t210str.tostring(sar_10"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

     
    table.cell(t,0,0,"Periyot",text_color color.white,bgcolor color.rgb(212121))
    table.cell(t,1,0,"Trend",text_color color.white,bgcolor color.rgb(212121))
    table.cell(t,2,0,"Fiyat",text_color color.white,bgcolor color.rgb(212121))

    lookback input.int(5"Line Lookback Period"minval=1)

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



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

    source      input.source(close'Source')
    length      input.int(100'Period'1)
    displayExt  input.bool(true""inline "ext")
    extrapolate input.int(1'Extrapolate'0inline "ext")
    degree      input.int(1'Degree'1)
    colorUp     input.color(color.rgb(25523559100), ""inline "col")
    colorDn     input.color(color.rgb(22364251100), ""inline "col")


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

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

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

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

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

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

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


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

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

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

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

            for [
    indexpredictionin predictions

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

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

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

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

            
        
    lastPred


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

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


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

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

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

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

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

    sarChange ta.change(out44 High)

    var 
    prevSar out44

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

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

    plot(sarChange na prevSarstyle plot.style_linebroffset = -1color out44 high color.new(#363a45, 100) : color.new(#363a45, 100), title = 'KRL', linewidth = 1)
    plot(out44'SRZ'style plot.style_steplinebrcolor color.yellow)
    ///////////////////////

    start88 input.float(0.'Starting value')
    inc88 input.float(0.01'Increment')
    max88 input.float(0.09'Max Value')
    width input.float(5.00'Zone width')

    atrs ta.atr(100) * width
    sarone 
    ta.sar(start88inc88max88)
    sarzone = if close sarone
        sarone 
    atrs
    else if close sarone
        sarone 
    atrs
    sartwo 
    ta.sar(start88 2inc88 2max88 2)

    p1 plot(sarone'Kanal'color close sarone #2962ff00 : #e91e6200, style = plot.style_circles)
    p3 plot(sarzone'Kanal'color close sarone #2962ff00 : #e91e6200, style = plot.style_circles)
    fill(p1p3color close sarone color.new(#2962ff, 80) : color.new(#e91e63, 80))

    //plot(sartwo, 'Second SAR', color = close > sartwo ? color.new(#2962ff, 50) : color.new(#e91e63, 50), style = plot.style_linebr)

    /////////////
    // 2. PSAR (Orta Yaknlk)
    start2 0.01 // steiniz zerine SIFIR
    inc2 input.float(0.1title '2. Art (Orta)'step 0.01group '2. Orta PSAR')
    max2 input.float(0.99title '2. Limit'step 0.05group '2. Orta PSAR')
    // 3. PSAR (Nispeten Daha Uzak ama Standarttan Yakn)
    start3 0. // steiniz zerine SIFIR
    inc3 input.float(0.1title '3. Art (Uzak)'step 0.01group '3. Uzak PSAR')
    max3 input.float(0.99title '3. Limit'step 0.05group '3. Uzak PSAR')
    psar2 ta.sar(start2inc2max2)
    psar3 ta.sar(start3inc3max3)
    // Define colors for bullish and bearish conditions
    GreenFluorescent color.rgb(02550)
    RedFluorescent color.rgb(25500)
    plot(psar2,"SRX"style plot.style_steplinelinewidth 1color close psar2 GreenFluorescent close psar2 RedFluorescent na)
    plot(psar3,"SRY"style plot.style_steplinelinewidth 1color close psar3 GreenFluorescent close psar3 RedFluorescent na)
    ///////////////////////////FBO LE SUPERTREND HESAPLAMASIDIR./////

    bool  trend_on input.bool(true""inline "trend"group "Trend")
    float trend_   input.float(5"Trend"step 0.01inline "trend"group "Trend")
    color col1     input.color(color.rgb(2352476), ""inline "trend"group "Trend")
    color col2     input.color(#dc05f400, "",inline = "trend", group = "Trend")

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

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

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

        label H 
    na
        label L 
    na

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


    var fib_d =  data.new()

    [
    supertrenddirection] = ta.supertrend(trend_25)

    draw_fibb(trend)=>

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

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

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


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


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

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

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


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


            
    //

            
    if trend == -1

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

            if 
    trend == 

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

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

    draw_fibb(direction)

    color trend_on ? (direction == col2 col1) : na
    p19 
    plot(supertrend"Fibo-Trend"color direction != direction[1] ? na colorstyle plot.style_linebrlinewidth 2)

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

    // --- 1. VISUAL SETTINGS --- RANGE ALANINI BELRLEMEK N KULLANILAN KOD.////
    i_boxColor input.color(color.new(#e7e8ec, 95), 'Range Background', group = 'Visuals')
    i_gpBullishColor input.color(color.new(#03f70c, 50), 'Bullish GP Color', group = 'Visuals')
    i_gpBearishColor input.color(color.new(#fa1504, 50), 'Bearish GP Color', group = 'Visuals')
    i_liqColor input.color(color.new(#da04fb, 50), 'Liquidity Zones Color', group = 'Visuals')
    i_lineColor input.color(color.white'Boundary Line Color'group 'Visuals')
    i_whiteText color.white

    // Range Settings
    i_autoFit input.bool(true'Auto-Fit Box to last high and low'group 'Range Settings')
    i_lookback input.int(100'Lookback Period'minval 2group 'Range Settings')
    i_offsetR input.int(10'Box Offset Right'minval 0group 'Range Settings')

    // FVG Settings
    //i_showFVG = input.bool(true, 'Show Fair Value Gaps (FVG)', group = 'FVG Settings')
    //i_fvgLen = input.int(10, 'FVG Extension (Bars)', minval = 1, group = 'FVG Settings')
    //i_bullFVGColor = input.color(color.new(#4caf4f, 100), 'Bullish FVG Color', group = 'FVG Settings')
    //i_bearFVGColor = input.color(color.new(#f44336, 100), 'Bearish FVG Color', group = 'FVG Settings')

    i_showLabels input.bool(true'Show Price Lines & Labels'group 'Visuals')

    // --- 2. CORE CALCULATIONS ---
    int hOff ta.highestbars(highi_lookback)
    int lOff ta.lowestbars(lowi_lookback)

    float rHigh high[-hOff]
    float rLow low[-lOff]
    float rDiff rHigh rLow

    // KORREKTUR: anchorBar nutzt nun die korrekten Identifier lOff und hOff
    int anchorBar i_autoFit bar_index math.min(hOfflOff) : bar_index i_lookback

    float bUp 
    rLow rDiff 0.382
    float bLo 
    rLow rDiff 0.35
    float sUp 
    rHigh rDiff 0.35
    float sLo 
    rHigh rDiff 0.382

    // --- 3. FVG LOGIC ---
    //if i_showFVG
        //if low > high[2]
            //box.new(bar_index[1], low, bar_index + i_fvgLen, high[2], bgcolor = i_bullFVGColor, border_color = na)
        //if high < low[2]
            //box.new(bar_index[1], high, bar_index + i_fvgLen, low[2], bgcolor = i_bearFVGColor, border_color = na)

    // --- 4. VISUALS (BOXES) ---
    var box b_Range box.new(nanananaxloc xloc.bar_indexbgcolor i_boxColorborder_color color.fuchsia)
    var 
    box b_Bullish box.new(nanananaxloc xloc.bar_indexbgcolor i_gpBullishColorborder_color natext ''text_color color.whitetext_size size.small)
    var 
    box b_Bearish box.new(nanananaxloc xloc.bar_indexbgcolor i_gpBearishColorborder_color natext ''text_color color.whitetext_size size.small)
    var 
    box b_LiqTop box.new(nanananaxloc xloc.bar_indexbgcolor i_liqColorborder_color natext ' 'text_color i_whiteTexttext_size size.small)
    var 
    box b_LiqBot box.new(nanananaxloc xloc.bar_indexbgcolor i_liqColorborder_color natext ''text_color i_whiteTexttext_size size.small)

    var array<
    linel_levels = array.new_line()
    var array<
    labellb_prices = array.new_label()

    if 
    barstate.isfirst
        
    for 0 to 7 by 1
            
    array.push(l_levelsline.new(nanananaxloc xloc.bar_indexcolor i_lineColor))
            array.
    push(lb_priceslabel.new(nana''xloc xloc.bar_indexcolor color.new(color.black100), textcolor i_lineColorsize size.normalstyle label.style_label_left))

    if 
    barstate.islast
        int rightBar 
    bar_index i_offsetR
        box
    .set_lefttop(b_RangeanchorBarrHigh)
        
    box.set_rightbottom(b_RangerightBarrLow)
        
    box.set_lefttop(b_BullishanchorBarbUp)
        
    box.set_rightbottom(b_BullishrightBarbLo)
        
    box.set_lefttop(b_BearishanchorBarsUp)
        
    box.set_rightbottom(b_BearishrightBarsLo)
        
    box.set_lefttop(b_LiqTopanchorBarrHigh)
        
    box.set_rightbottom(b_LiqToprightBarrHigh rDiff 0.05)
        
    box.set_lefttop(b_LiqBotanchorBarrLow rDiff 0.05)
        
    box.set_rightbottom(b_LiqBotrightBarrLow)

        if 
    i_showLabels
            
    array<floatp_vals = array.from(rHighrHigh rDiff 0.05sUpsLobUpbLorLow rDiff 0.05rLow)
            for 
    0 to 7 by 1
                float v 
    = array.get(p_valsi)
                
    //line.set_xy1(array.get(l_levels, i), anchorBar, v)
                //line.set_xy2(array.get(l_levels, i), rightBar, v)
                //label.set_xy(array.get(lb_prices, i), rightBar, v)
                //label.set_text(array.get(lb_prices, i), ' ' + str.tostring(v, format.mintick))

    // --- 5. SIGNAL LOGIC ---
    bool sfpShort high rHigh and close rHigh
    bool sfpLong 
    low rLow and close rLow

    var bool tBear false
    var bool tBull false
    if high >= sLo and low <= sUp
        tBear 
    := true
        tBear
    if low <= bUp and high >= bLo
        tBull 
    := true
        tBull

    bool pL 
    close[2] < open[2] and close[1] > open[1] and close high[1]
    bool pS close[2] > open[2] and close[1] < open[1] and close low[1]

    bool signalLongOnly tBull and pL
    bool signalShortOnly 
    tBear and pS

    if signalShortOnly or tBear and high rHigh
        tBear 
    := false
        tBear
    if signalLongOnly or tBull and low rLow
        tBull 
    := false
        tBull

    //BU KODUN SONUDUR./////////////////////
    /////////////////KAMA KULLANARAK BAR RENKLENDRMEDR.////////
    //////////BEYAZ LONG, KIRMIZI LONG KAPA, TURKUAZ SHORT, SARI SHORT KAPA.////////
    // KAMA PARAMETERS
    // ============================================================================
    kama1_length input.int(2'KAMA 1 Length'minval 1group 'KAMA Settings')
    kama1_fast input.int(1'KAMA 1 Fast Length'minval 1group 'KAMA Settings')
    kama1_slow input.int(3'KAMA 1 Slow Length'minval 1group 'KAMA Settings')

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

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

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

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

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

    // ============================================================================
    // TREND COLORING PARAMETERS
    // ============================================================================
    color color_bearish_price_state input.color(color.rgb(224325130), 'Bearish Trend'group 'Colors')
    color color_bullish_price_state input.color(color.rgb(24124724830), 'Bullish Trend'group 'Colors')
    color color_bullish_resistance_state input.color(color.rgb(2433330), 'Bullish Resistance'group 'Colors')
    color color_bearish_support_state input.color(color.rgb(226247230), 'Bearish Support'group 'Colors')

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


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

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

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

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

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

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

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

    var bool was_bullish_stack false
    var bool was_bearish_stack false

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

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


    // ============================================================================
    plotcandle(openhighlowclosecolor kama_ribbon_colorwickcolor kama_ribbon_colorbordercolor kama_ribbon_colortitle 'BAR')
    ////////////////BU KODUN SONUDUR.///////////////
    // BAR BOYUNA GRE SNYAL RETMEDR.///////
    isClosed barstate.isconfirmed

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

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

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

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

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

    if isClosed and close open
        bearWaveLocked 
    := false
        bearWaveLocked

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

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

        
    bullWaveLocked := true
        bullWaveLocked

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

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

        
    bearWaveLocked := true
        bearWaveLocked
    /////////////////////BU KODUN SONUDUR.///////////
    ////////// TREND TAKB N KULLANILAN KOD.////////
    var string vanity_group "Visual Settings"

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

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

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

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

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

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

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

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

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

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

    chosen_style 
    decode_fashion_statement(fashion_choice)

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

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

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

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

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

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

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

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

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

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

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

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

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

    color active_crayon 
    vibes == shrek_mode blood_bath

    plot
    (magic_wand_toggle bagholder_entry na"Trend"color=active_crayonlinewidth=girth_unitsstyle=plot.style_stepline)
    //////////////////////BU KODUN SONUDUR./////////////////// 
    16.07.2024 - 10.12.2024

  6.  Alnt Originally Posted by @yrk@ Yazy Oku
    sar mrtf...
    PHP Code:
    // This Pine Script code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    //  AlgoAlpha

    //@version=6
    indicator(".."overlay truemax_lines_count 500behind_chart false)
    var 
    tb table.new(position.bottom_center11bgcolor #161114)
    if barstate.isfirst 
        table
    .cell(tb00' Yatrm tavsiyesi olarak KULLANILAMAZ.'text_size size.normaltext_color #f4f2ef)

    //////////////////////////////////////////////////
    //@version=6
    start46 input(0.01)
    increment46 input(0.1)
    maximum46 input(0.99"Max Value")
    out55 ta.sar(start46increment46maximum46)
    plot_color close out55 color.rgb(518264) : close out55 color.rgb(16977) : na

    show_header 
    input(falsetitle="Show header?"group='Table Settings')
    dashboard_position input.string("Top center"title="Position"options=["Top right",  "Top center",  "Middle right"], group='Table Settings')
    text_size input.string('Normal'title="Size"options=["Tiny""Small""Normal""Large"], group='Table Settings')
    text_color input.color(color.rgb(1168224), title="Text color"group='Table Settings')
    table_color input.color(color.purpletitle="Border color"group='Table Settings')
    uptrend_indicator "🔵"
    downtrend_indicator "🟠"

    tf11 input.timeframe("1"title="Timeframe 1")
    tf22 input.timeframe("3"title="Timeframe 2")
    tf33 input.timeframe("5"title="Timeframe 3")
    tf4 input.timeframe("10"title="Timeframe 4")
    tf5 input.timeframe("15"title="Timeframe 5")
    tf6 input.timeframe("30"title="Timeframe 6")
    tf7 input.timeframe("60"title="Timeframe 7")
    tf8 input.timeframe("120"title="Timeframe 8")
    tf9 input.timeframe("240"title="Timeframe 9")
    tf10 input.timeframe("D"title="Timeframe 10")


    var 
    table_position dashboard_position == 'Top center' position.middle_left :
      
    dashboard_position == 'Top center' position.middle_right :
      
    dashboard_position == 'Middle right' position.middle_right position.middle_right
      
    var table_text_size text_size == 'Normal' size.normal :
      
    text_size == 'Small' size.small size.normal

    var table.new(position=table_positioncolumns=3rows=20frame_color=#cdcbcb, frame_width=5, border_color=table_color, border_width=1,bgcolor =color.rgb(21, 21, 21) )

    get_trend_status(trend_value) =>
        
    is_uptrend close trend_value
        candle_now 
    is_uptrend uptrend_indicator downtrend_indicator
        candle_now

    //--------------------------------------------------------------------------------------

    sar_1 request.security(syminfo.tickeridtf11ta.sar(start46increment46maximum46))
    sar_2 request.security(syminfo.tickeridtf22ta.sar(start46increment46maximum46))
    sar_3 request.security(syminfo.tickeridtf33ta.sar(start46increment46maximum46))
    sar_4 request.security(syminfo.tickeridtf4ta.sar(start46increment46maximum46))
    sar_5 request.security(syminfo.tickeridtf5ta.sar(start46increment46maximum46))
    sar_6 request.security(syminfo.tickeridtf6ta.sar(start46increment46maximum46))
    sar_7 request.security(syminfo.tickeridtf7ta.sar(start46increment46maximum46))
    sar_8 request.security(syminfo.tickeridtf8ta.sar(start46increment46maximum46))
    sar_9 request.security(syminfo.tickeridtf9ta.sar(start46increment46maximum46))
    sar_10 request.security(syminfo.tickeridtf10ta.sar(start46increment46maximum46))


    trend_indicator_1 get_trend_status(sar_1)
    trend_indicator_2 get_trend_status(sar_2)
    trend_indicator_3 get_trend_status(sar_3)
    trend_indicator_4 get_trend_status(sar_4)
    trend_indicator_5 get_trend_status(sar_5)
    trend_indicator_6 get_trend_status(sar_6)
    trend_indicator_7 get_trend_status(sar_7)
    trend_indicator_8 get_trend_status(sar_8)
    trend_indicator_9 get_trend_status(sar_9)
    trend_indicator_10 get_trend_status(sar_10)

    if 
    tf11 == "60"
        
    tf11 := "1H"
    if tf11 == "120"
        
    tf11 := "2H"
    if tf11 == "180"
        
    tf11 := "3H"
    if tf11 == "240"
        
    tf11 := "4H"

    if tf22 == "60"
        
    tf22 := "1H"
    if tf22 == "120"
        
    tf22 := "2H"
    if tf22 == "180"
        
    tf22 := "3H"
    if tf22 == "240"
        
    tf22 := "4H"

    if tf33 == "60"
        
    tf33 := "1H"
    if tf33 == "120"
        
    tf33 := "2H"
    if tf33 == "180"
        
    tf33 := "3H"
    if tf33 == "240"
        
    tf33 := "4H"

    if tf4 == "60"
        
    tf4 := "1H"
    if tf4 == "120"
        
    tf4 := "2H"
    if tf4 == "180"
        
    tf4 := "3H"
    if tf4 == "240"
        
    tf4 := "4H"

    if tf5 == "60"
        
    tf5 := "1H"
    if tf5 == "120"
        
    tf5 := "2H"
    if tf5 == "180"
        
    tf5 := "3H"
    if tf5 == "240"
        
    tf5 := "4H"

    if tf6 == "60"
        
    tf6 := "1H"
    if tf6 == "120"
        
    tf6 := "2H"
    if tf6 == "180"
        
    tf6 := "3H"
    if tf6 == "240"
        
    tf6 := "4H"

    if tf7 == "60"
        
    tf7 := "1H"
    if tf7 == "120"
        
    tf7 := "2H"
    if tf7 == "180"
        
    tf7 := "3H"
    if tf7 == "240"
        
    tf7 := "4H"

    if tf8 == "60"
        
    tf8 := "1H"
    if tf8 == "120"
        
    tf8 := "2H"
    if tf8 == "180"
        
    tf8 := "3H"
    if tf8 == "240"
        
    tf8 := "4H"

    if tf9 == "60"
        
    tf9 := "1H"
    if tf9 == "120"
        
    tf9 := "2H"
    if tf9 == "180"
        
    tf9 := "3H"
    if tf9 == "240"
        
    tf9 := "4H"

    if tf10 == "60"
        
    tf10 := "1H"
    if tf10 == "120"
        
    tf10 := "2H"
    if tf10 == "180"
        
    tf10 := "3H"
    if tf10 == "240"
        
    tf10 := "4H"


    //---------------------------------------------------------------------------------------------
    // Update table with trend data
    //---------------------------------------------------------------------------------------------
    if (barstate.islast)
       
        
    table.cell(t01tf11text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))
        
    table.cell(t11text="●"text_color=trend_indicator_1==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t21str.tostring(sar_1"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t02tf22text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))
        
    table.cell(t12text="●"text_color=trend_indicator_2==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t22str.tostring(sar_2"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))
        
        
    table.cell(t03tf33text_color=color.whitetext_size=table_text_size,bgcolorcolor.rgb(212121))
        
    table.cell(t13text="●"text_color=trend_indicator_3==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t23str.tostring(sar_3"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t04tf4text_color=color.whitetext_size=table_text_sizebgcolor color.rgb(212121))
        
    table.cell(t14text="●"text_color=trend_indicator_4==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t24str.tostring(sar_4"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t05tf5text_color=color.whitetext_size=table_text_sizebgcolor color.rgb(212121))
        
    table.cell(t15text="●"text_color=trend_indicator_5==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t25str.tostring(sar_5"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t06tf6text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))
        
    table.cell(t16text="●"text_color=trend_indicator_6==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t26str.tostring(sar_6"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t07tf7text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))
        
    table.cell(t17text="●"text_color=trend_indicator_7==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t27str.tostring(sar_7"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t08tf8text_color=color.whitetext_size=table_text_size,bgcolor =  color.rgb(212121))
        
    table.cell(t18text="●"text_color=trend_indicator_8==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t28str.tostring(sar_8"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t09tf9text_color=color.whitetext_size=table_text_size,bgcolor =  color.rgb(212121))
        
    table.cell(t19text="●"text_color=trend_indicator_9==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t29str.tostring(sar_9"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

        
    table.cell(t010tf10text_color=color.whitetext_size=table_text_size,bgcolor =  color.rgb(212121))
        
    table.cell(t110text="●"text_color=trend_indicator_10==uptrend_indicator?color.lime:color.red,text_size size.large)
        
    table.cell(t210str.tostring(sar_10"#.##"), text_color=color.whitetext_size=table_text_size,bgcolor color.rgb(212121))

     
    table.cell(t,0,0,"Periyot",text_color color.white,bgcolor color.rgb(212121))
    table.cell(t,1,0,"Trend",text_color color.white,bgcolor color.rgb(212121))
    table.cell(t,2,0,"Fiyat",text_color color.white,bgcolor color.rgb(212121))

    lookback input.int(5"Line Lookback Period"minval=1)

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



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

    source      input.source(close'Source')
    length      input.int(100'Period'1)
    displayExt  input.bool(true""inline "ext")
    extrapolate input.int(1'Extrapolate'0inline "ext")
    degree      input.int(1'Degree'1)
    colorUp     input.color(color.rgb(25523559100), ""inline "col")
    colorDn     input.color(color.rgb(22364251100), ""inline "col")


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

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

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

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

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

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

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


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

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

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

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

            for [
    indexpredictionin predictions

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

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

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

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

            
        
    lastPred


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

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


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

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

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

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

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

    sarChange ta.change(out44 High)

    var 
    prevSar out44

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

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

    plot(sarChange na prevSarstyle plot.style_linebroffset = -1color out44 high color.new(#363a45, 100) : color.new(#363a45, 100), title = 'KRL', linewidth = 1)
    plot(out44'SRZ'style plot.style_steplinebrcolor color.yellow)
    ///////////////////////

    start88 input.float(0.'Starting value')
    inc88 input.float(0.01'Increment')
    max88 input.float(0.09'Max Value')
    width input.float(5.00'Zone width')

    atrs ta.atr(100) * width
    sarone 
    ta.sar(start88inc88max88)
    sarzone = if close sarone
        sarone 
    atrs
    else if close sarone
        sarone 
    atrs
    sartwo 
    ta.sar(start88 2inc88 2max88 2)

    p1 plot(sarone'Kanal'color close sarone #2962ff00 : #e91e6200, style = plot.style_circles)
    p3 plot(sarzone'Kanal'color close sarone #2962ff00 : #e91e6200, style = plot.style_circles)
    fill(p1p3color close sarone color.new(#2962ff, 80) : color.new(#e91e63, 80))

    //plot(sartwo, 'Second SAR', color = close > sartwo ? color.new(#2962ff, 50) : color.new(#e91e63, 50), style = plot.style_linebr)

    /////////////
    // 2. PSAR (Orta Yaknlk)
    start2 0.01 // steiniz zerine SIFIR
    inc2 input.float(0.1title '2. Art (Orta)'step 0.01group '2. Orta PSAR')
    max2 input.float(0.99title '2. Limit'step 0.05group '2. Orta PSAR')
    // 3. PSAR (Nispeten Daha Uzak ama Standarttan Yakn)
    start3 0. // steiniz zerine SIFIR
    inc3 input.float(0.1title '3. Art (Uzak)'step 0.01group '3. Uzak PSAR')
    max3 input.float(0.99title '3. Limit'step 0.05group '3. Uzak PSAR')
    psar2 ta.sar(start2inc2max2)
    psar3 ta.sar(start3inc3max3)
    // Define colors for bullish and bearish conditions
    GreenFluorescent color.rgb(02550)
    RedFluorescent color.rgb(25500)
    plot(psar2,"SRX"style plot.style_steplinelinewidth 1color close psar2 GreenFluorescent close psar2 RedFluorescent na)
    plot(psar3,"SRY"style plot.style_steplinelinewidth 1color close psar3 GreenFluorescent close psar3 RedFluorescent na)
    ///////////////////////////FBO LE SUPERTREND HESAPLAMASIDIR./////

    bool  trend_on input.bool(true""inline "trend"group "Trend")
    float trend_   input.float(5"Trend"step 0.01inline "trend"group "Trend")
    color col1     input.color(color.rgb(2352476), ""inline "trend"group "Trend")
    color col2     input.color(#dc05f400, "",inline = "trend", group = "Trend")

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

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

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

        label H 
    na
        label L 
    na

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


    var fib_d =  data.new()

    [
    supertrenddirection] = ta.supertrend(trend_25)

    draw_fibb(trend)=>

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

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

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


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


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

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

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


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


            
    //

            
    if trend == -1

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

            if 
    trend == 

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

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

    draw_fibb(direction)

    color trend_on ? (direction == col2 col1) : na
    p19 
    plot(supertrend"Fibo-Trend"color direction != direction[1] ? na colorstyle plot.style_linebrlinewidth 2)

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

    // --- 1. VISUAL SETTINGS --- RANGE ALANINI BELRLEMEK N KULLANILAN KOD.////
    i_boxColor input.color(color.new(#e7e8ec, 95), 'Range Background', group = 'Visuals')
    i_gpBullishColor input.color(color.new(#03f70c, 50), 'Bullish GP Color', group = 'Visuals')
    i_gpBearishColor input.color(color.new(#fa1504, 50), 'Bearish GP Color', group = 'Visuals')
    i_liqColor input.color(color.new(#da04fb, 50), 'Liquidity Zones Color', group = 'Visuals')
    i_lineColor input.color(color.white'Boundary Line Color'group 'Visuals')
    i_whiteText color.white

    // Range Settings
    i_autoFit input.bool(true'Auto-Fit Box to last high and low'group 'Range Settings')
    i_lookback input.int(100'Lookback Period'minval 2group 'Range Settings')
    i_offsetR input.int(10'Box Offset Right'minval 0group 'Range Settings')

    // FVG Settings
    //i_showFVG = input.bool(true, 'Show Fair Value Gaps (FVG)', group = 'FVG Settings')
    //i_fvgLen = input.int(10, 'FVG Extension (Bars)', minval = 1, group = 'FVG Settings')
    //i_bullFVGColor = input.color(color.new(#4caf4f, 100), 'Bullish FVG Color', group = 'FVG Settings')
    //i_bearFVGColor = input.color(color.new(#f44336, 100), 'Bearish FVG Color', group = 'FVG Settings')

    i_showLabels input.bool(true'Show Price Lines & Labels'group 'Visuals')

    // --- 2. CORE CALCULATIONS ---
    int hOff ta.highestbars(highi_lookback)
    int lOff ta.lowestbars(lowi_lookback)

    float rHigh high[-hOff]
    float rLow low[-lOff]
    float rDiff rHigh rLow

    // KORREKTUR: anchorBar nutzt nun die korrekten Identifier lOff und hOff
    int anchorBar i_autoFit bar_index math.min(hOfflOff) : bar_index i_lookback

    float bUp 
    rLow rDiff 0.382
    float bLo 
    rLow rDiff 0.35
    float sUp 
    rHigh rDiff 0.35
    float sLo 
    rHigh rDiff 0.382

    // --- 3. FVG LOGIC ---
    //if i_showFVG
        //if low > high[2]
            //box.new(bar_index[1], low, bar_index + i_fvgLen, high[2], bgcolor = i_bullFVGColor, border_color = na)
        //if high < low[2]
            //box.new(bar_index[1], high, bar_index + i_fvgLen, low[2], bgcolor = i_bearFVGColor, border_color = na)

    // --- 4. VISUALS (BOXES) ---
    var box b_Range box.new(nanananaxloc xloc.bar_indexbgcolor i_boxColorborder_color color.fuchsia)
    var 
    box b_Bullish box.new(nanananaxloc xloc.bar_indexbgcolor i_gpBullishColorborder_color natext ''text_color color.whitetext_size size.small)
    var 
    box b_Bearish box.new(nanananaxloc xloc.bar_indexbgcolor i_gpBearishColorborder_color natext ''text_color color.whitetext_size size.small)
    var 
    box b_LiqTop box.new(nanananaxloc xloc.bar_indexbgcolor i_liqColorborder_color natext ' 'text_color i_whiteTexttext_size size.small)
    var 
    box b_LiqBot box.new(nanananaxloc xloc.bar_indexbgcolor i_liqColorborder_color natext ''text_color i_whiteTexttext_size size.small)

    var array<
    linel_levels = array.new_line()
    var array<
    labellb_prices = array.new_label()

    if 
    barstate.isfirst
        
    for 0 to 7 by 1
            
    array.push(l_levelsline.new(nanananaxloc xloc.bar_indexcolor i_lineColor))
            array.
    push(lb_priceslabel.new(nana''xloc xloc.bar_indexcolor color.new(color.black100), textcolor i_lineColorsize size.normalstyle label.style_label_left))

    if 
    barstate.islast
        int rightBar 
    bar_index i_offsetR
        box
    .set_lefttop(b_RangeanchorBarrHigh)
        
    box.set_rightbottom(b_RangerightBarrLow)
        
    box.set_lefttop(b_BullishanchorBarbUp)
        
    box.set_rightbottom(b_BullishrightBarbLo)
        
    box.set_lefttop(b_BearishanchorBarsUp)
        
    box.set_rightbottom(b_BearishrightBarsLo)
        
    box.set_lefttop(b_LiqTopanchorBarrHigh)
        
    box.set_rightbottom(b_LiqToprightBarrHigh rDiff 0.05)
        
    box.set_lefttop(b_LiqBotanchorBarrLow rDiff 0.05)
        
    box.set_rightbottom(b_LiqBotrightBarrLow)

        if 
    i_showLabels
            
    array<floatp_vals = array.from(rHighrHigh rDiff 0.05sUpsLobUpbLorLow rDiff 0.05rLow)
            for 
    0 to 7 by 1
                float v 
    = array.get(p_valsi)
                
    //line.set_xy1(array.get(l_levels, i), anchorBar, v)
                //line.set_xy2(array.get(l_levels, i), rightBar, v)
                //label.set_xy(array.get(lb_prices, i), rightBar, v)
                //label.set_text(array.get(lb_prices, i), ' ' + str.tostring(v, format.mintick))

    // --- 5. SIGNAL LOGIC ---
    bool sfpShort high rHigh and close rHigh
    bool sfpLong 
    low rLow and close rLow

    var bool tBear false
    var bool tBull false
    if high >= sLo and low <= sUp
        tBear 
    := true
        tBear
    if low <= bUp and high >= bLo
        tBull 
    := true
        tBull

    bool pL 
    close[2] < open[2] and close[1] > open[1] and close high[1]
    bool pS close[2] > open[2] and close[1] < open[1] and close low[1]

    bool signalLongOnly tBull and pL
    bool signalShortOnly 
    tBear and pS

    if signalShortOnly or tBear and high rHigh
        tBear 
    := false
        tBear
    if signalLongOnly or tBull and low rLow
        tBull 
    := false
        tBull

    //BU KODUN SONUDUR./////////////////////
    /////////////////KAMA KULLANARAK BAR RENKLENDRMEDR.////////
    //////////BEYAZ LONG, KIRMIZI LONG KAPA, TURKUAZ SHORT, SARI SHORT KAPA.////////
    // KAMA PARAMETERS
    // ============================================================================
    kama1_length input.int(2'KAMA 1 Length'minval 1group 'KAMA Settings')
    kama1_fast input.int(1'KAMA 1 Fast Length'minval 1group 'KAMA Settings')
    kama1_slow input.int(3'KAMA 1 Slow Length'minval 1group 'KAMA Settings')

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

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

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

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

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

    // ============================================================================
    // TREND COLORING PARAMETERS
    // ============================================================================
    color color_bearish_price_state input.color(color.rgb(224325130), 'Bearish Trend'group 'Colors')
    color color_bullish_price_state input.color(color.rgb(24124724830), 'Bullish Trend'group 'Colors')
    color color_bullish_resistance_state input.color(color.rgb(2433330), 'Bullish Resistance'group 'Colors')
    color color_bearish_support_state input.color(color.rgb(226247230), 'Bearish Support'group 'Colors')

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


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

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

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

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

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

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

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

    var bool was_bullish_stack false
    var bool was_bearish_stack false

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

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


    // ============================================================================
    plotcandle(openhighlowclosecolor kama_ribbon_colorwickcolor kama_ribbon_colorbordercolor kama_ribbon_colortitle 'BAR')
    ////////////////BU KODUN SONUDUR.///////////////
    // BAR BOYUNA GRE SNYAL RETMEDR.///////
    isClosed barstate.isconfirmed

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

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

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

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

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

    if isClosed and close open
        bearWaveLocked 
    := false
        bearWaveLocked

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

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

        
    bullWaveLocked := true
        bullWaveLocked

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

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

        
    bearWaveLocked := true
        bearWaveLocked
    /////////////////////BU KODUN SONUDUR.///////////
    ////////// TREND TAKB N KULLANILAN KOD.////////
    var string vanity_group "Visual Settings"

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

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

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

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

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

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

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

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

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

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

    chosen_style 
    decode_fashion_statement(fashion_choice)

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

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

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

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

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

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

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

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

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

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

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

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

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

    color active_crayon 
    vibes == shrek_mode blood_bath

    plot
    (magic_wand_toggle bagholder_entry na"Trend"color=active_crayonlinewidth=girth_unitsstyle=plot.style_stepline)
    //////////////////////BU KODUN SONUDUR./////////////////// 
    fibo tarding...
    //@version=6
    indicator('...', overlay = true, max_lines_count = 500, max_labels_count = 500)
    ma_tt = '=== Moving Average Cycle ==='
    _source = close
    _p = input(100, title = 'Period', inline = 'set1', group = ma_tt)
    _c = ta.ema(close, _p) - ta.sma(close, _p)
    _m = 0
    sr_group = '=== Support Resistance ==='
    Left = input.int(4, title = '.', minval = 1, group = sr_group)
    Right = input.int(4, title = '.', minval = 0, group = sr_group)
    trading_group = '=== Trading Setup ==='
    trading_setup = input.string('Both', title = 'Setup', options = ['Long Only', 'Short Only', 'Both', 'MA Cycle', 'RSI_MACD', 'Gaussian_Filter'], group = trading_group)

    var Long = false
    Short = false
    if trading_setup == 'Long Only'
    Long := true
    Short := false
    Short
    else if trading_setup == 'Short Only'
    Long := false
    Short := true
    Short
    else if trading_setup == 'MA Cycle'
    if _c > 0
    Long := true
    Short := false
    Short
    else
    Long := false
    Short := true
    Short
    //else if trading_setup == 'RSI_MACD'
    //if _m > 0
    //Long := true
    //Short := false
    //Short
    //else
    //Long := false
    //Short := true
    //Short
    //else if trading_setup == 'Gaussian_Filter'
    //if _g > 0
    //Long := true
    //Short := false
    //Short
    //else
    //Long := false
    //Short := true
    //Short
    else
    Long := true
    Short := true
    Short
    //Background Filling
    ///

    isFractal(x) =>
    ta.highestbars(x, Left + Right + 1) == -Right
    sF = isFractal(-low)
    support = low
    support := sF ? low[Right] : support[1]
    rF = isFractal(high)
    resistance = high
    resistance := rF ? high[Right] : resistance[1]
    //Value & Index
    ph = rF
    ph_val = ta.valuewhen(ph, resistance, 0)
    res = ph_val
    ph_index = ta.valuewhen(ph, bar_index - Right, 0)

    pl = sF
    pl_val = ta.valuewhen(pl, support, 0)
    sup = pl_val
    pl_index = ta.valuewhen(pl, bar_index - Right, 0)
    //Long setup
    var long_sup_index = 0
    long_sup_val = 0.0
    long_res_val = 0.0
    if pl_index < ph_index
    long_sup_index := pl_index
    long_sup_val := pl_val
    long_res_val := ph_val
    long_res_val
    else
    long_sup_index := long_sup_index[1]
    long_sup_val := long_sup_val[1]
    long_sup_val
    if long_sup_index == long_sup_index[1]
    long_res_val := long_res_val[1]
    long_res_val
    //Long Condition
    long_cond = close > long_sup_val and Long
    //Resistance Line
    long_res_x1 = long_sup_index
    long_res_y1 = long_cond ? long_res_val : na
    long_res_x2 = bar_index
    long_res_y2 = long_res_y1
    long_res_ext = extend.right
    long_res_clr = color.new(color.red, 0)
    long_res_textColor = color.new(color.white, 0)
    long_res_sty = line.style_dotted
    long_res_width = 2
    plot(long_cond ? long_res_y1 : na, title = 'Long Arttr', color = color.new(color.red, 100))

    //Support Line
    long_sup_x1 = long_sup_index
    long_sup_y1 = Long ? long_sup_val : na
    long_sup_x2 = bar_index
    long_sup_y2 = long_sup_y1
    long_sup_ext = extend.right
    long_sup_clr = color.new(color.blue, 0)
    long_sup_textColor = color.new(color.white, 0)
    long_sup_sty = line.style_dotted
    long_sup_width = 2
    plot(Long ? long_sup_val : na, title = 'Long DnME', color = color.new(color.blue, 100))
    //Fib50 Line
    long_fib50_x1 = long_sup_index
    long_fib50_y1 = long_cond ? (long_res_y1 + long_sup_y1) * 0.5 : na
    long_fib50_x2 = bar_index
    long_fib50_y2 = long_fib50_y1
    long_fib50_ext = extend.right
    long_fib50_clr = color.new(color.blue, 0)
    long_fib50_textColor = color.new(color.white, 0)
    long_fib50_sty = line.style_dotted
    long_fib50_width = 2
    plot(long_cond ? long_fib50_y1 : na, title = 'Long Bala', color = color.new(color.blue, 100))
    //Fib618 Line
    long_fib618_x1 = long_sup_index
    long_fib618_y1 = long_cond ? long_res_y1 - (long_res_y1 - long_sup_y1) * 0.618 : na
    long_fib618_x2 = bar_index
    long_fib618_y2 = long_fib618_y1
    long_fib618_ext = extend.right
    long_fib618_clr = color.new(color.blue, 0)
    long_fib618_textColor = color.new(color.white, 0)
    long_fib618_sty = line.style_dotted
    long_fib618_width = 2

    long_tp1_x1 = long_sup_index
    long_tp1_y1 = long_cond ? long_res_y1 + (long_res_y1 - long_sup_y1) * 0.382 : na
    long_tp1_x2 = bar_index
    long_tp1_y2 = long_tp1_y1
    long_tp1_ext = extend.right
    long_tp1_clr = color.new(color.blue, 0)
    long_tp1_textColor = color.new(color.white, 0)
    long_tp1_sty = line.style_dotted
    long_tp1_width = 2
    plot(long_cond ? long_tp1_y1 : na, title = 'Long Kapat', color = color.new(color.blue, 100))
    //tp2
    long_tp2_x1 = long_sup_index
    long_tp2_y1 = long_cond ? long_res_y1 + long_res_y1 - long_sup_y1 : na
    long_tp2_x2 = bar_index
    long_tp2_y2 = long_tp2_y1
    long_tp2_ext = extend.right
    long_tp2_clr = color.new(color.blue, 0)
    long_tp2_textColor = color.new(color.white, 0)
    long_tp2_sty = line.style_dotted
    long_tp2_width = 2
    plot(long_cond ? long_tp2_y1 : na, title = 'Long Kesin Kapat', color = color.new(color.blue, 100))

    //Short setup
    var short_res_index = 0
    short_res_val = 0.0
    short_sup_val = 0.0
    if pl_index > ph_index
    short_res_index := ph_index
    short_res_val := ph_val
    short_sup_val := pl_val
    short_sup_val
    else
    short_res_index := short_res_index[1]
    short_res_val := short_res_val[1]
    short_res_val
    if short_res_index == short_res_index[1]
    short_sup_val := short_sup_val[1]
    short_sup_val
    //Short Condition
    short_cond = close < short_res_val and Short
    //Resistance Line
    short_res_x1 = short_res_index
    short_res_y1 = Short ? short_res_val : na
    short_res_x2 = bar_index
    short_res_y2 = short_res_y1
    short_res_ext = extend.right
    short_res_clr = color.new(color.red, 0)
    short_res_textColor = color.new(color.white, 0)
    short_res_sty = line.style_dotted
    short_res_width = 2
    plot(Short ? short_res_val : na, title = 'Short DnME', color = color.new(color.red, 100))

    //Support Line
    short_sup_x1 = short_res_index
    short_sup_y1 = short_cond ? short_sup_val : na
    short_sup_x2 = bar_index
    short_sup_y2 = short_sup_y1
    short_sup_ext = extend.right
    short_sup_clr = color.new(color.blue, 0)
    short_sup_textColor = color.new(color.white, 0)
    short_sup_sty = line.style_dotted
    short_sup_width = 2
    plot(short_cond ? short_sup_y1 : na, title = 'Short Arttr', color = color.new(color.blue, 100))
    //Fib50 Line
    short_fib50_x1 = short_res_index
    short_fib50_y1 = short_cond ? (short_res_y1 + short_sup_y1) * 0.5 : na
    short_fib50_x2 = bar_index
    short_fib50_y2 = short_fib50_y1
    short_fib50_ext = extend.right
    short_fib50_clr = color.new(color.red, 0)
    short_fib50_textColor = color.new(color.white, 0)
    short_fib50_sty = line.style_dotted
    short_fib50_width = 2
    plot(short_cond ? short_fib50_y1 : na, title = 'Short Bala', color = color.new(color.red, 100))
    //Fib618 Line
    short_fib618_x1 = short_res_index
    short_fib618_y1 = short_cond ? short_sup_y1 + (short_res_y1 - short_sup_y1) * 0.618 : na
    short_fib618_x2 = bar_index
    short_fib618_y2 = short_fib618_y1
    short_fib618_ext = extend.right
    short_fib618_clr = color.new(color.red, 0)
    short_fib618_textColor = color.new(color.white, 0)
    short_fib618_sty = line.style_dotted
    short_fib618_width = 2

    short_tp1_x1 = short_res_index
    short_tp1_y1 = short_cond ? short_sup_y1 - (short_res_y1 - short_sup_y1) * 0.382 : na
    short_tp1_x2 = bar_index
    short_tp1_y2 = short_tp1_y1
    short_tp1_ext = extend.right
    short_tp1_clr = color.new(color.red, 0)
    short_tp1_textColor = color.new(color.white, 0)
    short_tp1_sty = line.style_dotted
    short_tp1_width = 2
    plot(short_cond ? short_tp1_y1 : na, title = 'Short Kapat', color = color.new(color.red, 100))
    //tp2
    short_tp2_x1 = short_res_index
    short_tp2_y1 = short_cond ? short_sup_y1 - (short_res_y1 - short_sup_y1) : na
    short_tp2_x2 = bar_index
    short_tp2_y2 = short_tp2_y1
    short_tp2_ext = extend.right
    short_tp2_clr = color.new(color.red, 0)
    short_tp2_textColor = color.new(color.white, 0)
    short_tp2_sty = line.style_dotted
    short_tp2_width = 2
    plot(short_cond ? short_tp2_y1 : na, title = 'Short Kesin Kapat', color = color.new(color.red, 100))

    // --------------------------------------------------------------------------------------------------------------------{

    showBreakLabels = input.bool(true, title = 'Show breakouts', group = 'Breakout Labels')
    showVolumeBreakLabels = input.bool(true, title = 'Show Breakouts with high volume', group = 'Breakout Labels')

    timeframe = input.timeframe('', title = 'Timeframe')
    [Open, High, Low, Close, Volume] = request.security(syminfo.tickerid, timeframe, [open, high, low, close, volume])

    start44 = input(0., title = 'start', group = 'Parabolic SAR')
    increment44 = input(0.1, title = 'Increment', group = 'Parabolic SAR')
    maximum44 = input(0.99, 'Max Value', group = 'Parabolic SAR')

    out44 = request.security(syminfo.tickerid, timeframe, ta.sar(start44, increment44, maximum44), gaps = barmerge.gaps_off)

    sarChange = ta.change(out44 < High)

    var prevSar = out44

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

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

    //plot(sarChange ? na : prevSar, style = plot.style_linebr, offset = -1, color = out44 < high ? color.new(#363a45, 100) : color.new(#363a45, 100), title = 'KRL', linewidth = 1)
    //plot(out44, 'TREND1', style = plot.style_steplinebr, color = color.yellow)
    plot(out44, 'TREND1', color = close > out44 ? color.new(#f8f402, 50) : color.new(#c604f7, 50), style = plot.style_linebr)

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

    start88 = input.float(0., 'Starting value')
    inc88 = input.float(0.01, 'Increment')
    max88 = input.float(0.99, 'Max Value')
    width = input.float(5.00, 'Zone width')

    atrs = ta.atr(100) * width
    sarone = ta.sar(start88, inc88, max88)
    sarzone = if close > sarone
    sarone + atrs
    else if close < sarone
    sarone - atrs
    sartwo = ta.sar(start88 / 2, inc88 / 2, max88 / 2)

    p1 = plot(sarone, 'Kanal', color = close > sarone ? #2962ff00 : #e91e6200, style = plot.style_circles)
    p3 = plot(sarzone, 'Kanal', color = close > sarone ? #2962ff00 : #e91e6200, style = plot.style_circles)
    fill(p1, p3, color = close > sarone ? color.new(#ffffff, 90) : color.new(#e91e63, 100))

    plot(sartwo, 'TREND2', color = close > sartwo ? color.new(#f8f402, 0) : color.new(#c604f7, 0), style = plot.style_linebr)
    16.07.2024 - 10.12.2024

  7. swing trade...
    PHP Code:
    // This Pine Script code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    //  ChartPrime


    //@version=6
    indicator("Swing Structure Bands [ChartPrime]"overlay truemax_bars_back 5000max_polylines_count 100max_labels_count 500)


    // --------------------------------------------------------------------------------------------------------------------}
    // 📌 USER INPUTS
    // --------------------------------------------------------------------------------------------------------------------{

    lenSwing input.int(100"Swing Length")
    maType   input.string("SMA""MA Type"options = ["SMA""EMA""SMMA (RMA)""WMA""VWMA"], display display.data_window)
    bands    input.bool(true"Bands")

    colDn input.color(color.fuchsia,   "Bear Color")
    colUp input.color(color.green"Bull Color")


    // --------------------------------------------------------------------------------------------------------------------}
    // 📌 INDICATOR CALCULATIONS
    // --------------------------------------------------------------------------------------------------------------------{

    f_ema(srclen) =>
        
    / (len 1)
        
    0.0
        v 
    := na(v[1]) ? src src + (a) * nz(v[1])

    f_rma(srclen) =>
        
    len
        v 
    0.0
        v 
    := na(v[1]) ? ta.sma(srclen) : src + (a) * nz(v[1])

    f_ma(srclentype) =>
        switch 
    type
            
    "SMA"        => ta.sma(srclen)
            
    "EMA"        => f_ema(srclen)
            
    "SMMA (RMA)" => f_rma(srclen)
            
    "WMA"        => ta.wma(srclen)
            
    "VWMA"       => ta.vwma(srclen)


    hiMax ta.highest(lenSwing)
    loMin ta.lowest(lenSwing)
    atr  ta.atr(200)

    var 
    dir  0
    var lh   1
    var ll   1

    var hiIdx 0
    var hiPx  0.0

    var loIdx 0
    var loPx  0.0


    isHiSw 
    high[1] == hiMax and high hiMax
    isLoSw 
    low[1]  == loMin and low  loMin


    if high == hiMax
        dir 
    := 1

    if low == loMin
        dir 
    := -1

    if isLoSw
        loIdx 
    := bar_index 1
        loPx  
    := low[1]
        
    ll    := 1

    if isHiSw
        hiIdx 
    := bar_index 1
        hiPx  
    := high[1]
        
    lh    := 1


    if dir != dir[1] and dir == -1
        label
    .new(hiIdxhiPx+atr"Swing High"color color.new(colDn80), textcolor chart.fg_colorstyle label.style_label_down)

    if 
    dir != dir[1] and dir == 1
        label
    .new(loIdxloPx-atr"Swing Low"color color.new(colUp80), textcolor chart.fg_colorstyle label.style_label_up)


    lh += 1
    ll 
    += 1


    maHi 
    f_ma(highlhmaType)
    maLo f_ma(low,  llmaType)


    dHi math.abs(maHi maHi[1]) > atr
    dLo 
    math.abs(maLo maLo[1]) > atr


    var uc 0
    var lc 0

    var uIdx 0
    var lIdx 0


    uc 
    := not dHi uc 0
    lc 
    := not dLo lc 0


    ub 
    dHi na maHi
    lb 
    dLo na maLo

    ub1 
    dHi na maHi atr
    ub2 
    dHi na maHi atr

    lb1 
    dLo na maLo atr
    lb2 
    dLo na maLo atr


    // --------------------------------------------------------------------------------------------------------------------}
    // 📌 VISUALIZATION
    // --------------------------------------------------------------------------------------------------------------------{

    pU  plot(ub,  style plot.style_linebrcolor colDntitle "TOP Band Middle")
    pU1 plot(ub1style plot.style_linebrcolor color.new(colDnbands 50 100), title "TOP Band Upper")
    pU2 plot(ub2style plot.style_linebrcolor color.new(colDnbands 50 100), title "TOP Band Lower")

    fill(pUpU1ub1ubnacolor.new(colDnbands 70 100))
    fill(pUpU2ub2ubnacolor.new(colDnbands 70 100))


    pL  plot(lb,  style plot.style_linebrcolor colUptitle "LOW Band Middle")
    pL1 plot(lb1style plot.style_linebrcolor color.new(colUpbands 50 100), title "LOW Band Upper")
    pL2 plot(lb2style plot.style_linebrcolor color.new(colUpbands 50 100), title "LOW Band Lower")

    fill(pLpL1lb1lbnacolor.new(colUpbands 70 100))
    fill(pLpL2lb2lbnacolor.new(colUpbands 70 100))


    sell ta.crossunder(highub) and uc 20
    buy  
    ta.crossover(low,  lb) and lc 15

    plotshape
    (sell and bar_index uIdx 10 high[1] + atr na"Sell"shape.diamondlocation.absolutesize size.tiny,  color colDn)
    plotshape(sell and bar_index uIdx 10 high[1] + atr na"Sell"shape.diamondlocation.absolutesize size.smallcolor color.new(colDn60))

    plotshape(buy  and bar_index lIdx 10 low[1]  - atr na"Buy",  shape.diamondlocation.absolutesize size.tiny,  color colUp)
    plotshape(buy  and bar_index lIdx 10 low[1]  - atr na"Buy",  shape.diamondlocation.absolutesize size.smallcolor color.new(colUp60))

    if 
    sell
        uIdx 
    := bar_index

    if buy
        lIdx 
    := bar_index
    // --------------------------------------------------------------------------------------------------------------------} 
    16.07.2024 - 10.12.2024

  8. yedek...
    PHP Code:
    ////////////////////////////////////////////////////////////////////////////////
    //                                                                            //
    // ====== ABOUT THIS INDICATOR                                                //
    //                                                                            //
    //  - This is just a basic example of drawing lines using 'line.new()' to     //
    //    extend a line beyond the end of the bars on a chart using offsets,      //
    //    rather than relying on 'extend.right' functionality.                    //
    //                                                                            //
    //  It includes:                                                              //
    //                                                                            //
    //     a simple function to get an easy time offset which can then be        //
    //      multiplied to get an index forwards off the chart, or backwards.      //
    //     simple, but 'proper' line creation and management functionality.      //
    //                                                                            //
    // ====== REASON FOR STUDY                                                    //
    //                                                                            //
    //  - Educational Purposes Only                                               //
    //                                                                            //
    //     I attempt to break down the very basics of positioning lines          //
    //      and other drawing objects using 'time'.                               //
    //                                                                            //
    //     For more advanced/in-depth time offset stuffs check out this post:             
    //      https://www.tradingview.com/script/5mZ7hV66-Time-Offset-Calculation-Framework-PineCoders-FAQ/
    //                                                                            
    // ====== DISCLAIMER                                                          //
    //                                                                            //
    //    Any trade decisions you make are entirely your own responsibility.      //
    //    I've made an effort to squash all the bugs, but you never know!         //
    //                                                                            //
    ////////////////////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////////////////
    //                                                                            //
    //                            ====== INPUTS ======                            //
    //                                                                            //
    ////////////////////////////////////////////////////////////////////////////////

    // -- our time offset multiplier input
    INP_offsetTime input(10'Time Offset')

    // -- fast and slow SMA length inputs for use as the example cases
    INP_fastLength input.int(1'Fast SMA Length'minval 1)
    INP_slowLength input.int(21'Slow SMA Length'minval 1)

    // -- extra fluff input for changing length of vertical lines
    INP_vertLength input(3'(extra) Vertical Line Length')

    ////////////////////////////////////////////////////////////////////////////////
    //                                                                            //
    //                          ====== FUNCTIONS ======                           //
    //                                                                            //
    ////////////////////////////////////////////////////////////////////////////////

    // -- Time Offset Function
    //
    f_offsetTime(_userOffsetInput) =>

        
    // init our _return variable
        
    var int _return na

        
    // get current time
        
    int _timeNow time

        
    // get difference between current bar time and previous bar time
        
    int _timeSeg time time[1]

        
    // multiply the segment by the user input
        
    int _segMult _timeSeg _userOffsetInput

        
    // return time now + multiplied time segment for offset, giving us our
        // +1|2|3 etc. OR -1|2|3 location depending on user input.
        
    _return := _timeNow _segMult
        _return

    // -- compact offset function version
    //
    //      f_offsetTime(_input) => time + ( ( time - time[1] ) * _input )

    ////////////////////////////////////////////////////////////////////////////////
    //                                                                            //
    //                    ====== SERIES and LINES SETUP ======                    //
    //                                                                            //
    ////////////////////////////////////////////////////////////////////////////////

    // -- standard 'fast' and 'slow' sma's which we will be extending
    float _fastMA ta.sma(close[1], INP_fastLength)
    float _slowMA ta.sma(close[1], INP_slowLength)

    // -- 'proper' instantiation for our lines, which we set up later
    //  * For more information about using the 'var' keyword:
    //    https://www.tradingview.com/pine-script-reference/v4/#op_var
    var line _fastExtention na
    var line _slowExtention na

    // -- our time offset for forward/backward positioning on our lines
    int _offsetTime f_offsetTime(INP_offsetTime)

    ////////////////////////////////////////////////////////////////////////////////
    //                                                                            //
    //                     ====== DRAWING and PLOTTING ======                     //
    //                                                                            //
    ////////////////////////////////////////////////////////////////////////////////

    // -- our SMA plots
    //plot(_fastMA,'hzlSMA', color = color.new(color.yellow, 100))
    //plot(_slowMA, 'yavaSMA', color = color.new(color.aqua, 100))


    // -- FIRST EXTENSION LINE (for fast SMA)
    //
    if na(_fastExtention)
        
    //
        //  If our variable has 'na' value, then we need to create our line first.
        //  For it's first horizontal (x1) location, we use the current 'time'
        //  For the second horizontal (x2) location, we use our '_offsetTime' value.
        //  For both of the vertical (y1 and y2) locations, we use the '_fastMA' so
        //  that we get a straight projection out from it's end.
        //
        
    _fastExtention := line.new(time_fastMA_offsetTime_fastMAxloc.bar_timeextend.none)
        
    _fastExtention

    // -- POSITION UPDATING:
    //
    //    once the line has been created we can keep updating it's locations to
    //    match the end of the _fastMA using 'line.set_xy1()' and 'line.set_xy2()'
    //
    line.set_xy1(_fastExtentiontime_fastMA)
    line.set_xy2(_fastExtention_offsetTime_fastMA)
    // -- adjust some styling options
    line.set_color(_fastExtentioncolor.yellow)
    line.set_width(_fastExtention1)


    // -- SECOND EXTENSION LINE (for slow SMA)
    //  
    //  We can simply repeat the steps above for the '_fastExtention' line on the 
    //  '_slowExtention', but this time using the '_slowMA' for the vertical
    //  positioning (y1 and y2)
    //
    if na(_slowExtention)
        
    _slowExtention := line.new(time_slowMA_offsetTime_slowMAxloc.bar_timeextend.none)
        
    _slowExtention
    line
    .set_xy1(_slowExtentiontime_slowMA)
    line.set_xy2(_slowExtention_offsetTime_slowMA)
    // -- adjust some styling options
    line.set_color(_slowExtentioncolor.aqua)
    line.set_width(_slowExtention1)


    //  NOTES:
    //
    //  1:  [ 0 + 0 = 0 ] ...and what i mean by that is...
    //      Should you find your line to NOT BE SHOWING, it may be that you need to
    //      check your locations. If both your 'x1' and 'x2' are sharing a position,
    //      then your 'y1' and 'y2' must NOT share the same values (similarly the 
    //      opposite way around) else you will be drawing nothing. There MUST be an
    //      offset somewhere for a line to draw.
    //
    //  2:  If you're on a chart with temporal gaps (not open to trade 24/7) then
    //      your lines may not extend for example into the weekend on a currency
    //      pair.
    //
    //  3:  If you want to get rid of a line rather than update it, based on some
    //      condition for example, then rather than updating you can delete it until
    //      another condition calls for it to be drawn and updated again. So it
    //      might end up looking more like this:
    //
    //      if na(_line)
    //          _line := line.new(time, _float, _offsetTime, _float, xloc.bar_time)
    //
    //      if _someConditionTrue
    //          line.delete(_line)
    //      else
    //          line.set_xy1(_line, time, _float)
    //          line.set_xy2(_line, _offsetTime, _float)
    //

    ////////////////////////////////////////////////////////////////////////////////
    //                                                                            //
    //                          ====== EXTRA FLUFF ======                         //
    //                                                                            //
    //      For the purpose of this example, everything below can happily         //
    //      be ignored as it's just for extra decoration and visualisation,       //
    //      but we do set vertical lines and a label using the time               //
    //      positioning value already defined above.                              //
    //                                                                            //
    ////////////////////////////////////////////////////////////////////////////////

    // -- vertical lines to depict the starting and finish of extensions
    var line _startLineVertical na
    var line _finishLineVertical na

    // -- a few Y positioning values using the current gap between SMA's
    float _min math.min(_fastMA_slowMA)
    float _max math.max(_fastMA_slowMA)
    float _len _max _min
    float _top 
    _max _len INP_vertLength
    float _bot 
    _min _len INP_vertLength

    // -- draw our verticals much like the horizontals, but focusing on the y1|y2
    //    positioning while the x1|x2 remain constant
    if na(_startLineVertical)
        
    _startLineVertical := line.new(time_toptime_botxloc.bar_timeextend.none)
        
    _startLineVertical
    line
    .set_xy1(_startLineVerticaltime_top)
    line.set_xy2(_startLineVerticaltime_bot)

    if 
    na(_finishLineVertical)
        
    _finishLineVertical := line.new(_offsetTime_top_offsetTime_botxloc.bar_timeextend.none)
        
    _finishLineVertical
    line
    .set_xy1(_finishLineVertical_offsetTime_top)
    line.set_xy2(_finishLineVertical_offsetTime_bot)

    // -- a label to denote the extension distance and mark endpoint.
    var label _offsetLabel na
    // -- to contain text string for the label
    var string _labelText na

    // -- buid our label text
    string _direction INP_offsetTime ' +++' INP_offsetTime ' ---' ''
    _labelText := str.tostring(INP_offsetTime) + ' @@' _direction '**'

    // -- get it printed and managed
    if na(_offsetLabel)
        
    _offsetLabel := label.new(_offsetTime_top_labelTextxloc.bar_time)
        
    _offsetLabel
    label
    .set_xy(_offsetLabel_offsetTime_top)

    // -- lets flip the label style if the vertical multiplier is set to negative
    //    value, because why not?
    label.set_style(_offsetLabelINP_vertLength >= label.style_label_down label.style_label_up)

    // -- PEANUT
    /////////////////// 
    16.07.2024 - 10.12.2024

Sayfa 367/393 lklk ... 267317357365366367368369377 ... SonSon

Yer mleri

Yer mleri

Gnderi Kurallar

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