Sayfa 347/351 İlkİlk ... 247297337345346347348349 ... SonSon
Arama sonucu : 2803 madde; 2,769 - 2,776 arası.

Konu: Tradingview

  1. PHP Code:
    //@version=6

    indicator('.'shorttitle '.'overlay truemax_lines_count 100max_labels_count=100max_boxes_count 100max_bars_back 100)

    // Ortak başlangıç değeri
    start 0.01
    // 4. SAR ve EMA(5) ile yumuşatma
    sar4_raw ta.sar(start11)
    sar4_ema ta.ema(sar4_raw3)
    sar4_color close sar4_ema color.white color.fuchsia

    A111 
    input(0.1)
    B111 input(0.01)
    C111 input(0.1".")
    ABC111 ta.sar(A111B111C111)
    plot(ABC111"sar"style=plot.style_crosscolor=sar4_colorlinewidth 2)


    /////////////////////////////////////////////////////////SON BARI ATR İLE OLASILIK HESAPLA///////////////////////
    // Inputs
    length14 input.int(title 'ATR Length'defval 1minval 1)
    tradetype14 input.string(defval 'Long'title 'Trade Type'options = ['Long''Short'])
    takeprofit14 input.float(1'Take Profit Times ATR'minval 0.1)
    stoploss14 input.float(1.6'Stop Loss Times ATR'minval 0.1)
    index14 input(0'Display Index')

    // Functions
    getMA(serieslength14) =>
        
    ta.rma(serieslength14)
    getTV(value) =>
        
    math.round(value 100000) / 100000

    // Variables
    atr148 getMA(ta.tr(true), length14)[index14]
    posTake tradetype14 == 'Long' close[index14] + takeprofit14 atr148 close[index14] - takeprofit14 atr148
    posStop 
    tradetype14 == 'Long' close[index14] - stoploss14 atr148 close[index14] + stoploss14 atr148
    colorTake 
    color.new(color.lime50)
    colorStop color.new(color.red50)
    // Plots
    plotcandle(close[index14], posTakeclose[index14], posTaketitle 'OLST'color index14 == colorTake nabordercolor index14 == colorTake nawickcolor nashow_last 1)
    plotcandle(close[index14], closeposStopposStoptitle 'OLSD'color index14 == colorStop nabordercolor index14 == colorStop nawickcolor nashow_last 1
    denemek isteyene....

  2. PHP Code:
    //@version=6

    indicator('Neural Network Buy and Sell Signals'shorttitle '.'overlay truemax_lines_count 100max_labels_count=100max_boxes_count 100max_bars_back 100)

    var 
    string scalpHelperGroup 'Scalp Helper Signal Settings'
    enable_scalp_helper input.bool(true'Enable Scalp Helper Signals'group scalpHelperGroup)
    signalCandleType input.string('Candlesticks''Signal Candle Type'options = ['Candlesticks''Heikin Ashi''Linear Regression'], group scalpHelperGrouptooltip 'Choose which candle type to use for signal calculations. This will not change what candlestick type is displayed.')

    signal_trigger_mult input.float(1.5'Signal Trigger Sensitivity'minval 0.1maxval 10.0step 0.1group scalpHelperGrouptooltip 'Controls both buy and sell signal sensitivity. Lower values = more sensitive signals, higher values = less sensitive signals.')

    stop_atr_mult input.float(1.5'Stop Loss ATR Multiplier'minval 0.1maxval 10.0step 0.1group scalpHelperGrouptooltip 'Once a signal is triggered this stop will be initiated to tell how long the signal is valid. Higher values = wider stops and less signals, lower values = tighter stops and more signals.')

    var 
    string candleGroup 'Candlestick Settings'
    candleType input.string('Candlesticks''Candle Type'options = ['Candlesticks''Heikin Ashi''Linear Regression'], group candleGrouptooltip 'Choose the type of candles to display. This does not impact signal calculations.')
    lrcLength1 input.int(6'Linear Regression Length'minval 1group candleGrouptooltip 'Length for Linear Regression calculations. Lower values are more responsive but noisier.')

    var 
    string visualGroup 'Display Settings'
    signalOffset input.float(1.05'Signal Distance from Candles'minval 0.1maxval 3.0step 0.1group visualGrouptooltip 'Distance of buy/sell labels from candles (ATR multiplier)')
    signalLabelSize input.string('medium''Signal Label Size'options = ['tiny''small''medium''large'], group visualGrouptooltip 'Size of the neural network signal labels')

    buy_signal_length 2
    buy_atr_length 
    18
    sell_signal_length 
    2
    sell_atr_length 
    18

    buy_signal_use_close 
    false
    buy_atr_use_close 
    true
    sell_signal_use_close 
    false
    sell_atr_use_close 
    true

    amf_length 
    14
    amf_signal_length 
    9
    amf_smoothing 
    3
    amf_fast_length 
    5
    amf_slow_length 
    21
    amf_far_threshold 
    0.3
    amf_slope_fast_threshold 
    0.03

    h1_amf_weight 
    1.2
    h1_alma_weight 
    0.4
    h1_sr_weight 
    0.5
    h1_swing_weight 
    0.4
    h1_regime_weight 
    0.7
    h1_bias 
    0.2

    h2_amf_weight 
    1.4
    h2_alma_weight 
    0.3
    h2_sr_weight 
    0.6
    h2_swing_weight 
    0.3
    h2_regime_weight 
    0.8
    h2_bias 
    0.15

    h3_amf_weight 
    1.6
    h3_alma_weight 
    0.4
    h3_sr_weight 
    0.4
    h3_swing_weight 
    0.5
    h3_regime_weight 
    0.6
    h3_bias 
    0.25

    out_h1_weight 
    0.4
    out_h2_weight 
    0.4
    out_h3_weight 
    0.4
    out_bias 
    0.3

    enable_input_normalization 
    true
    normalization_lookback 
    50
    outlier_clipping 
    true
    clipping_threshold 
    3.0

    almaLength 
    20
    almaOffset 
    0.85
    almaSigma 
    6.0
    alma2Length 
    20
    alma2Offset 
    0.77
    alma2Sigma 
    6.0
    alma_wide_gap_threshold 
    0.1

    pivot_lookback 
    10
    sr_proximity_threshold 
    0.5
    sr_breakout_threshold 
    0.2
    swing_structure_length 
    20
    regime_lookback 
    30
    trending_threshold 
    0.6

    showScalpLabels 
    true

    var float signalOpen open
    var float signalHigh high
    var float signalLow low
    var float signalClose close

    customBuyColor 
    color.new(#00FFFF, 0)
    customSellColor color.new(#FF0000, 0)
    scalpLongColor color.new(#00B3B3, 0) 
    scalpShortColor color.new(#FF0000, 0) 
    textColor color.new(color.white0)

    f_ema_amf(sourcelen) =>
        
    float alpha 2.0 / (len 1)
        var 
    float ema_val na 
        
    if not na(source) and len 0
            ema_val 
    := alpha source + (alpha) * nz(ema_val[1])
        
    ema_val

    f_dema_amf
    (sourcelen) =>
        
    float ema1 f_ema_amf(sourcelen)
        
    float ema2 f_ema_amf(ema1len)
        
    float dema_val ema1 ema2
        dema_val

    f_zlema_amf
    (sourcelen) =>
        
    int lag int((len 1) / 2)
        
    float lag_source lag source[lag] : source
        float adjusted_source 
    source + (source lag_source)
        
    float zlema_val f_ema_amf(adjusted_sourcelen)
        
    zlema_val

    f_sum_amf
    (sourcelen) =>
        
    float sum_val 0.0
        
    for 0 to len 1
            sum_val 
    += nz(source[i], 0)
        
    sum_val

    f_calculate_amf
    (srclengthfast_lenslow_lensmooth_len) =>
        
    float current_atr ta.atr(14)
        
    float avg_atr ta.sma(current_atr50)
        
    float volatility_ratio avg_atr current_atr avg_atr 1.0
        
        float volatility_sensitivity 
    2.0
        float raw_adaptive_lookback 
    float(length) / math.pow(volatility_ratiovolatility_sensitivity)
        
    int adaptive_lookback int(math.max(5math.min(50raw_adaptive_lookback)))
        
        if 
    adaptive_lookback 1
            adaptive_lookback 
    := 1

        int zlema_fast_len 
    adaptive_lookback
        int dema_medium_len 
    int(adaptive_lookback 1.5
        
    int dema_slow_len int(adaptive_lookback 2.5)
        
        if 
    dema_medium_len 1
            dema_medium_len 
    := 1
        
    if dema_slow_len 1
            dema_slow_len 
    := 1

        float zlema_fast 
    f_zlema_amf(srczlema_fast_len)
        
    float dema_medium f_dema_amf(srcdema_medium_len)
        
    float dema_slow f_dema_amf(srcdema_slow_len)

        
    float pv 0.0
        
    if src src[1]
            
    pv := volume
        
    else if src src[1]
            
    pv := -volume

        float vzo_sum 
    f_sum_amf(pvlength)
        
    float vol_sum f_sum_amf(volumelength)
        
    float vzo_value vol_sum != 100 * (vzo_sum vol_sum) : 0.0
        float smoothed_vzo 
    ta.sma(vzo_value3)

        
    float price_vs_fast_weight 30.0
        float fast_vs_medium_weight 
    30.0
        float medium_vs_slow_weight 
    40.0
        float vzo_weight 
    20.0

        float oscillator_score 
    0.0

        
    if src zlema_fast
            oscillator_score 
    += price_vs_fast_weight
        
    else if src zlema_fast
            oscillator_score 
    -= price_vs_fast_weight

        
    if zlema_fast dema_medium
            oscillator_score 
    += fast_vs_medium_weight
        
    else if zlema_fast dema_medium
            oscillator_score 
    -= fast_vs_medium_weight

        
    if dema_medium dema_slow
            oscillator_score 
    += medium_vs_slow_weight
        
    else if dema_medium dema_slow
            oscillator_score 
    -= medium_vs_slow_weight

        oscillator_score 
    += (smoothed_vzo 100) * vzo_weight

        float max_possible_score 
    price_vs_fast_weight fast_vs_medium_weight medium_vs_slow_weight vzo_weight

        float normalized_score 
    max_possible_score != 0.0 ? (oscillator_score max_possible_score) * 100.0 0.0

        float final_amf 
    ta.ema(normalized_score 100.0smooth_len)
        
        
    final_amf

    f_amf_signal
    (amf_linesignal_length) =>
        
    ta.ema(amf_linesignal_length)

    // ===========================================================================================================
    // CACHED CALCULATIONS
    // ===========================================================================================================

    cached_atr ta.atr(14)

    // ===========================================================================================================
    // NORMALIZATION FUNCTIONS
    // ===========================================================================================================

    f_normalizeInput(valuelookback_periodenable_clippingclip_threshold) =>
        if 
    not enable_input_normalization
            value
        
    else
            
    mean_val ta.sma(valuelookback_period)
            
    variance ta.sma(math.pow(value mean_val2), lookback_period)
            
    std_val math.sqrt(variance)
            
            
    normalized std_val ? (value mean_val) / std_val 0.0
            
            
    if enable_clipping
                math
    .max(-clip_thresholdmath.min(clip_thresholdnormalized))
            else
                
    normalized

    f_robustNormalize
    (valuelookback_period) =>
        if 
    not enable_input_normalization
            value
        
    else
            
    ema_val ta.ema(valuelookback_period)
            
            
    abs_dev math.abs(value ema_val)
            
    mad_approx ta.ema(abs_devlookback_period) * 1.4826
            
            mad_approx 
    ? (value ema_val) / mad_approx 0.0

    // ===========================================================================================================
    // SIGNAL SCORING
    // ===========================================================================================================

    // Tanh approximation
    f_tanh(x) =>
        
    ex math.exp(x)
        (
    ex 1) / (ex 1)

    f_scoreSignal(amf_scorealma_scoresr_scoreswing_scoreregime_score) =>
        
    hidden1 f_tanh(h1_amf_weight*amf_score h1_alma_weight*alma_score h1_sr_weight*sr_score h1_swing_weight*swing_score h1_regime_weight*regime_score h1_bias)
        
    hidden2 f_tanh(h2_amf_weight*amf_score h2_alma_weight*alma_score h2_sr_weight*sr_score h2_swing_weight*swing_score h2_regime_weight*regime_score h2_bias)
        
    hidden3 f_tanh(h3_amf_weight*amf_score h3_alma_weight*alma_score h3_sr_weight*sr_score h3_swing_weight*swing_score h3_regime_weight*regime_score h3_bias)
        
    raw_output out_h1_weight*hidden1 out_h2_weight*hidden2 out_h3_weight*hidden3 out_bias
        1.0 
    / (1.0 math.exp(-raw_output))

    f_scoreSignalNormalized(amf_normalma_normsr_normswing_normregime_norm) =>
        
    input_scale 0.8 
        
        scaled_amf 
    amf_norm input_scale
        scaled_alma 
    alma_norm input_scale
        scaled_sr 
    sr_norm input_scale
        scaled_swing 
    swing_norm input_scale
        scaled_regime 
    regime_norm input_scale
        
        hidden1 
    f_tanh(h1_amf_weight*scaled_amf h1_alma_weight*scaled_alma 
                         
    h1_sr_weight*scaled_sr h1_swing_weight*scaled_swing h1_regime_weight*scaled_regime h1_bias)
        
        
    hidden2 f_tanh(h2_amf_weight*scaled_amf h2_alma_weight*scaled_alma 
                         
    h2_sr_weight*scaled_sr h2_swing_weight*scaled_swing h2_regime_weight*scaled_regime h2_bias)
        
        
    hidden3 f_tanh(h3_amf_weight*scaled_amf h3_alma_weight*scaled_alma 
                         
    h3_sr_weight*scaled_sr h3_swing_weight*scaled_swing h3_regime_weight*scaled_regime h3_bias)
        
        
    raw_output out_h1_weight*hidden1 out_h2_weight*hidden2 out_h3_weight*hidden3 out_bias
        
        temperature 
    1.2
        1.0 
    / (1.0 math.exp(-raw_output temperature))

    f_getSignalGrade(score) =>
        if 
    score >= 0.80
            
    ">80"  
        
    else if score >= 0.76
            
    "76"   
        
    else if score >= 0.65
            
    "65"   
        
    else if score >= 0.40
            
    "40"   
        
    else if score >= 0.32
            
    "32"   
        
    else
            
    "<32"   // (< 0.32)

    f_getScoreColor(score) =>
        var 
    color result_color color.maroon
        
        
    if score >= 0.76
            result_color 
    := customBuyColor
        
    else if score >= 0.65
            result_color 
    := color.new(customBuyColor20)
        else if 
    score >= 0.40
            result_color 
    := color.new(#00FFFF, 30)
        
    else if score >= 0.32
            result_color 
    := color.new(#FFB000, 0)
        
    else
            
    result_color := customSellColor
        
        result_color

    // AMF Analysis Functions
    f_analyzeAMF(amf_linesignal_lineis_buyis_sellcached_atr) =>
        
    amf_vs_signal amf_line signal_line
        
        crossing_up 
    amf_line signal_line and amf_line[1] <= signal_line[1]
        
    crossing_down amf_line signal_line and amf_line[1] >= signal_line[1]
        
        
    normalized_distance math.abs(amf_vs_signal) / cached_atr
        is_far 
    normalized_distance amf_far_threshold
        
        signal_slope 
    = (signal_line signal_line[1]) / cached_atr
        slope_fast_falling 
    signal_slope < -amf_slope_fast_threshold
        slope_fast_rising 
    signal_slope amf_slope_fast_threshold
        
        
    var float amf_score 0.0
        
        
    if is_buy
            
    if crossing_up or amf_line signal_line
                amf_score 
    := 1.0  
            
    else if amf_line signal_line
                
    if is_far
                    amf_score 
    := -0.8 
                
    else
                    
    amf_score := -0.4 
            
    else
                
    amf_score := 0.0
            
            
    if slope_fast_falling
                amf_score 
    := amf_score 0.3
                
        
    else if is_sell
            
    if crossing_down or amf_line signal_line
                amf_score 
    := 1.0  
            
    else if amf_line signal_line
                
    if is_far
                    amf_score 
    := -0.8
                
    else
                    
    amf_score := -0.4
            
    else
                
    amf_score := 0.0
            
            
    if slope_fast_rising
                amf_score 
    := amf_score 0.3
                
        
    else
            
    amf_score := 0.0
        
        math
    .max(-1.0math.min(1.0amf_score))

    f_analyzeALMA(fast_almaslow_almais_buyis_sellcached_atr) =>
        
    alma_gap fast_alma slow_alma
        normalized_gap 
    math.abs(alma_gap) / cached_atr
        is_wide_gap 
    normalized_gap alma_wide_gap_threshold
        
        crossing_up 
    fast_alma slow_alma and fast_alma[1] <= slow_alma[1]
        
    crossing_down fast_alma slow_alma and fast_alma[1] >= slow_alma[1]
        
        var 
    float alma_score 0.0
        
        
    if is_buy
            
    if crossing_up or fast_alma slow_alma
                alma_score 
    := 0.5 
            
    else if fast_alma slow_alma
                
    if is_wide_gap
                    alma_score 
    := -0.8 
                
    else
                    
    alma_score := -0.2 
            
    else
                
    alma_score := 0.0
                
        
    else if is_sell
            
    if crossing_down or fast_alma slow_alma
                alma_score 
    := 0.5 
            
    else if fast_alma slow_alma
                
    if is_wide_gap
                    alma_score 
    := -0.8
                
    else
                    
    alma_score := -0.2
            
    else
                
    alma_score := 0.0
                
        
    else
            
    alma_score := 0.0
        
        alma_score

    f_analyzeSupportResistance
    (is_buyis_sellcached_atrsig_highsig_lowsig_close) =>
        
    pivot_high ta.pivothigh(sig_highpivot_lookbackpivot_lookback)
        
    pivot_low ta.pivotlow(sig_lowpivot_lookbackpivot_lookback)
        
        var 
    float nearest_resistance na
        
    var float nearest_support na
        
        
    if not na(pivot_high)
            
    nearest_resistance := pivot_high
        
    if not na(pivot_low)
            
    nearest_support := pivot_low
        
        resistance_distance 
    nearest_resistance math.abs(sig_close nearest_resistance) / cached_atr 999
        support_distance 
    nearest_support math.abs(sig_close nearest_support) / cached_atr 999
        
        near_resistance 
    resistance_distance <= sr_proximity_threshold
        near_support 
    support_distance <= sr_proximity_threshold
        
        recent_resistance_break 
    nearest_resistance and sig_close nearest_resistance and sig_close[5] <= nearest_resistance
        recent_support_break 
    nearest_support and sig_close nearest_support and sig_close[5] >= nearest_support
        
        
    var float sr_score 0.0
        
        
    if is_buy
            
    if recent_resistance_break
                sr_score 
    := 0.8
            
    else if near_support
                sr_score 
    := 0.5
            
    else if near_resistance
                sr_score 
    := -0.6
            
    else
                
    sr_score := 0.0
                
        
    else if is_sell
            
    if recent_support_break
                sr_score 
    := 0.8
            
    else if near_resistance
                sr_score 
    := 0.5
            
    else if near_support
                sr_score 
    := -0.6
            
    else
                
    sr_score := 0.0
                
        
    else
            
    sr_score := 0.0
        
        sr_score


    f_analyzeSwingStructure
    (is_buyis_sellsig_highsig_low) =>
        
    recent_high ta.highest(sig_highswing_structure_length)
        
    recent_low ta.lowest(sig_lowswing_structure_length)
        
    previous_high ta.highest(sig_high[swing_structure_length], swing_structure_length)
        
    previous_low ta.lowest(sig_low[swing_structure_length], swing_structure_length)
        
        
    making_higher_highs recent_high previous_high
        making_higher_lows 
    recent_low previous_low
        making_lower_highs 
    recent_high previous_high
        making_lower_lows 
    recent_low previous_low
        
        bullish_structure 
    making_higher_highs and making_higher_lows
        bearish_structure 
    making_lower_highs and making_lower_lows
        mixed_structure 
    not bullish_structure and not bearish_structure
        
        
    var float swing_score 0.0
        
        
    if is_buy
            
    if bullish_structure
                swing_score 
    := 0.6
            
    else if bearish_structure
                swing_score 
    := -0.7
            
    else
                
    swing_score := -0.1
                
        
    else if is_sell
            
    if bearish_structure
                swing_score 
    := 0.6
            
    else if bullish_structure
                swing_score 
    := -0.7
            
    else
                
    swing_score := -0.1
                
        
    else
            
    swing_score := 0.0
        
        swing_score

    f_analyzeMarketRegime
    (is_buyis_sellsig_opensig_highsig_lowsig_close) =>
        
    tr1 math.max(sig_high sig_lowmath.abs(sig_high sig_close[1]))
        
    tr math.max(tr1math.abs(sig_low sig_close[1]))
        
    plus_dm sig_high sig_high[1] > sig_low[1] - sig_low math.max(sig_high sig_high[1], 0) : 0
        minus_dm 
    sig_low[1] - sig_low sig_high sig_high[1] ? math.max(sig_low[1] - sig_low0) : 0
        
        plus_di 
    100 ta.rma(plus_dmregime_lookback) / ta.rma(trregime_lookback)
        
    minus_di 100 ta.rma(minus_dmregime_lookback) / ta.rma(trregime_lookback)
        
    dx math.abs(plus_di minus_di) / (plus_di minus_di) * 100
        adx 
    ta.rma(dxregime_lookback)
        
        
    trending_market adx >= trending_threshold 100
        ranging_market 
    not trending_market
        bullish_trend 
    trending_market and plus_di minus_di
        bearish_trend 
    trending_market and minus_di plus_di
        
        
    var float regime_score 0.0
        
        
    if is_buy
            
    if bullish_trend
                regime_score 
    := 0.7
            
    else if bearish_trend
                regime_score 
    := -0.8
            
    else
                
    regime_score := -0.2
                
        
    else if is_sell
            
    if bearish_trend
                regime_score 
    := 0.7
            
    else if bullish_trend
                regime_score 
    := -0.8
            
    else
                
    regime_score := -0.2
                
        
    else
            
    regime_score := 0.0
        
        regime_score

    // ===========================================================================================================
    // CANDLE TYPE CALCULATIONS
    // ===========================================================================================================

    // Heikin Ashi
    calculateHA111() =>
        var 
    haOpen 0.0
        
    var haHigh 0.0
        
    var haLow 0.0
        
    var haClose 0.0

        newHaClose 
    = (open high low close) / 4
        newHaOpen 
    na(haOpen[1]) ? (open close) / : (haOpen[1] + haClose[1]) / 2
        newHaHigh 
    math.max(highmath.max(newHaOpennewHaClose))
        
    newHaLow math.min(lowmath.min(newHaOpennewHaClose))

        
    haClose := newHaClose
        haOpen 
    := newHaOpen
        haHigh 
    := newHaHigh
        haLow 
    := newHaLow

        
    [newHaOpennewHaHighnewHaLownewHaClose]

    [
    oHAhHAlHAcHA] = calculateHA111()

    var 
    float displayOpen na
    var float displayHigh na
    var float displayLow na
    var float displayClose na

    if candleType == 'Candlesticks'
        
    displayOpen := open
        displayHigh 
    := high
        displayLow 
    := low
        displayClose 
    := close
    else if candleType == 'Heikin Ashi'
        
    displayOpen := oHA
        displayHigh 
    := hHA
        displayLow 
    := lHA
        displayClose 
    := cHA
    else if candleType == 'Linear Regression'
        
    displayOpen := ta.linreg(openlrcLength10)
        
    displayHigh := ta.linreg(highlrcLength10)
        
    displayLow := ta.linreg(lowlrcLength10)
        
    displayClose := ta.linreg(closelrcLength10)

    // Determine coloring
    isBullishCandle displayClose displayOpen
    isBearishCandle 
    displayClose displayOpen

    // ===========================================================================================================
    // SIGNAL DATA SOURCE SELECTION
    // ===========================================================================================================

    var float signalOpenCalc na
    var float signalHighCalc na
    var float signalLowCalc na
    var float signalCloseCalc na

    if signalCandleType == 'Candlesticks'
        
    signalOpenCalc := open
        signalHighCalc 
    := high
        signalLowCalc 
    := low
        signalCloseCalc 
    := close
    else if signalCandleType == 'Heikin Ashi'
        
    signalOpenCalc := oHA
        signalHighCalc 
    := hHA
        signalLowCalc 
    := lHA
        signalCloseCalc 
    := cHA
    else if signalCandleType == 'Linear Regression'
        
    signalOpenCalc := ta.linreg(openlrcLength10)
        
    signalHighCalc := ta.linreg(highlrcLength10)
        
    signalLowCalc := ta.linreg(lowlrcLength10)
        
    signalCloseCalc := ta.linreg(closelrcLength10)

    signalOpen := signalOpenCalc
    signalHigh 
    := signalHighCalc
    signalLow 
    := signalLowCalc
    signalClose 
    := signalCloseCalc

    // ===========================================================================================================
    // SCALP HELPER SIGNAL SYSTEM
    // ===========================================================================================================

    buy_signal_buySignal false
    sell_signal_sellSignal 
    false
    buy_atr_sellSignal 
    false
    sell_atr_buySignal 
    false
    buy_atr_longStop 
    close
    sell_atr_shortStop 
    close
    var bool buy_atr_stop_active false
    var bool sell_atr_stop_active false

    if enable_scalp_helper
        
    // ============================================================================
        // BUY SIGNAL
        // ============================================================================
        
        
    buy_signal_atr ta.atr(buy_signal_length) * signal_trigger_mult
        
        buy_signal_longStop 
    = (buy_signal_use_close ta.highest(signalClosebuy_signal_length) : ta.highest(signalHighbuy_signal_length)) - buy_signal_atr
        buy_signal_longStopPrev 
    nz(buy_signal_longStop[1], buy_signal_longStop)
        
    buy_signal_longStop := signalClose[1] > buy_signal_longStopPrev math.max(buy_signal_longStopbuy_signal_longStopPrev) : buy_signal_longStop
        
        buy_signal_shortStop 
    = (buy_signal_use_close ta.lowest(signalClosebuy_signal_length) : ta.lowest(signalLowbuy_signal_length)) + buy_signal_atr
        buy_signal_shortStopPrev 
    nz(buy_signal_shortStop[1], buy_signal_shortStop)
        
    buy_signal_shortStop := signalClose[1] < buy_signal_shortStopPrev math.min(buy_signal_shortStopbuy_signal_shortStopPrev) : buy_signal_shortStop
        
        
    var int buy_signal_dir 1
        buy_signal_dir 
    := signalClose buy_signal_shortStopPrev signalClose buy_signal_longStopPrev ? -buy_signal_dir
        
        buy_signal_buySignal 
    := buy_signal_dir == and buy_signal_dir[1] == -1
        
        
    // ============================================================================
        // BUY ATR STOP
        // ============================================================================
        
        
    buy_atr_atr ta.atr(buy_atr_length) * stop_atr_mult
        
        buy_atr_longStop 
    := (buy_atr_use_close ta.highest(signalClosebuy_atr_length) : ta.highest(signalHighbuy_atr_length)) - buy_atr_atr
        buy_atr_longStopPrev 
    nz(buy_atr_longStop[1], buy_atr_longStop)
        
    buy_atr_longStop := signalClose[1] > buy_atr_longStopPrev math.max(buy_atr_longStopbuy_atr_longStopPrev) : buy_atr_longStop
        
        buy_atr_shortStop 
    = (buy_atr_use_close ta.lowest(signalClosebuy_atr_length) : ta.lowest(signalLowbuy_atr_length)) + buy_atr_atr
        buy_atr_shortStopPrev 
    nz(buy_atr_shortStop[1], buy_atr_shortStop)
        
    buy_atr_shortStop := signalClose[1] < buy_atr_shortStopPrev math.min(buy_atr_shortStopbuy_atr_shortStopPrev) : buy_atr_shortStop
        
        
    var int buy_atr_dir 1
        buy_atr_dir 
    := signalClose buy_atr_shortStopPrev signalClose buy_atr_longStopPrev ? -buy_atr_dir
        
        buy_atr_sellSignal 
    := buy_atr_dir == -and buy_atr_dir[1] == 1
        
        
    // ============================================================================
        // SELL SIGNAL
        // ============================================================================
        
        
    sell_signal_atr ta.atr(sell_signal_length) * signal_trigger_mult
        
        sell_signal_longStop 
    = (sell_signal_use_close ta.highest(signalClosesell_signal_length) : ta.highest(signalHighsell_signal_length)) - sell_signal_atr
        sell_signal_longStopPrev 
    nz(sell_signal_longStop[1], sell_signal_longStop)
        
    sell_signal_longStop := signalClose[1] > sell_signal_longStopPrev math.max(sell_signal_longStopsell_signal_longStopPrev) : sell_signal_longStop
        
        sell_signal_shortStop 
    = (sell_signal_use_close ta.lowest(signalClosesell_signal_length) : ta.lowest(signalLowsell_signal_length)) + sell_signal_atr
        sell_signal_shortStopPrev 
    nz(sell_signal_shortStop[1], sell_signal_shortStop)
        
    sell_signal_shortStop := signalClose[1] < sell_signal_shortStopPrev math.min(sell_signal_shortStopsell_signal_shortStopPrev) : sell_signal_shortStop
        
        
    var int sell_signal_dir 1
        sell_signal_dir 
    := signalClose sell_signal_shortStopPrev signalClose sell_signal_longStopPrev ? -sell_signal_dir
        
        sell_signal_sellSignal 
    := sell_signal_dir == -and sell_signal_dir[1] == 1
        
        
    // ============================================================================
        // SELL ATR STOP
        // ============================================================================
        
        
    sell_atr_atr ta.atr(sell_atr_length) * stop_atr_mult
        
        sell_atr_longStop 
    = (sell_atr_use_close ta.highest(signalClosesell_atr_length) : ta.highest(signalHighsell_atr_length)) - sell_atr_atr
        sell_atr_longStopPrev 
    nz(sell_atr_longStop[1], sell_atr_longStop)
        
    sell_atr_longStop := signalClose[1] > sell_atr_longStopPrev math.max(sell_atr_longStopsell_atr_longStopPrev) : sell_atr_longStop
        
        sell_atr_shortStop 
    := (sell_atr_use_close ta.lowest(signalClosesell_atr_length) : ta.lowest(signalLowsell_atr_length)) + sell_atr_atr
        sell_atr_shortStopPrev 
    nz(sell_atr_shortStop[1], sell_atr_shortStop)
        
    sell_atr_shortStop := signalClose[1] < sell_atr_shortStopPrev math.min(sell_atr_shortStopsell_atr_shortStopPrev) : sell_atr_shortStop
        
        
    var int sell_atr_dir 1
        sell_atr_dir 
    := signalClose sell_atr_shortStopPrev signalClose sell_atr_longStopPrev ? -sell_atr_dir
        
        sell_atr_buySignal 
    := sell_atr_dir == and sell_atr_dir[1] == -1
        
        
    // ============================================================================
        // SIGNAL STATE MANAGEMENT
        // ============================================================================
        
        
    if not buy_atr_stop_active
            
    if buy_signal_buySignal
                buy_atr_stop_active 
    := true
        
    else
            if 
    buy_atr_sellSignal
                buy_atr_stop_active 
    := false

        
    if not sell_atr_stop_active
            
    if sell_signal_sellSignal
                sell_atr_stop_active 
    := true
        
    else
            if 
    sell_atr_buySignal
                sell_atr_stop_active 
    := false

    // ===========================================================================================================
    // CORE CALCULATIONS
    // ===========================================================================================================

    // AMF Calculations
    amf_line f_calculate_amf(signalCloseamf_lengthamf_fast_lengthamf_slow_lengthamf_smoothing)
    amf_signal f_amf_signal(amf_lineamf_signal_length)

    // Cached ATR
    atr14 ta.atr(14)

    // ALMA calculations for neural network (Use Signal Candles for analysis)
    alma200 ta.alma(signalClosealmaLengthalmaOffsetalmaSigma)
    alma2 ta.alma(signalClosealma2Lengthalma2Offsetalma2Sigma)

    // ===========================================================================================================
    // NEURAL NETWORK
    // ===========================================================================================================

    is_buy_signal buy_signal_buySignal
    is_sell_signal 
    sell_signal_sellSignal

    amf_context 
    f_analyzeAMF(amf_lineamf_signalis_buy_signalis_sell_signalatr14)

    alma_context f_analyzeALMA(alma200alma2is_buy_signalis_sell_signalatr14)

    sr_context f_analyzeSupportResistance(is_buy_signalis_sell_signalatr14signalHighsignalLowsignalClose)

    swing_context f_analyzeSwingStructure(is_buy_signalis_sell_signalsignalHighsignalLow)

    regime_context f_analyzeMarketRegime(is_buy_signalis_sell_signalsignalOpensignalHighsignalLowsignalClose)

    amf_context_normalized f_normalizeInput(amf_contextnormalization_lookbackoutlier_clippingclipping_threshold)
    alma_context_normalized f_normalizeInput(alma_contextnormalization_lookbackoutlier_clippingclipping_threshold)
    sr_context_normalized f_normalizeInput(sr_contextnormalization_lookbackoutlier_clippingclipping_threshold)
    swing_context_normalized f_normalizeInput(swing_contextnormalization_lookbackoutlier_clippingclipping_threshold)
    regime_context_normalized f_normalizeInput(regime_contextnormalization_lookbackoutlier_clippingclipping_threshold)

    signal_score = (is_buy_signal or is_sell_signal) ? 
                   
    f_scoreSignalNormalized(amf_context_normalizedalma_context_normalized
                                         
    sr_context_normalizedswing_context_normalizedregime_context_normalized) : 0.5
    signal_grade 
    f_getSignalGrade(signal_score)
    score_color f_getScoreColor(signal_score)

    // ===========================================================================================================
    // CANDLE PLOTTING
    // ===========================================================================================================

    candleColor isBullishCandle customBuyColor customSellColor

    plotcandle
    (candleType != 'Candlesticks' displayOpen na
               
    candleType != 'Candlesticks' displayHigh na
               
    candleType != 'Candlesticks' displayLow na
               
    candleType != 'Candlesticks' displayClose na
               
    title 'BAR',
               
    color candleType != 'Candlesticks' candleColor na,
               
    wickcolor candleType != 'Candlesticks' candleColor na,
               
    bordercolor candleType != 'Candlesticks' candleColor na)

    // ===========================================================================================================
    // SCALP HELPER SIGNAL PLOTS
    // ===========================================================================================================

    atr_offset signalOffset atr14

    show_buy_signal 
    enable_scalp_helper and buy_signal_buySignal and not buy_atr_stop_active[1]
    show_sell_signal enable_scalp_helper and sell_signal_sellSignal and not sell_atr_stop_active[1]

    label_size signalLabelSize == 'tiny' size.tiny 
                 
    signalLabelSize == 'small' size.small 
                 
    signalLabelSize == 'large' size.large size.normal

    if showScalpLabels and show_buy_signal
        buy_label_text 
    signal_grade
        label
    .new(bar_indexsignalLow atr_offset
                 
    text buy_label_text
                 
    style label.style_label_up
                 
    size label_size
                 
    color score_color
                 
    textcolor color.black)

    if 
    showScalpLabels and show_sell_signal
        sell_label_text 
    signal_grade
        label
    .new(bar_indexsignalHigh atr_offset
                 
    text sell_label_text
                 
    style label.style_label_down
                 
    size label_size
                 
    color score_color
                 
    textcolor color.black)
    /////////////////////////////////////////////////////////////////////

    // Kullanıcı Girişleri
    slow_sar_set input.float(0.3'Slow SAR'minval 0.01maxval 0.3group 'SAR Settings')
    sar_set input.float(0.2'Normal SAR'minval 0.01maxval 0.2group 'SAR Settings')
    fast_sar_set input.float(0.1'Fast SAR'minval 0.01maxval 0.1group 'SAR Settings')
    sar_avg_length input.int(1'Hareketli Ortalama Uzunluğu'minval 1group 'SAR Settings')


    // Hesaplamalar
    // ta.sar(baslangic, artis, maksimum) - sayı küçüldükçe değişim hızı artar
    fast_sar ta.sar(fast_sar_setfast_sar_set0.1)
    sar ta.sar(sar_setsar_set0.1)
    slow_sar ta.sar(slow_sar_setslow_sar_set0.1)

    // Hareketli Ortalama
    sar_avg ta.sma(sarsar_avg_length)

    // Çizimler
    plot(fast_sartitle '1Z'color close fast_sar #00ff0000 : #ffbbba00, style = plot.style_circles, linewidth = 1)
    plot(sartitle '2Z'color close sar #00b80000 : #ff010100, style = plot.style_circles, linewidth = 1)
    plot(slow_sartitle '3Z'color close slow_sar #14571500 : #aa000000, style = plot.style_circles, linewidth = 1)

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

    // Ortak başlangıç değeri
    start 0.01

    // 3 SAR (farklı hızlarda)
    sar1 ta.sar(start0.20.2)
    sar2 ta.sar(start0.30.3)
    sar3 ta.sar(start0.50.5)

    // 4. SAR ve EMA(5) ile yumuşatma
    sar4_raw ta.sar(start11)
    sar4_ema ta.ema(sar4_raw5)

    // SAR4 EMA çizgi rengi: fiyatın üstünde yeşil, altında kırmızı
    sar4_color close sar4_ema color.white color.fuchsia


    plot
    (sar1title '1Y'color close sar1 #00ff0000 : #ffbbba00, style = plot.style_circles, linewidth = 1)
    plot(sar2title '2Y'color close sar2 #00b80000 : #ff010100, style = plot.style_circles, linewidth = 1)
    plot(sar3title '3Y'color close sar3 #14571500 : #aa000000, style = plot.style_circles, linewidth = 1)

    // SAR4 EMA çizgisi (renkli)
    //plot(sar4_ema, title = 'Z', color = sar4_color, style = plot.style_line, linewidth = 2)
    /////////////////////////
    // === SAR'lar
    sar19 ta.sar(0.0.10.1)
    sar59 ta.sar(0.0.10.1)
    sar109 ta.sar(0.0.10.1)

    // === Gerçek eşitlik kontrolü
    equalAll sar19 == sar59 and sar59 == sar109

    sort9 
    = (sar19 sar59 sar109) / 3
    //plot(sort9, title = 'X', color = sar4_color, style = plot.style_stepline, linewidth = 1)
    ////////////////////////
    price7 hl2
    tolerans7 
    0.001

    // === SAR'lar ===
    sar17 ta.sar(0.0010.020.2)
    sar27 ta.sar(0.0010.030.3)
    sar37 ta.sar(0.0010.040.4)


    plot(sar17title '1X'color close sar17 #00ff0000 : #ffbbba00, style = plot.style_circles, linewidth = 1)
    plot(sar27title '2X'color close sar27 #00b80000 : #ff010100, style = plot.style_circles, linewidth = 1)
    plot(sar37title '3X'color close sar37 #14571500 : #aa000000, style = plot.style_circles, linewidth = 1)

    // === SAR yakınlığı kontrolü ===
    yakinsar7 math.abs(sar17 sar27) < tolerans7 or math.abs(sar17 sar37) < tolerans7 or math.abs(sar27 sar37) < tolerans7

    longSignal7 
    yakinsar7 and price7 sar17
    shortSignal7 
    yakinsar7 and price7 sar17

    // === Sinyal üçgenleri ===
    plotshape(longSignal7location location.belowbarstyle shape.triangleupcolor color.fuchsiasize size.tiny)
    plotshape(shortSignal7location location.abovebarstyle shape.triangledowncolor color.fuchsiasize size.tiny)
    //////////////////

    // 5 SAR hesapla
    sar18 ta.sar(0.10.10.1)
    sar28 ta.sar(0.10.30.3)
    sar38 ta.sar(0.10.50.5)
    sar48 ta.sar(0.10.70.7)
    sar58 ta.sar(0.11.01.0)

    // SAR ortalaması ve EMA(3) ile smooth
    sarAvg8 = (sar18 sar28 sar38 sar48 sar58) / 5
    smoothedSar8 
    ta.ema(sarAvg810)

    // EMA(1) (fiyat çizgisi)
    ema18 ta.ema(close1)

    // Çizgiler

    //plot(smoothedSar8, title = 'Y', color = sar4_color, style = plot.style_stepline, linewidth = 1)

    TREND789=(smoothedSar8+sort9+sar4_ema)/3
    plot
    (TREND789title 'TR3'color sar4_colorstyle plot.style_steplinelinewidth 1)

    SAR7 ta.sar(0.040.040.3)
    SAR8 ta.sar(0.030.030.25)
    plot(SAR7title 'TR1'style plot.style_linelinewidth 1color sar4_color)
    plot(SAR8title 'TR2'style plot.style_linelinewidth 1color sar4_color)
    // === SAR sıkışma kontrolü ===
    tolerance22 input.float(0.0005title 'SAR Yakınlık Toleransı')
    sar_near22 math.abs(SAR7 SAR8) < tolerance22
    bgcolor
    (sar_near22 color.new(color.yellow75) : natitle 'SAR Sıkışma Alanı')



    // Sinyaller
    longSignal8 ta.crossover(ema18smoothedSar8// AL
    shortSignal8 ta.crossunder(ema18smoothedSar8// SAT

    // Sinyal üçgenleri
    plotshape(longSignal8title 'AL Sinyali'location location.belowbarstyle shape.triangleupcolor color.limesize size.small)
    plotshape(shortSignal8title 'SAT Sinyali'location location.abovebarstyle shape.triangledowncolor color.redsize size.small)
    /////////////////////
    /////////////////////////////////İMZA AT//////////////////////////////////////////////////

    var table logo table.new(position.bottom_center11)
    if 
    barstate.islast
        table
    .cell(logo00'@yörük@ EĞİTİM ÇALIŞMASIDIR.'text_size size.normaltext_color color.rgb(2182415))
    // === Girişler ===
    uz1 input(1title 'Periyot (lowest/highest)')
    atr1 input(10title 'ATR Periyodu')
    az1 input(1title 'ATR Katsayısı')

    // === Stop seviyeleri ===
    ss1 ta.lowest(uz1) + az1 ta.atr(atr1// üstten takip
    ll1 ta.highest(uz1) - az1 ta.atr(atr1// alttan takip

    // === İlk tanımlamalar ===
    var float ssx1 na
    var float llx1 na
    ssx1 
    := na(ssx1[1]) ? ss1 close ssx1[1] ? ss1 math.min(ss1ssx1[1])
    llx1 := na(llx1[1]) ? ll1 close llx1[1] ? ll1 math.max(ll1llx1[1])

    // === Sinyaller ===
    yunus1 close >= ssx1[1] and close[1] < ssx1[1] ? 0
    yusuf1 
    close <= llx1[1] and close[1] > llx1[1] ? 0

    // === Trend durumu ===
    var int fato1 0
    fato1 
    := fato1 <= and bool(yunus1) ? fato1 >= and bool(yusuf1) ? -fato1

    // === Gösterim ===
    memo1 fato1 llx1 ssx1
    plot
    (memo1title 'STOP'color fato1 color.rgb(255255255100) : color.rgb(22364251100), linewidth 2)

    ///////////////////ATR HESAPLA///////////////////////////////////////////////////////
    var params "Parameters"
    src55 nz(input.source(closetitle "Source"group params))
    len55 input.int(10title "ATR Len"group params)
    multi55 input.float(1.5title "Multi"step 0.25minval 0group params)

    var 
    cols "Colors"
    up_col input.color(color.rgb(255255255100), title "Yükseliş"group cols)
    down_col input.color(color.rgb(22364251100), title "DÜşüş"group cols)
    flat_col input.color(color.rgb(22364251100), title "Flat "inline "3"group cols)

    rope_smoother(float _src55float _threshold) =>

        var 
    float _rope _src55

        _move 
    _src55 _rope //Movement from Rope

        
    _rope += math.max(math.abs(_move) - nz(_threshold), 0) * math.sign(_move//Directional Movement beyond the Threshold
        
        
    [_rope,_rope+_threshold,_rope-_threshold//[Rope, Upper, Lower]

    ///_____________________________________________________________________________________________________________________

    //Calculating Rope
    atr99 ta.atr(len55)*multi55

    [rope,upper,lower] = rope_smoother(src55,atr99)

    //Directional Detection
    var dir89 0

    dir89 
    := rope rope[1] ? rope rope[1] ? -dir89

    if ta.cross(src55,rope)
        
    dir89 := 0

    //Directional Color Assignment    
    col dir89 up_col dir89 down_col flat_col

    //High and Low Output Lines
    var float c_hi na
    var float c_lo na

    //Counters for Accumulating Averages
    var float h_sum 0
    var float l_sum 0
    var int c_count 0

    //Flip-Flop
    var ff 1

    if dir89 == 0

        
    if dir89[1] != 0
            h_sum 
    := 0
            l_sum 
    := 0
            c_count 
    := 0
            ff 
    := ff * -1

        h_sum 
    += upper
        l_sum 
    += lower
        c_count 
    += 1
        c_hi 
    := h_sum/c_count
        c_lo 
    := l_sum/c_count

    ///
    plot(ropelinewidth 2color coltitle "ATR"force_overlay true)
    /////////////////////////////EN HIZLI SARLA BAR RENKLENDİR////////////////////
    // —————————————————————————————————————————
    f_colorNew(_color_transp) =>
        var 
    _r color.r(_color)
        var 
    _g color.g(_color)
        var 
    _b color.b(_color)
        
    color _return color.rgb(_r_g_b_transp)
        
    _return


    //automatic higher timeframe chooser
    f_autoHTF(str) =>
        
    str == '1S' or str == '5S' or str == '10S' or str == '15S' or str == '20S' or str == '30S' or str == '40S' or str == '45S' or str == '50S' '1' str == '1' or str == '2' or str == '3' or str == '4' '5' str == '5' or str == '10' '15' str == '15' or str == '20' '30' str == '30' or str == '45' or str == '50' '60' str == '60' or str == '90' or str == '100' '120' str == '120' or str == '180' '240' str == '240' 'D' str == 'D' 'W' str == 'W' '2W' 'M'
    var string ticker syminfo.tickerid
    var string tfp timeframe.period
    htf1 
    f_autoHTF(tfp)
    htf2 f_autoHTF(htf1)
    htf3 f_autoHTF(htf2)
    htf4 f_autoHTF(htf3)

    f_security(_sym_res_src_rep) =>
        
    request.security(_sym_res_src[not _rep and barstate.isrealtime 0])[_rep or barstate.isrealtime 1]

    //PSAR inputs
    grpin '⚙=====-----'
    grpout '-----=====⚙'
    grpPSAR grpin 'Dual PSAR Options:' grpout
    colorBull 
    input.color(defval color.rgb(3724870), group grpPSARtitle 'Bullish Color'//Light Blue
    colorBear input.color(defval #fc07072f, group = grpPSAR, title = 'Bearish Color') //yellow
    colorWait input.color(defval color.rgb(241191970), group grpPSARtitle 'Wait Color'//grey
    showRecolorCandles input.bool(true'Show Trend Full-Candle Recoloring?'group grpPSARtooltip 'Recolor the full candle including wick and border with trend color.')
    psar_start input.float(defval 0.group grpPSARtitle 'PSAR: Start'minval 0.maxval 2step 0.01)
    psar_accel input.float(defval 0.1group grpPSARtitle 'PSAR: Acceleration  Factor'minval 0.01maxval 2step 0.01)
    psar_maximum input.float(defval 0.9group grpPSARtitle 'PSAR: Extreme Point'minval 0.01maxval 2)


    f_psar() =>
        
    ta.sar(psar_startpsar_accelpsar_maximum)

    psar_ctf f_psar()
    psar_htf f_security(tickerhtf1f_psar(), false)


    longZone psar_ctf low and psar_htf low
    shortZone 
    psar_ctf high and psar_htf high
    waitZone 
    not longZone and not shortZone

    trendSupportColor 
    longZone colorBull shortZone colorBear colorWait
    plotcandle
    (showRecolorCandles open nahighlowclosecolor trendSupportColorwickcolor trendSupportColorbordercolor trendSupportColortitle 'BAR')
    barcolor(trendSupportColor)

    ///////////////////SON BARI ATR İLE OLASILIK HESAPLA///////////////////////
    // Inputs
    length14 input.int(title 'ATR Length'defval 1minval 1)
    tradetype14 input.string(defval 'Long'title 'Trade Type'options = ['Long''Short'])
    takeprofit14 input.float(1'Take Profit Times ATR'minval 0.1)
    stoploss14 input.float(1.6'Stop Loss Times ATR'minval 0.1)
    index14 input(0'Display Index')

    // Functions
    getMA(serieslength14) =>
        
    ta.rma(serieslength14)
    getTV(value) =>
        
    math.round(value 100000) / 100000

    // Variables
    atr148 getMA(ta.tr(true), length14)[index14]
    posTake tradetype14 == 'Long' close[index14] + takeprofit14 atr148 close[index14] - takeprofit14 atr148
    posStop 
    tradetype14 == 'Long' close[index14] - stoploss14 atr148 close[index14] + stoploss14 atr148
    colorTake 
    color.new(color.lime50)
    colorStop color.new(color.red50)
    // Plots
    plotcandle(close[index14], posTakeclose[index14], posTaketitle 'OLST'color index14 == colorTake nabordercolor index14 == colorTake nawickcolor nashow_last 1)
    plotcandle(close[index14], closeposStopposStoptitle 'OLSD'color index14 == colorStop nabordercolor index14 == colorStop nawickcolor nashow_last 1)
    ////////////////10 SAR HESAPLA VE 10NUDA LA VERİRSE ARKA PLANI YEŞİLLENDİR//////////////
    // === PSAR Settings === //
    abh97 0.001
    abh96 
    0.1

    // === Manually defined 10 PSARs === //
    psar132 ta.sar(abh970.001abh96)
    psar232 ta.sar(abh970.002abh96)
    psar332 ta.sar(abh970.003abh96)
    psar432 ta.sar(abh970.004abh96)
    psar532 ta.sar(abh970.005abh96)
    psar632 ta.sar(abh970.006abh96)
    psar732 ta.sar(abh970.007abh96)
    psar832 ta.sar(abh970.008abh96)
    psar932 ta.sar(abh970.009abh96)
    psar1032 ta.sar(abh970.010abh96)

    // === PSAR Trend Alignment Check === //
    allBelow32 psar132 close and psar232 close and psar332 close and psar432 close and psar532 close and
               
    psar632 close and psar732 close and psar832 close and psar932 close and psar1032 close

    allAbove32 
    psar132 close and psar232 close and psar332 close and psar432 close and psar532 close and
               
    psar632 close and psar732 close and psar832 close and psar932 close and psar1032 close

    // === Trend Signal === //
    trendUp32 allBelow32
    trendDown32 
    allAbove32
    trendNeutral32 
    not trendUp32 and not trendDown32

    // === Background Color === //
    bgcolor(trendUp32 color.new(color.green85) : natitle="Up Trend Background")
    //////////////////////////
    //////////////////////////EN HIZLI SAR İLE MTF HESAPLA TABLO YAP/////////////////////////////////////
    start46 input(0.)
    increment46 input(0.001)
    maximum46 input(0.01"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_left :
      
    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)
    /////////////////////////////////////////////////////////////SAR HESAPLAMALARI YAP////////////////////////////
    A111 input(0.)
    B111 input(0.01)
    C111 input(0.1".")
    ABC111 ta.sar(A111B111C111)
    plot(ABC111"@yörük@"style=plot.style_crosscolor=color.yellowlinewidth 2)
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    // === INPUTS === //
    atrLength33 input.int(5title="ATR Period")
    mult33 input.float(1.0title="ATR Multiplier (DES/DİR)")
    desLookback33 input.int(1title="DES/DİR Lookback Period")
    psarConfirmCount33 input.int(6title="Minimum PSAR Sayısı (Sinyal için)")

    // === PSAR Settings === //
    start33 0.01
    max33 
    0.1

    // === 10 PSAR hesapla === //
    psar133 ta.sar(start330.01max33)
    psar233 ta.sar(start330.02max33)
    psar333 ta.sar(start330.03max33)
    psar433 ta.sar(start330.04max33)
    psar533 ta.sar(start330.05max33)
    psar633 ta.sar(start330.06max33)
    psar733 ta.sar(start330.07max33)
    psar833 ta.sar(start330.08max33)
    psar933 ta.sar(start330.09max33)
    psar1033 ta.sar(start330.10max33)

    // === Kaç tanesi fiyatın altında/üstünde? === //
    countBelow33 0
    countBelow33 
    := countBelow33 + (psar133 close 0)
    countBelow33 := countBelow33 + (psar233 close 0)
    countBelow33 := countBelow33 + (psar333 close 0)
    countBelow33 := countBelow33 + (psar433 close 0)
    countBelow33 := countBelow33 + (psar533 close 0)
    countBelow33 := countBelow33 + (psar633 close 0)
    countBelow33 := countBelow33 + (psar733 close 0)
    countBelow33 := countBelow33 + (psar833 close 0)
    countBelow33 := countBelow33 + (psar933 close 0)
    countBelow33 := countBelow33 + (psar1033 close 0)

    countAbove33 10 countBelow33

    // === Trend sinyalleri === //
    trendUp33 countBelow33 >= psarConfirmCount33
    trendDown33 
    countAbove33 >= psarConfirmCount33

    // === DES / DİR === //
    atr33 ta.atr(atrLength33)
    dir33 ta.lowest(desLookback33) + mult33 atr33
    des33 
    ta.highest(desLookback33) - mult33 atr33

    plot
    (dir33title="Direnç"color=color.rgb(22364251100), style=plot.style_linebrlinewidth=2)
    plot(des33title="Destek"color=color.rgb(0187212100), style=plot.style_linebrlinewidth=2)
    ////////


    // === Ayarlar ===
    leftBars47 input(50title 'Pivot Left Bars')
    rightBars47 input(50title 'Pivot Right Bars')
    projBars47 input(50title 'Proj. Bars to the Right')

    // === Pivot Noktaları ===
    ph47 ta.pivothigh(leftBars47rightBars47)
    pl47 ta.pivotlow(leftBars47rightBars47)

    // === Destek/Direnç çizgileri oluştur ===
    if not na(ph47)
        
    line.new(bar_index rightBars47ph47bar_index projBars47ph47color color.redstyle line.style_dashedwidth 2)

    if 
    not na(pl47)
        
    line.new(bar_index rightBars47pl47bar_index projBars47pl47color color.greenstyle line.style_dashedwidth 2)
    /////////////////////////////////////////////////////////// 
    kombine edilmiş kodlar.... denemek isteyene....içinden istediğiniz kısmı silin atın.... şablon niyetine kullanılabilir....

  3.  Alıntı Originally Posted by @yörük@ Yazıyı Oku
    hoşuma giden bir kod....
    denemek isteyene.....

    PHP Code:
    //@version=6
    indicator('Adaptive Parabolic SAR (PSAR) [Loxx]'shorttitle '.'overlay truetimeframe ''timeframe_gaps true)

    //thanks to @Bjorgum
    calcBaseUnit() =>
        
    bool isForexSymbol syminfo.type == 'forex'
        
    bool isYenPair syminfo.currency == 'JPY'
        
    float result isForexSymbol isYenPair 0.01 0.0001 syminfo.mintick
        result

    greencolor 
    #2DD204
    redcolor #D2042D

    _afact(modeinputpersmooth) =>
        
    eff 0.
        seff 
    0.
        len 
    0
        sum 
    0.
        max 
    0.
        min 
    1000000000.
        len 
    := mode == 'Kaufman' math.ceil(per) : math.ceil(math.max(20per))
        for 
    0 to len by 1
            
    if mode == 'Kaufman'
                
    sum := sum math.abs(input[i] - input[1])
                
    sum
            
    else
                
    max := input[i] > max input[i] : max
                min 
    := input[i] < min input[i] : min
                min
        
    if mode == 'Kaufman' and sum != 0
            eff 
    := math.abs(input input[len]) / sum
            eff
        
    else
            if 
    mode == 'Ehlers' and max min 0
                eff 
    := (input min) / (max min)
                
    eff
        seff 
    := ta.ema(effsmooth)
        
    seff

    src 
    input.source(close'Sourse'group 'Basic Settings')
    startAFactor input.float(0.1'Starting Acceleration Factor'step 0.001group 'Basic Settings')
    minStep input.float(0.0'Min Step'step 0.001group 'Basic Settings')
    maxStep input.float(0.2'Max Step'step 0.001group 'Basic Settings')
    maxAFactor input.float(0.2'Max Acceleration Factor'step 0.001group 'Basic Settings')

    hiloMode input.string('On''HiLo Mode'options = ['Off''On'], group 'Advanced Settings')
    adaptMode input.string('Kaufman''Adaptive Mode'options = ['Off''Kaufman''Ehlers'], group 'Advanced Settings')
    adaptSmth input.int(5'Adaptive Smoothing Period'minval 1group 'Advanced Settings')
    filt input.float(0.0'Filter in Pips'group 'Advanced Settings'minval 0)
    minChng input.float(0.0'Min Change in Pips'group 'Advanced Settings'minval 0)
    SignalMode input.string('Only Stops''Signal Mode'options = ['Only Stops''Signals & Stops'], group 'Advanced Settings')

    colorbars input.bool(false'Color bars?'group 'UI Options')

    hVal2 nz(high[2])
    hVal1 nz(high[1])
    hVal0 high
    lowVal2 
    nz(low[2])
    lowVal1 nz(low[1])
    lowVal0 low
    hiprice2 
    nz(high[2])
    hiprice1 nz(high[1])
    hiprice0 high
    loprice2 
    nz(low[2])
    loprice1 nz(low[1])
    loprice0 low

    upSig 
    0.
    dnSig 
    0.
    aFactor 
    0.
    step 
    0.
    trend 
    0.
    upTrndSAR 
    0.
    dnTrndSAR 
    0.
    length 
    maxAFactor 1

    if hiloMode == 'On'
        
    hiprice0 := high
        loprice0 
    := low
        loprice0
    else
        
    hiprice0 := src
        loprice0 
    := hiprice0
        loprice0

    if bar_index == 1
        trend 
    := 1
        hVal1 
    := hiprice1
        hVal0 
    := math.max(hiprice0hVal1)
        
    lowVal1 := loprice1
        lowVal0 
    := math.min(loprice0lowVal1)
        
    aFactor := startAFactor
        upTrndSAR 
    := lowVal0
        dnTrndSAR 
    := 0.
        dnTrndSAR
    else
        
    hVal0 := hVal1
        lowVal0 
    := lowVal1
        trend 
    := nz(trend[1])
        
    aFactor := nz(aFactor[1])
        
    inputs 0.
        inprice 
    src
        
    if adaptMode != 'Off'
            
    if hiloMode == 'On'
                
    inprice := src
                inprice
            
    else
                
    inprice := hiprice0
                inprice
            
    if adaptMode == 'Kaufman'
                
    inputs := inprice
                inputs
            
    else
                if 
    adaptMode == 'Ehlers'
                    
    if nz(upTrndSAR[1]) != 0.
                        inputs 
    := math.abs(inprice nz(upTrndSAR[1]))
                        
    inputs
                    
    else
                        if 
    nz(dnTrndSAR[1]) != 0.
                            inputs 
    := math.abs(inprice nz(dnTrndSAR[1]))
                            
    inputs
            step 
    := minStep _afact(adaptModeinputslengthadaptSmth) * (maxStep minStep)
            
    step
        
    else
            
    step := maxStep
            step

        upTrndSAR 
    := 0.
        dnTrndSAR 
    := 0.
        upSig 
    := 0.
        dnSig 
    := 0.

        
    if nz(trend[1]) > 0
            
    if nz(trend[1]) == nz(trend[2])
                
    aFactor := hVal1 hVal2 nz(aFactor[1]) + step aFactor
                aFactor 
    := aFactor maxAFactor maxAFactor aFactor
                aFactor 
    := hVal1 hVal2 startAFactor aFactor
                aFactor
            
    else
                
    aFactor := nz(aFactor[1])
                
    aFactor

            upTrndSAR 
    := nz(upTrndSAR[1]) + aFactor * (hVal1 nz(upTrndSAR[1]))
            
    upTrndSAR := upTrndSAR loprice1 loprice1 upTrndSAR
            upTrndSAR 
    := upTrndSAR loprice2 loprice2 upTrndSAR
            upTrndSAR
        
    else
            if 
    nz(trend[1]) == nz(trend[2])
                
    aFactor := lowVal1 lowVal2 nz(aFactor[1]) + step aFactor
                aFactor 
    := aFactor maxAFactor maxAFactor aFactor
                aFactor 
    := lowVal1 lowVal2 startAFactor aFactor
                aFactor
            
    else
                
    aFactor := nz(aFactor[1])
                
    aFactor

            dnTrndSAR 
    := nz(dnTrndSAR[1]) + aFactor * (lowVal1 nz(dnTrndSAR[1]))
            
    dnTrndSAR := dnTrndSAR hiprice1 hiprice1 dnTrndSAR
            dnTrndSAR 
    := dnTrndSAR hiprice2 hiprice2 dnTrndSAR
            dnTrndSAR

        hVal0 
    := hiprice0 hVal0 hiprice0 hVal0
        lowVal0 
    := loprice0 lowVal0 loprice0 lowVal0

        
    if minChng 0
            
    if upTrndSAR nz(upTrndSAR[1]) < minChng calcBaseUnit() and upTrndSAR != 0. and nz(upTrndSAR[1]) != 0.
                upTrndSAR 
    := nz(upTrndSAR[1])
                
    upTrndSAR
            
    if nz(dnTrndSAR[1]) - dnTrndSAR minChng calcBaseUnit() and dnTrndSAR != 0. and nz(dnTrndSAR[1]) != 0.
                dnTrndSAR 
    := nz(dnTrndSAR[1])
                
    dnTrndSAR

        dnTrndSAR 
    := trend and dnTrndSAR nz(dnTrndSAR[1]) ? nz(dnTrndSAR[1]) : dnTrndSAR
        upTrndSAR 
    := trend and upTrndSAR nz(upTrndSAR[1]) ? nz(upTrndSAR[1]) : upTrndSAR

        
    if trend and hiprice0 >= dnTrndSAR filt calcBaseUnit()
            
    trend := 1
            upTrndSAR 
    := lowVal0
            upSig 
    := SignalMode == 'Signals & Stops' lowVal0 upSig
            dnTrndSAR 
    := 0.
            aFactor 
    := startAFactor
            lowVal0 
    := loprice0
            hVal0 
    := hiprice0
            hVal0
        
    else if trend and loprice0 <= upTrndSAR filt calcBaseUnit()
            
    trend := -1
            dnTrndSAR 
    := hVal0
            dnSig 
    := SignalMode == 'Signals & Stops' hVal0 dnSig
            upTrndSAR 
    := 0.
            aFactor 
    := startAFactor
            lowVal0 
    := loprice0
            hVal0 
    := hiprice0
            hVal0

    outer 
    upTrndSAR upTrndSAR dnTrndSAR
    colorout 
    outer >= src redcolor greencolor
    plot
    (upTrndSAR upTrndSAR dnTrndSAR"Trend"color coloroutstyle plot.style_stepline_diamondlinewidth 2)

    //barcolor(colorbars ? colorout : na)

    //plotshape(SignalMode == 'Signals & Stops' ? dnSig : na, color = redcolor, textcolor = redcolor, style = shape.triangledown, location = location.abovebar, size = size.small, title = 'Short', text = 'S')
    //plotshape(SignalMode == 'Signals & Stops' ? upSig : na, color = greencolor, textcolor = greencolor, style = shape.triangleup, location = location.belowbar, size = size.small, title = 'Long', text = 'L') 
    Bu sanki spesifik bir kod hocam...
    Altcoin grafiklerinde veya senetlerde ben de benzer bir yöntem kullanıyordum geçmişte.
    Örneğin altcoin için analiz yapıyorsan, BTCUSD'yi, hisse analizi yapıyorsan XU100 endeksini çarpan olarak kullanmak gibi...


    Bu arkadaş da :

    ...

    calcBaseUnit() =>
    bool isForexSymbol = syminfo.type == 'forex'
    bool isYenPair = syminfo.currency == 'JPY'
    float result = isForexSymbol ? isYenPair ? 0.01 : 0.0001 : syminfo.mintick
    result

    ...


    if minChng > 0
    if upTrndSAR - nz(upTrndSAR[1]) < minChng * calcBaseUnit() and upTrndSAR != 0. and nz(upTrndSAR[1]) != 0.
    upTrndSAR := nz(upTrndSAR[1])
    upTrndSAR
    if nz(dnTrndSAR[1]) - dnTrndSAR < minChng * calcBaseUnit() and dnTrndSAR != 0. and nz(dnTrndSAR[1]) != 0.
    dnTrndSAR := nz(dnTrndSAR[1])
    dnTrndSAR


    ...


    if trend < 0 and hiprice0 >= dnTrndSAR + filt * calcBaseUnit()
    trend := 1
    upTrndSAR := lowVal0
    upSig := SignalMode == 'Signals & Stops' ? lowVal0 : upSig
    dnTrndSAR := 0.
    aFactor := startAFactor
    lowVal0 := loprice0
    hVal0 := hiprice0
    hVal0



    benzer bir yöntem kullanmış. JPY çarpanı, JPY ile ilgisi olmayan enstrümanlarda yanıltıcı olabilir.
    "Bence", sanırım, galiba, herhalde...
    Al,sat,tut,yakala,sık,bırak vb. tavsiye için aracı kurumunuzla görüşün.

  4. seçilen sar değeriyle, mtf hesaplamayla...bar renklendirme.....denemek isteyene....

    PHP Code:
    //@version=6
    indicator('..'shorttitle '.'overlay truemax_lines_count 100max_labels_count=100max_boxes_count 100max_bars_back 100)

    // —————————————————————————————————————————
    f_colorNew(_color_transp) =>
        var 
    _r color.r(_color)
        var 
    _g color.g(_color)
        var 
    _b color.b(_color)
        
    color _return color.rgb(_r_g_b_transp)
        
    _return


    //automatic higher timeframe chooser
    f_autoHTF(str) =>
        
    str == '1S' or str == '5S' or str == '10S' or str == '15S' or str == '20S' or str == '30S' or str == '40S' or str == '45S' or str == '50S' '1' str == '1' or str == '2' or str == '3' or str == '4' '5' str == '5' or str == '10' '15' str == '15' or str == '20' '30' str == '30' or str == '45' or str == '50' '60' str == '60' or str == '90' or str == '100' '120' str == '120' or str == '180' '240' str == '240' 'D' str == 'D' 'W' str == 'W' '2W' 'M'
    var string ticker syminfo.tickerid
    var string tfp timeframe.period
    htf1 
    f_autoHTF(tfp)
    htf2 f_autoHTF(htf1)
    htf3 f_autoHTF(htf2)
    htf4 f_autoHTF(htf3)

    f_security(_sym_res_src_rep) =>
        
    request.security(_sym_res_src[not _rep and barstate.isrealtime 0])[_rep or barstate.isrealtime 1]

    //PSAR inputs
    grpin '⚙=====-----'
    grpout '-----=====⚙'
    grpPSAR grpin 'Dual PSAR Options:' grpout
    colorBull 
    input.color(defval color.rgb(243243246), group grpPSARtitle 'Bullish Color'//Light Blue
    colorBear input.color(defval color.rgb(25255), group grpPSARtitle 'Bearish Color'//yellow
    colorWait input.color(defval color.rgb(2411919), group grpPSARtitle 'Wait Color'//grey
    showRecolorCandles input.bool(true'Show Trend Full-Candle Recoloring?'group grpPSARtooltip 'Recolor the full candle including wick and border with trend color.')
    psar_start input.float(defval 0.01group grpPSARtitle 'PSAR: Start'minval 0.maxval 2step 0.01)
    psar_accel input.float(defval 0.01group grpPSARtitle 'PSAR: Acceleration  Factor'minval 0.001maxval 2step 0.01)
    psar_maximum input.float(defval 0.01group grpPSARtitle 'PSAR: Extreme Point'minval 0.01maxval 2)


    f_psar() =>
        
    ta.sar(psar_startpsar_accelpsar_maximum)

    psar_ctf f_psar()
    psar_htf f_security(tickerhtf1f_psar(), false)


    longZone psar_ctf low and psar_htf low
    shortZone 
    psar_ctf high and psar_htf high
    waitZone 
    not longZone and not shortZone

    trendSupportColor 
    longZone colorBull shortZone colorBear colorWait
    //plotcandle(showRecolorCandles ? open : na, high, low, close, color = trendSupportColor, wickcolor = trendSupportColor, bordercolor = trendSupportColor, title = 'BAR')
    barcolor(trendSupportColor)
    /// 

  5.  Alıntı Originally Posted by KısaVade Yazıyı Oku
    Bu sanki spesifik bir kod hocam...
    Altcoin grafiklerinde veya senetlerde ben de benzer bir yöntem kullanıyordum geçmişte.
    Örneğin altcoin için analiz yapıyorsan, BTCUSD'yi, hisse analizi yapıyorsan XU100 endeksini çarpan olarak kullanmak gibi...


    Bu arkadaş da :

    ...

    calcBaseUnit() =>
    bool isForexSymbol = syminfo.type == 'forex'
    bool isYenPair = syminfo.currency == 'JPY'
    float result = isForexSymbol ? isYenPair ? 0.01 : 0.0001 : syminfo.mintick
    result

    ...


    if minChng > 0
    if upTrndSAR - nz(upTrndSAR[1]) < minChng * calcBaseUnit() and upTrndSAR != 0. and nz(upTrndSAR[1]) != 0.
    upTrndSAR := nz(upTrndSAR[1])
    upTrndSAR
    if nz(dnTrndSAR[1]) - dnTrndSAR < minChng * calcBaseUnit() and dnTrndSAR != 0. and nz(dnTrndSAR[1]) != 0.
    dnTrndSAR := nz(dnTrndSAR[1])
    dnTrndSAR


    ...


    if trend < 0 and hiprice0 >= dnTrndSAR + filt * calcBaseUnit()
    trend := 1
    upTrndSAR := lowVal0
    upSig := SignalMode == 'Signals & Stops' ? lowVal0 : upSig
    dnTrndSAR := 0.
    aFactor := startAFactor
    lowVal0 := loprice0
    hVal0 := hiprice0
    hVal0



    benzer bir yöntem kullanmış. JPY çarpanı, JPY ile ilgisi olmayan enstrümanlarda yanıltıcı olabilir.
    "Bence", sanırım, galiba, herhalde...
    haklısın hocam... o yüzden değerlerde oynama yaptım.... x100 için denedim şimdilik....

    bunu...ons..btc gibi farklı kullanmalarını denemek istiyorum....(gerçekten bistin, btc, ons, gramla korelasyonu var mı?)

    (yedekleme olarak şimdilik kalsın)

  6.  Alıntı Originally Posted by @yörük@ Yazıyı Oku
    haklısın hocam... o yüzden değerlerde oynama yaptım.... x100 için denedim şimdilik....

    bunu...ons..btc gibi farklı kullanmalarını denemek istiyorum....

    (yedekleme olarak şimdilik kalsın)
    Eline sağlık üstadım.

    Sonraki kod bende böyle:




    Görüntü şık
    Al,sat,tut,yakala,sık,bırak vb. tavsiye için aracı kurumunuzla görüşün.

  7.  Alıntı Originally Posted by KısaVade Yazıyı Oku
    Eline sağlık üstadım.

    Sonraki kod bende böyle:




    Görüntü şık
    https://www.tradingview.com/x/3eaIRS3N/ bar kalıp kullanılan ve sarlar görüntü

    https://www.tradingview.com/x/IT6wMqdd/ sar döngülü görüntü

    bende böyle gözüküyor...

  8.  Alıntı Originally Posted by KısaVade Yazıyı Oku
    Eline sağlık üstadım.

    Sonraki kod bende böyle:




    Görüntü şık
    denemek istersen... o kodun....kombine edilmiş... farklı versiyonu....

    PHP Code:
    //@version=6
    indicator("combine"shorttitle="."overlay=true,
         
    max_lines_count=400max_boxes_count=50max_labels_count=5)

    // ── Enhanced Inputs
    string GRP1 "Core Pattern Matching"
    string GRP2 "Projection & Smoothing"
    string GRP3 "Quality & Filtering"
    string GRP4 "Visuals"

    int   patLen   input.int(20,   "Pattern Length",      minval=8,  maxval=200group=GRP1)
    int   fLen     input.int(30,   "Forecast Bars",       minval=5,  maxval=300group=GRP1)
    int   depth    input.int(2000"Search Depth",        minval=200,maxval=6000,group=GRP1)
    float minConf  input.float(0.30,"Min Confidence",     minval=0.10,maxval=0.95,step=0.05,group=GRP1)

    string scaling    input.string("Adaptive","Scaling Method"options=["Fixed","Adaptive","Volatility","Z-Score"], group=GRP2)
    string smoothing  input.string("EMA","Projection Smoothing"options=["None","SMA","EMA","Adaptive"], group=GRP2)
    int    smoothLen  input.int(3"Smoothing Length",     minval=2,  maxval=10group=GRP2)

    bool   useQualFilter input.bool(true,  "Enable Quality Filter"group=GRP3)
    float  minVariance   input.float(0.001,"Min Pattern Variance"minval=0.0001maxval=0.01step=0.0001group=GRP3)
    int    trendCheck    input.int(5,      "Trend Coherence Bars"minval=3maxval=15group=GRP3)

    bool showProj   input.bool(true,  "Show Projection"group=GRP4)
    bool showBands  input.bool(true,  "Show Bands",      group=GRP4)
    bool showZones  input.bool(true,  "Show Zones",      group=GRP4)

    // Enhanced colors
    color upColor   input.color(#00FF88, "Uptrend (Green)",   group=GRP4)
    color dnColor   input.color(#FF4444, "Downtrend (Red)",   group=GRP4)
    color swColor   input.color(#FFAA00, "Sideways (Yellow)", group=GRP4)

    // ── Enhanced Data buffers
    var array<floatprices = array.new<float>()
    var array<
    int>   times  = array.new<int>()
    var array<
    floathighs  = array.new<float>()
    var array<
    floatlows   = array.new<float>()

    // handles
    var array<linehProj = array.new<line>()
    var array<
    linehBand = array.new<line>()
    var array<
    box>  hBox  = array.new<box>()
    var 
    label       hLbl  na

    // ── Enhanced Helper Functions
    safeDiv(float nfloat dfloat fb) => 
        
    == 0.0 fb d

    // Enhanced cosine similarity with multiple normalization methods
    cosineSim(array<floatarrint startAint startBint lenstring method "returns") =>
        array<
    floatseqA = array.new<float>()
        array<
    floatseqB = array.new<float>()
        
        
    // Extract sequences
        
    for 0 to len 1
            
    array.push(seqA, array.get(arrstartA i))
            array.
    push(seqB, array.get(arrstartB i))
        
        
    // Normalize based on method
        
    if method == "returns"
            
    // Return-based normalization (original method)
            
    float dp 0.0na2 0.0nb2 0.0
            
    for 1 to len 1
                float a0 
    = array.get(seqA1)
                
    float a1 = array.get(seqAk)
                
    float b0 = array.get(seqB1)
                
    float b1 = array.get(seqBk)
                
    float ra safeDiv(a1 a0a00.0)
                
    float rb safeDiv(b1 b0b00.0)
                
    dp  := dp ra rb
                na2 
    := na2 ra ra
                nb2 
    := nb2 rb rb
            float den 
    math.sqrt(na2) * math.sqrt(nb2)
            
    den == 0.0 0.0 dp den
        
    else
            
    // Z-score normalization for more stable comparison
            
    float meanA 0.0meanB 0.0
            
    for 0 to len 1
                meanA 
    := meanA + array.get(seqAi)
                
    meanB := meanB + array.get(seqBi)
            
    meanA := meanA len
            meanB 
    := meanB len
            
            float stdA 
    0.0stdB 0.0
            
    for 0 to len 1
                float diffA 
    = array.get(seqAi) - meanA
                float diffB 
    = array.get(seqBi) - meanB
                stdA 
    := stdA diffA diffA
                stdB 
    := stdB diffB diffB
            stdA 
    := math.sqrt(stdA len)
            
    stdB := math.sqrt(stdB len)
            
            if 
    stdA == 0.0 or stdB == 0.0
                0.0
            
    else
                
    float dp 0.0na2 0.0nb2 0.0
                
    for 0 to len 1
                    float za 
    = (array.get(seqAi) - meanA) / stdA
                    float zb 
    = (array.get(seqBi) - meanB) / stdB
                    dp  
    := dp za zb
                    na2 
    := na2 za za
                    nb2 
    := nb2 zb zb
                float den 
    math.sqrt(na2) * math.sqrt(nb2)
                
    den == 0.0 0.0 dp den

    // Pattern quality validation
    patternQuality(array<floatarrint startint len) =>
        if 
    start or start len >= array.size(arr)
            
    0.0
        
    else
            
    // Calculate variance to ensure pattern has sufficient movement
            
    float mean 0.0
            
    for 0 to len 1
                mean 
    := mean + array.get(arrstart i)
            
    mean := mean len
            
            float variance 
    0.0
            
    for 0 to len 1
                float diff 
    = array.get(arrstart i) - mean
                variance 
    := variance diff diff
            variance 
    := variance len
            
            
    // Check trend coherence - avoid choppy patterns
            
    int trendChanges 0
            bool lastUp 
    false
            bool firstCheck 
    true
            
    for 1 to len 1
                bool currentUp 
    = array.get(arrstart i) > array.get(arrstart 1)
                if 
    not firstCheck and currentUp != lastUp
                    trendChanges 
    := trendChanges 1
                lastUp 
    := currentUp
                firstCheck 
    := false
            
            float coherence 
    1.0 - (trendChanges / (len 1))
            
    math.sqrt(variance) * coherence

    // Enhanced smoothing function
    smoothProjection(array<floatprojstring methodint length) =>
        array<
    floatsmoothed = array.new<float>()
        
    int size = array.size(proj)
        
        if 
    method == "None"
            
    for 0 to size 1
                
    array.push(smoothed, array.get(proji))
        else if 
    method == "SMA"
            
    for 0 to size 1
                float sum 
    0.0
                int count 
    0
                int start 
    math.max(0length 1)
                for 
    start to i
                    sum 
    := sum + array.get(projj)
                    
    count := count 1
                
    array.push(smoothedsum count)
        else if 
    method == "EMA"
            
    float alpha 2.0 / (length 1.0)
            array.
    push(smoothed, array.get(proj0))
            for 
    1 to size 1
                float prev 
    = array.get(smoothed1)
                
    float curr = array.get(proji)
                array.
    push(smoothedalpha curr + (1.0 alpha) * prev)
        else 
    // Adaptive
            
    for 0 to size 1
                float sum 
    0.0
                float weightSum 
    0.0
                int adaptiveLen 
    length length
                
    for 0 to adaptiveLen 1
                    float weight 
    1.0 / (1.0)
                    
    sum := sum + array.get(projj) * weight
                    weightSum 
    := weightSum weight
                
    array.push(smoothedsum weightSum)
        
        
    smoothed

    // Sample std of returns (enhanced for volatility scaling)
    retStd(array<floatarrint startint len) =>
        if 
    start or start len >= array.size(arr)
            
    0.0
        
    else
            
    float s 0.0
            float c 
    0.0
            
    for start 1 to start len
                float r 
    safeDiv(array.get(arrk) - array.get(arr1), array.get(arr1), 0.0)
                
    := r
                c 
    := 1.0
            float m 
    safeDiv(sc0.0)
            
    float ss 0.0
            
    for start 1 to start len
                float r 
    safeDiv(array.get(arrk) - array.get(arr1), array.get(arr1), 0.0)
                
    float d m
                ss 
    := ss d
            math
    .sqrt(safeDiv(ssmath.max(1.01.0), 0.0))

    // Array min/max over a range
    arrMin(array<floataint startint len) =>
        
    float m na
        int stop 
    math.min(start len, array.size(a))
        if 
    start >= and start < array.size(a)
            for 
    start to stop 1
                float v 
    = array.get(ai)
                
    := na(m) ? math.min(mv)
        
    m

    arrMax
    (array<floataint startint len) =>
        
    float m na
        int stop 
    math.min(start len, array.size(a))
        if 
    start >= and start < array.size(a)
            for 
    start to stop 1
                float v 
    = array.get(ai)
                
    := na(m) ? math.max(mv)
        
    m

    // Draw cleanup
    cleanup() =>
        for 
    l in hProj
            line
    .delete(l)
        array.
    clear(hProj)
        for 
    l in hBand
            line
    .delete(l)
        array.
    clear(hBand)
        for 
    b in hBox
            box
    .delete(b)
        array.
    clear(hBox)
        if 
    not na(hLbl)
            
    label.delete(hLbl)

    // Keep arrays bounded
    keep(int maxKeep) =>
        while array.
    size(prices) > maxKeep
            
    array.shift(prices)
            array.
    shift(times)
            array.
    shift(highs)
            array.
    shift(lows)

    // ── Ingest
    array.push(pricesclose)
    array.
    push(times,  time)
    array.
    push(highs,  high)
    array.
    push(lows,   low)
    keep(depth patLen fLen 50)

    // ── Enhanced Engine
    if barstate.islastconfirmedhistory and array.size(prices) > patLen fLen
        cleanup
    ()
        
    hLbl := na

        int N 
    = array.size(prices)
        
    int recentStart patLen
        int searchEnd   
    patLen fLen
        int searchStart 
    math.max(0searchEnd depth)

        
    float bestScore = -1.0
        int   bestIdx   
    0
        float bestQuality 
    0.0

        
    // Enhanced pattern search with quality filtering
        
    for searchStart to searchEnd
            
    // Check pattern quality first if filtering enabled
            
    float quality useQualFilter patternQuality(pricesipatLen) : 1.0
            
            
    if quality >= minVariance
                string simMethod 
    scaling == "Z-Score" "zscore" "returns"
                
    float s cosineSim(pricesrecentStartipatLensimMethod)
                
                
    // Weight similarity by pattern quality
                
    float weightedScore * (0.7 0.3 math.min(quality / (minVariance 10.0), 1.0))
                
                if 
    weightedScore bestScore
                    bestScore 
    := weightedScore
                    bestIdx 
    := i
                    bestQuality 
    := quality

        bool have 
    bestScore >= minConf
        
    if have
            
    // Enhanced scaling methods
            
    float cur      = array.get(prices1)
            
    float baseHist = array.get(pricesbestIdx patLen 1)
            
    float scale    1.0
            
            
    if scaling == "Fixed"
                
    scale := 1.0
            
    else if scaling == "Adaptive"
                
    scale := safeDiv(curbaseHist1.0)
            else if 
    scaling == "Volatility"
                
    float cstd retStd(pricespatLenpatLen)
                
    float hstd retStd(pricesbestIdxpatLen)
                
    float vr   safeDiv(cstdhstd1.0)
                
    scale := safeDiv(curbaseHist1.0) * vr
            
    else // Z-Score
                // Z-score based scaling for more stable projections
                
    float histMean 0.0
                
    for 0 to patLen 1
                    histMean 
    := histMean + array.get(pricesbestIdx i)
                
    histMean := histMean patLen
                
                float histStd 
    0.0
                
    for 0 to patLen 1
                    float diff 
    = array.get(pricesbestIdx i) - histMean
                    histStd 
    := histStd diff diff
                histStd 
    := math.sqrt(histStd patLen)
                
                
    float currentStd ta.stdev(closepatLen)
                
    scale := safeDiv(currentStdhistStd1.0)

            
    // Build raw projection path
            
    array<floatrawProj = array.new<float>()
            for 
    0 to fLen 1
                float src 
    = array.get(pricesbestIdx patLen k)
                
    float val cur + (src baseHist) * scale
                
    array.push(rawProjval)

            
    // Apply smoothing to projection
            
    array<floatproj smoothProjection(rawProjsmoothingsmoothLen)
            
            
    // Enhanced confidence bands
            
    float baseVol ta.atr(20)
            
    float confMult = (1.0 bestScore) * 2.0 + (1.0 bestQuality / (minVariance 20.0)) * 1.0
            
            
    array<floatup = array.new<float>()
            array<
    floatdn = array.new<float>()
            for 
    0 to array.size(proj) - 1
                float val 
    = array.get(proji)
                
    float dynamicConf baseVol confMult * (1.0 0.1 fLen// Expanding confidence
                
    array.push(upval dynamicConf)
                array.
    push(dnval dynamicConf)

            
    // Directional analysis with smoothed values
            
    float last = array.get(proj, array.size(proj) - 1)
            
    float pct  safeDiv(last curcur0.0) * 100.0
            color lnColor 
    math.abs(pct) < 0.3 swColor : (pct upColor dnColor)

            
    // Draw enhanced projection
            
    if showProj
                line l0 
    line.new(bar_indexcurbar_index 1, array.get(proj0), color=lnColorwidth=3)
                array.
    push(hProjl0)
                for 
    0 to array.size(proj) - 2
                    line lk 
    line.new(bar_index 1, array.get(projk),
                                       
    bar_index 2, array.get(proj1),
                                       
    color=lnColorwidth=3)
                    array.
    push(hProjlk)

            
    // Enhanced bands
            
    if showBands
                color bc 
    color.new(lnColor70)
                
    line u0 line.new(bar_indexcur baseVol confMultbar_index 1, array.get(up0), color=bcstyle=line.style_dashed)
                
    line d0 line.new(bar_indexcur baseVol confMultbar_index 1, array.get(dn0), color=bcstyle=line.style_dashed)
                array.
    push(hBandu0)
                array.
    push(hBandd0)
                for 
    0 to array.size(up) - 2
                    line uu 
    line.new(bar_index 1, array.get(upk), bar_index 2, array.get(up1), color=bcstyle=line.style_dashed)
                    
    line dd line.new(bar_index 1, array.get(dnk), bar_index 2, array.get(dn1), color=bcstyle=line.style_dashed)
                    array.
    push(hBanduu)
                    array.
    push(hBanddd)

            
    // Zones (unchanged)
            
    if showZones
                float hLow  
    arrMin(lows,  bestIdxpatLen)
                
    float hHigh arrMax(highsbestIdxpatLen)
                if 
    not na(hLow) and not na(hHigh)
                    
    box b1 box.new(array.get(timesbestIdx), hLow, array.get(timesbestIdx patLen 1), hHigh,
                                     
    xloc=xloc.bar_timebgcolor=color.new(lnColor85), border_color=color.new(lnColor55))
                    array.
    push(hBoxb1)
                
    float cLow  ta.lowest(low,  patLen)
                
    float cHigh ta.highest(high,patLen)
                
    box b2 box.new(bar_index patLen 1cLowbar_indexcHigh,
                                 
    bgcolor=color.new(color.blue85), border_color=color.new(color.blue55))
                array.
    push(hBoxb2)

            
    // Enhanced label with quality metrics
            
    string tname math.abs(pct) < 0.3 "SIDEWAYS" : (pct "BULLISH" "BEARISH")
            
    string emoji math.abs(pct) < 0.3 "↔"        : (pct "▲"      "▼")
            
    string lbl   str.format("{0} ENHANCED PROJECTION ({1})\nConfidence: {2,number,#.0}% | Quality: {3,number,#.0}%\nTarget: {4,number,#.##} | Change: {5,number,#.1}%\nMethod: {6} | Smoothing: {7}",
                                      
    emojitnamebestScore*100.0bestQuality*10000.0lastpctscalingsmoothing)
            
    hLbl := label.new(bar_index math.round(array.size(proj)/2.0), math.max(curlast) + ta.atr(10),
                              
    lblcolor=color.new(lnColor20), textcolor=color.white,
                              
    style=label.style_label_downsize=size.normal)

    ////////////////////
    // UI Options for Auto Trend Detection and No Signal in Sideways Market
    autoTrendDetection input.bool(truetitle 'Auto Trend Detection')
    noSignalSideways input.bool(truetitle 'No Signal in Sideways Market')


    // Color variables
    upTrendColor color.white
    neutralColor 
    #90bff9
    downTrendColor color.blue


    // Source
    source input(defval closetitle 'Source')


    // Sampling Period - Replaced with Sniper Machine
    period input.int(defval 9minval 1title 'Sniper Machine Period')


    // Trend Master - Replaced with Sniper Machine
    multiplier input.float(defval 3.0minval 0.1title 'Sniper Machine Multiplier')


    // Smooth Average Range
    smoothRange(xtm) =>
        
    adjustedPeriod 1
        avgRange 
    ta.ema(math.abs(x[1]), t)
        
    smoothRange ta.ema(avgRangeadjustedPeriod) * m
        smoothRange
    smoothedRange 
    smoothRange(sourceperiodmultiplier)


    // Trend Filter
    trendFilter(xr) =>
        
    filtered x
        filtered 
    := nz(filtered[1]) ? nz(filtered[1]) ? nz(filtered[1]) : nz(filtered[1]) ? nz(filtered[1]) : r
        filtered
    filter 
    trendFilter(sourcesmoothedRange)


    // Filter Direction
    upCount 0.0
    upCount 
    := filter filter[1] ? nz(upCount[1]) + filter filter[1] ? nz(upCount[1])
    downCount 0.0
    downCount 
    := filter filter[1] ? nz(downCount[1]) + filter filter[1] ? nz(downCount[1])


    // Colors
    filterColor upCount upTrendColor downCount downTrendColor neutralColor


    // Buy/Sell Signals - Adapted from Clear Trend Logic
    trendUp upCount // Equivalent to REMA_up in Clear Trend
    newBuySignal trendUp and not trendUp[1] and barstate.isconfirmed
    newSellSignal 
    not trendUp and trendUp[1] and barstate.isconfirmed


    initialCondition 
    0
    initialCondition 
    := newBuySignal newSellSignal ? -initialCondition[1]
    longSignal newBuySignal and initialCondition[1] == -1
    shortSignal 
    newSellSignal and initialCondition[1] == 1


    // Alerts and Signals
    plotshape(longSignaltitle 'Buy Signal'text '🚀'textcolor #000000, style = shape.labelup, size = size.small, location = location.belowbar, color = #fae10400) // Bright yellow for Buy
    plotshape(shortSignaltitle 'Sell Signal'text '🚨'textcolor #000000, style = shape.labeldown, size = size.small, location = location.abovebar, color = #fb020200) // Bright red for Sell


    alertcondition(longSignaltitle 'Buy alert on Sniper Machine'message 'Buy alert on Sniper Machine')
    alertcondition(shortSignaltitle 'Sell alert on Sniper Machine'message 'Sell alert on Sniper Machine')
    ///////////////

    // Inputs
    src     input.source(hlc3"Source")
    emaLen  input.int(15"Center EMA")
    spreadN input.int(200"Spread Length")
    kMult   input.float(3.0"Multiplier"step=0.1)

    upCol   input.color(color.rgb(25155), "Up Color")
    dnCol   input.color(color.rgb(26,221,127), "Down Color")

    // Core calculation
    mid    ta.ema(srcemaLen)
    spread ta.sma(high lowspreadN)
    uBand  mid kMult spread
    lBand  
    mid kMult spread

    // Crawl bands
    var float upC na
    var float dnC na
    upC 
    := na(upC[1]) ? uBand : (src[1] > upC[1] ? uBand math.min(uBandupC[1]))
    dnC := na(dnC[1]) ? lBand : (src[1] < dnC[1] ? lBand math.max(lBanddnC[1]))

    // Direction & guide
    var int dir na
    var float guide na
    if na(dir[1])
        
    dir := 1
    else
        
    dir := guide[1] == upC[1] ? (src upC ? -1) : (src dnC : -1)
    guide := dir == upC dnC

    // Background zone fill
    bgcolor(dir==color.new(upCol85) : color.new(dnCol85), title="Trend Zone")

    // Guide line
    plot(guide"Trs"color=color.new(dir==1?upCol:dnCol0), linewidth=1)

    // Signals
    trendUpbn    not na(dir[1]) and dir == -and dir[1] != -1
    trendDownbn  
    not na(dir[1]) and dir == 1  and dir[1] != 1
    pbUp       
    dir==-and high >= upC
    pbDown     
    dir==1  and low <= dnC

    dist 
    0.25 spread 
    filteredPbUp   
    pbUp   and (high upC <= dist)
    filteredPbDown pbDown and (dnC low <= dist)

    firstPbUp   filteredPbUp   and not filteredPbUp[1]
    firstPbDown filteredPbDown and not filteredPbDown[1]

    // ATR for vertical spacing of signals
    atrVal ta.atr(14)
    upY   low 15 atrVal
    downY 
    high 10 atrVal

    // Plot BUY/SELL arrows as labels for vertical spacing
    //if trendUpbn
        //label.new(bar_index, upY, text="BUY", style=label.style_triangleup, color=dnCol, textcolor=color.white, size=size.small, yloc=yloc.price)

    //if trendDownbn
        //label.new(bar_index, downY, text="SELL", style=label.style_triangledown, color=upCol, textcolor=color.white, size=size.small, yloc=yloc.price)

    // Pullback dots
    //plotshape(firstPbUp,   style=shape.circle, location=location.belowbar, color=color.new(dnCol,0), size=size.small)
    //plotshape(firstPbDown, style=shape.circle, location=location.abovebar, color=color.new(upCol,0), size=size.small)
    //////////////////////

    // --- User Inputs ---
    // NEW: Added the "20/20 Profile (Ultra-Safe)" option.
    profile input.string('20/20 Profile (Ultra-Safe)''Select Profile'options = ['20/20 Profile (Ultra-Safe)''16/16 Profile (Safe)''12/12 Profile (Balanced)''8/8 Profile (Aggressive)''Custom'], group 'Grid Calculation')

    // These inputs are now only used when "Custom" is selected.
    customRangePercent input.float(6.3title 'Custom Range as % of Price'group 'Grid Calculation')
    customGridCount input.int(12title 'Custom Grid Count'group 'Grid Calculation')

    // Style Inputs
    gridColor input.color(color.new(color.gray60), title 'Grid Line Color'group 'Line Style')
    gridWidth input.int(1title 'Grid Line Width'minval 1maxval 5group 'Line Style')
    gridStyleString input.string('Dotted'title 'Grid Line Style'options = ['Solid''Dashed''Dotted'], group 'Line Style')

    // --- Variable Declarations ---
    var array<linegridLines = array.new_line()
    var array<
    labelpriceLabels = array.new_label()
    var 
    float finalRangePercent 0.0
    var int finalGridCount 0

    // --- Logic to select parameters based on profile ---
    if profile == '20/20 Profile (Ultra-Safe)'
        
    finalRangePercent := 10.5
        finalGridCount 
    := 20
        finalGridCount
    else if profile == '16/16 Profile (Safe)'
        
    finalRangePercent := 8.4
        finalGridCount 
    := 16
        finalGridCount
    else if profile == '12/12 Profile (Balanced)'
        
    finalRangePercent := 6.3
        finalGridCount 
    := 12
        finalGridCount
    else if profile == '8/8 Profile (Aggressive)'
        
    finalRangePercent := 4.2
        finalGridCount 
    := 8
        finalGridCount
    else // Custom
        
    finalRangePercent := customRangePercent
        finalGridCount 
    := customGridCount
        finalGridCount

    // --- Helper Function ---
    getLineStyle(styleString) =>
        
    styleString == 'Solid' line.style_solid styleString == 'Dashed' line.style_dashed line.style_dotted

    // --- Drawing Logic ---
    if barstate.islast
        
    // Delete old lines and labels
        
    if array.size(gridLines) > 0
            
    for lineId in gridLines
                line
    .delete(lineId)
            array.
    clear(gridLines)
        if array.
    size(priceLabels) > 0
            
    for labelId in priceLabels
                label
    .delete(labelId)
            array.
    clear(priceLabels)

        
    // Main Calculation
        
    currentPrice close
        totalRange 
    currentPrice * (finalRangePercent 100)
        
    halfRange totalRange 2.0
        upperLimit 
    currentPrice halfRange
        lowerLimit 
    currentPrice halfRange
        selectedGridStyle 
    getLineStyle(gridStyleString)

        
    // Draw Lines & Labels
        
    array.push(gridLinesline.new(bar_index 99upperLimitbar_indexupperLimitxloc xloc.bar_indexextend extend.nonecolor color.new(color.green20), width 2))
        array.
    push(gridLinesline.new(bar_index 99lowerLimitbar_indexlowerLimitxloc xloc.bar_indexextend extend.nonecolor color.new(color.red20), width 2))
        if 
    finalGridCount 1
            stepSize 
    totalRange finalGridCount
            
    for 1 to finalGridCount 1 by 1
                gridLevel 
    lowerLimit stepSize
                
    array.push(gridLinesline.new(bar_index 99gridLevelbar_indexgridLevelxloc xloc.bar_indexextend extend.nonecolor gridColorwidth gridWidthstyle selectedGridStyle))
        array.
    push(priceLabelslabel.new(bar_indexupperLimittext str.tostring(upperLimitformat.mintick), xloc xloc.bar_indexcolor color.new(color.green70), textcolor color.whitestyle label.style_label_left))
        array.
    push(priceLabelslabel.new(bar_indexlowerLimittext str.tostring(lowerLimitformat.mintick), xloc xloc.bar_indexcolor color.new(color.red70), textcolor color.whitestyle label.style_label_left))
    ///////////////////////////////// 

Sayfa 347/351 İlkİlk ... 247297337345346347348349 ... SonSon

Yer İmleri

Yer İmleri

Gönderi Kuralları

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