Sayfa 213/276 İlkİlk ... 113163203211212213214215223263 ... SonSon
Arama sonucu : 2208 madde; 1,697 - 1,704 arası.

Konu: Tradingview

  1. z score ile sade tasarım....
    PHP Code:
      // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © Steversteves

    //@version=5
    indicator("Z-Score"overlay=truemax_labels_count 500)

    lengthInput input.int(50"Length"minval 2)
    // Calculating High Z Score

    ta.sma(closelengthInput)
    ta.stdev(closelengthInput)
    = (close a) / 



    // Highest and Lowest

    highz ta.highest(clengthInput)

    lowz ta.lowest(clengthInput

    // Condition Alerts

    var wait 0

    wait 
    := wait 1

    if (<= lowz) and (wait 30)
        
    wait := 10
        label
    .new(x=bar_indexy=hightext="sat"size size.tinycolor=color.rgb(24777))
        
    alert("sat tepe "+syminfo.tickeralert.freq_once_per_bar)
        

    if (
    >= highz) and (wait 30)
        
    wait := 10
        label
    .new(x=bar_indexy=hightext="al"size size.tinycolor=color.rgb(6624811))
        
    alert("al ralli "+syminfo.tickeralert.freq_once_per_bar)

    // Colors

    color bear color.new(color.orange0
    color bull color.new(color.lime0

    bool overbought >= 
    bool oversold 
    <= -

    brcolor 
    overbought bear oversold bull na

    //barcolor(brcolor)
    //////////////////////////
    Length22 input(50)
    stddevs input(1.69)
    src22 close

    basis 
    ta.ema(src22Length22)

    zscore = (src22-basis)/ta.stdev(src22Length22)

    diff math.abs(src22 basis)
    absZscore math.abs(zscore)
    bounds diff absZscore stddevs
    upper 
    basis bounds
    lower 
    basis bounds

    zscoreColor 
    zscore 0.0 zscore >= zscore[1] ? zscore >= stddevs color.blue color.green color.new(color.green70) : zscore <= zscore[1] ? zscore <= -stddevs color.blue color.red color.new(color.red70)

    plot(ta.ema(upper5), title="Upper "linewidth=2)
    //plot(ta.ema(basis, 5), title="Median", color=color.new(color.white, 60), linewidth=2)
    plot(ta.ema(lower5), title="Lower "linewidth=2

    https://www.tradingview.com/x/Yy4GFVZx/
    16.07.2024 - 10.12.2024

  2. sar stratejisi...
    PHP Code:
      //@version=5
    strategy(title='Parabolic SAR Strategy (on close) [QuantNomad]'shorttitle='SAR Strategy [QN]'overlay=true)

    start input(0.02)
    increment input(0.02)
    maximum input(0.2)
    entry_bars input(1title='Entry on Nth trend bar')

    psar 0.0  // PSAR
    af 0.0  // Acceleration Factor
    trend_dir 0  // Current direction of PSAR
    ep 0.0  // Extreme point
    trend_bars 0

    sar_long_to_short 
    trend_dir[1] == and close <= psar[1]  // PSAR switches from long to short
    sar_short_to_long trend_dir[1] == -and close >= psar[1]  // PSAR switches from short to long

    trend_change barstate.isfirst[1] or sar_long_to_short or sar_short_to_long

    // Calculate trend direction
    trend_dir := barstate.isfirst[1] and close[1] > open[1] ? barstate.isfirst[1] and close[1] <= open[1] ? -sar_long_to_short ? -sar_short_to_long nz(trend_dir[1])

    trend_bars := sar_long_to_short ? -sar_short_to_long trend_dir == nz(trend_bars[1]) + trend_dir == -nz(trend_bars[1]) - nz(trend_bars[1])

    // Calculate  Acceleration Factor
    af := trend_change start trend_dir == and high ep[1] or trend_dir == -and low ep[1] ? math.min(maximumaf[1] + increment) : af[1]

    // Calculate extreme point
    ep := trend_change and trend_dir == high trend_change and trend_dir == -low trend_dir == math.max(ep[1], high) : math.min(ep[1], low)

    // Calculate PSAR
    psar := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change ep[1] : trend_dir == psar[1] + af * (ep psar[1]) : psar[1] - af * (psar[1] - ep)

    plot(psarstyle=plot.style_crosscolor=trend_dir == color.green color.redlinewidth=2)

    // Strategy 
    strategy.entry('Long'strategy.longwhen=trend_bars == entry_bars)
    strategy.entry('Short'strategy.shortwhen=trend_bars == -entry_bars
    16.07.2024 - 10.12.2024

  3. sar...
    PHP Code:
      // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © LonesomeTheBlue

    //@version=5
    indicator('Parabolic SAR''SAR'overlay=true)

    start input.float(title='Start'defval=0.02step=0.001)
    increment input.float(title='Increment'defval=0.02step=0.001)
    maximum input.float(title='Max Value'defval=0.2step=0.01)
    putlabel input(title='Put Labels'defval=true)
    colup input.color(title='Colors'defval=color.limeinline='col')
    coldn input.color(title=''defval=color.redinline='col')

    int trend 0
    float sar 
    0.0
    float ep 
    0.0
    float af 
    0.0

    trend 
    := nz(trend[1])
    ep := nz(ep[1])
    af := nz(af[1])
    sar := sar[1]

    if 
    trend == and not na(high[1])
        
    trend := high >= high[1] or low >= low[1] ? : -1
        sar 
    := trend low[1] : high[1]
        
    ep := trend high[1] : low[1]
        
    af := start
        af
    else
        
    nextsar sar
        
    if trend 0
            
    if high[1] > ep
                ep 
    := high[1]
                
    af := math.min(maximumaf increment)
                
    af

            nextsar 
    := sar af * (ep sar)
            
    nextsar := math.min(math.min(low[1], low[2]), nextsar)

            
    //Reversal
            
    if nextsar low
                trend 
    := -1
                nextsar 
    := ep
                ep 
    := low
                af 
    := start
                af
        
    else
            if 
    low[1] < ep
                ep 
    := low[1]
                
    af := math.min(maximumaf increment)
                
    af

            nextsar 
    := sar af * (ep sar)
            
    nextsar := math.max(math.max(high[1], high[2]), nextsar)

            
    //Reversal
            
    if nextsar high
                trend 
    := 1
                nextsar 
    := ep
                ep 
    := high
                af 
    := start
                af
        sar 
    := nextsar
        sar

    plot
    (sartitle='Parabolic SAR'color=trend colup coldnlinewidth=2style=plot.style_circles)

    alertcondition(ta.change(trend) > 0title='PSAR Trend UP'message='PSAR Trend UP')
    alertcondition(ta.change(trend) < 0title='PSAR Trend DOWN'message='PSAR Trend DOWN')

    if 
    ta.change(trend) > and putlabel
        label
    .new(bar_indexsartext=str.tostring(math.round_to_mintick(sar)), color=colupstyle=label.style_label_upsize=size.tiny)
    if 
    ta.change(trend) < and putlabel
        label
    .new(bar_indexsartext=str.tostring(math.round_to_mintick(sar)), color=coldnstyle=label.style_label_downsize=size.tiny
    16.07.2024 - 10.12.2024

  4. sar...
    PHP Code:
      //@version=5
    indicator('Kozlod - Parabolic SAR Strategy Alerts'overlay=true)

    // Inputs
    start input(0.02)
    increment input(0.02)
    maximum input(0.2)

    // Calculation Parabolic SAR
    psar ta.sar(startincrementmaximum)

    // Signals
    psar_long high[1] < psar[2] and high >= psar[1]
    psar_short low[1] > psar[2] and low <= psar[1]

    // Plot PSAR
    plotshape(psarlocation=location.absolutestyle=shape.crosssize=size.tinycolor=low <= psar[1] and not psar_long color.green color.red)

    // Plot Signals
    plotshape(psar_longtitle='PSAR Long'text='PSAR Long'style=shape.arrowuplocation=location.belowbarcolor=color.new(color.blue0))
    plotshape(psar_shorttitle='PSAR Short'text='PSAR Short'style=shape.arrowdownlocation=location.abovebarcolor=color.new(color.red0))

    // Alerts
    alertcondition(psar_long'PSAR Long''PSAR Long')
    alertcondition(psar_short'PSAR Short''PSAR Short'
    16.07.2024 - 10.12.2024

  5. atr sar...
    PHP Code:
      //@version=5
    strategy(title='ATR Parabolic SAR Strategy [QuantNomad]'shorttitle='ATR PSAR Strategy [QN]'overlay=truedefault_qty_type=strategy.percent_of_equitydefault_qty_value=100)

    atr_length input(14)
    start input(0.02)
    increment input(0.02)
    maximum input(0.2)
    entry_bars input(1title='Entry on Nth trend bar')

    atr ta.atr(atr_length)

    atr := na(atr) ? ta.tr atr

    psar 
    0.0  // PSAR
    af 0.0  // Acceleration Factor
    trend_dir 0  // Current direction of PSAR
    ep 0.0  // Extreme point
    trend_bars 0

    sar_long_to_short 
    trend_dir[1] == and close <= psar[1]  // PSAR switches from long to short
    sar_short_to_long trend_dir[1] == -and close >= psar[1]  // PSAR switches from short to long

    trend_change barstate.isfirst[1] or sar_long_to_short or sar_short_to_long

    // Calculate trend direction
    trend_dir := barstate.isfirst[1] and close[1] > open[1] ? barstate.isfirst[1] and close[1] <= open[1] ? -sar_long_to_short ? -sar_short_to_long nz(trend_dir[1])

    trend_bars := sar_long_to_short ? -sar_short_to_long trend_dir == nz(trend_bars[1]) + trend_dir == -nz(trend_bars[1]) - nz(trend_bars[1])

    // Calculate  Acceleration Factor
    af := trend_change start trend_dir == and high ep[1] or trend_dir == -and low ep[1] ? math.min(maximumaf[1] + increment) : af[1]

    // Calculate extreme point
    ep := trend_change and trend_dir == high trend_change and trend_dir == -low trend_dir == math.max(ep[1], high) : math.min(ep[1], low)

    // Calculate PSAR
    psar := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change ep[1] : trend_dir == psar[1] + af atr psar[1] - af atr

    plot
    (psarstyle=plot.style_crosscolor=trend_dir == color.green color.redlinewidth=2)


    // Strategy 
    strategy.entry('Long'strategy.longwhen=trend_bars == entry_bars)
    strategy.entry('Short'strategy.shortwhen=trend_bars == -entry_bars
    16.07.2024 - 10.12.2024

  6. sar döngülerde...
    aynı değerleri farklı periyotlarda döndürme yerine....
    test edilen farklı değerleri...
    periyotlara uygulayıp....

    periyodu döngülemek....

    örneğin...
    15 dak için belirlenmiş..... https://www.tradingview.com/x/IE3WwZNs/

    5 dak için belirlenmiş.... https://www.tradingview.com/x/zw064I5D/

    1 dakka için belirlenmiş... https://www.tradingview.com/x/gREnusrx/

    şimdi bu döngüler periyotlar için aynı renk olsa...

    1 dakkalık beyaz, 5 dakkalık sarı, 15 dakkalık yeşil gibi misal...

    ve bu olay... tek bir kodun içine yazılsa....

    mtf olmadığı için grafikte bozulma olmaz....

    1-5-15 içinde bütün görülmüş olur.....

    bu fikri denemek lazım....


    ya bu kodla https://tr.tradingview.com/v/fg33yCjb/

    ya da https://tr.tradingview.com/v/Zv6fowwF/ bu kodla

    çalışarak... deneyelim bakalım....
    16.07.2024 - 10.12.2024

  7.  Alıntı Originally Posted by @yörük@ Yazıyı Oku
    sar döngülerde...
    aynı değerleri farklı periyotlarda döndürme yerine....
    test edilen farklı değerleri...
    periyotlara uygulayıp....

    periyodu döngülemek....

    örneğin...
    15 dak için belirlenmiş..... https://www.tradingview.com/x/IE3WwZNs/

    5 dak için belirlenmiş.... https://www.tradingview.com/x/zw064I5D/

    1 dakka için belirlenmiş... https://www.tradingview.com/x/gREnusrx/

    şimdi bu döngüler periyotlar için aynı renk olsa...

    1 dakkalık beyaz, 5 dakkalık sarı, 15 dakkalık yeşil gibi misal...

    ve bu olay... tek bir kodun içine yazılsa....

    mtf olmadığı için grafikte bozulma olmaz....

    1-5-15 içinde bütün görülmüş olur.....

    bu fikri denemek lazım....


    ya bu kodla https://tr.tradingview.com/v/fg33yCjb/

    ya da https://tr.tradingview.com/v/Zv6fowwF/ bu kodla

    çalışarak... deneyelim bakalım....
    deneyince sonuçlar şöyle....
    1 dakka için kullanılan değerler ve beyaz renkle....


    5 dakka için sarı renkle....


    1 ve 5 dakka beraber ise...


    15 dakka fuşya renkle...


    1-5 ve 15 dakkanın beraber görünümleri ise







    sar ile dip tepe sinyalleri konunca kırılımlara istinaden...

    her periyotta iş gören bir tasarım oldu....

    periyot seçmek ise kişinin kendi yatırım anlayışına bağlı kalmış oldu....

    sadelik içinde diğerlerini gizleyip...istersek değerler kalır...
    15 dakkalık fusya ...

    görüntüyü belli ediyor....

    dikkat ederseniz....
    dağınık başlama trendi zayıf....
    aynı yerden toplu başlama trendin gücünü ölçmüş gibi oluyor....
    https://www.tradingview.com/x/QuBHv3Iv/
    https://www.tradingview.com/x/6Ah0hwmu/
    https://www.tradingview.com/x/oADdgtIA/
    https://www.tradingview.com/x/4pZ1uSIk/
    https://www.tradingview.com/x/QIrEiRyH/
    https://www.tradingview.com/x/FLdn5Vqp/

    1 ve 5 dakkalık gizlenirse......
    ama değerler kalırsa....
    değerler destekler...dirençler....stop olarak kullanılabileceği gibi.....
    sarların başlangıç ve bitiş noktaları ise trend çizgileri veya kanal gibi olur....
    https://www.tradingview.com/x/S1t4H5cf/
    https://www.tradingview.com/x/PCXMQEnB/
    https://www.tradingview.com/x/gQEqKEZb/
    https://www.tradingview.com/x/WA7QPVVM/
    https://www.tradingview.com/x/9khbCtlM/
    https://www.tradingview.com/x/YGzZUcHL/
    Son düzenleme : @yörük@; 16-07-2023 saat: 14:16.
    16.07.2024 - 10.12.2024

  8. yedeklemeler....

    PHP Code:
     // //////////////////////trend hesaplama kısmı////////////////////
    //@version=5

    indicator('Average Interpercentile Range AIR Supertrend','---'overlay=truemax_labels_count 500format=format.price)

    // Moving Averages Types
    var string SMA      'Simple Moving Average'
    var string EMA      'Exponential Moving Average'
    var string WMA      'Weighted Moving Average'
    var string VWMA     'Volume Weighted Moving average'
    var string ALMA     'Arnaud Legoux Moving Average'
    var string JURIK    'Jurik Moving Average'
    var string T3       'Tillson T3 Moving Average'
    var string RSIMA    'RSI Moving Average'
    var string MEDIAN   'Median'
    var string SS        'Super Smoother Moving Average'
    var string HANN       'Ehlers Hann Moving Average'

    src                 input.source(hl2title 'Source'inline '1')
    period              input.int(title 'Length'defval 5inline '1')
    multiplier          input.float(title 'Multiplier'step 0.1defval 3.3inline '1')

    var 
    string GRP_RF   '══════ Range mix ══════'
    atrActive           input.bool(true'ATR,'inline='42'group=GRP_RF)
    atrMult             input.float(0.3'Mult'step=0.1inline='42'group=GRP_RF)
    atr_move            input.string(T3'MA'options=[SMAEMAWMAVWMAALMAJURIKT3RSIMAMEDIANSSHANN], group=GRP_RFinline='42'

    airActive           input.bool(true'AIR,'inline='44'group=GRP_RF)
    airMult             input.float(0.6'Mult'step=0.1inline='44'group=GRP_RF)
    air_move            input.string(T3'MA'options=[SMAEMAWMAVWMAALMAJURIKT3RSIMAMEDIANSSHANN], group=GRP_RFinline='44'
    spacer              input.int(16'%'inline='44'group=GRP_RF)

    var 
    string GRP_MA   'Global MA Settings'
    inputAlmaOffset_T   input.float(defval 0.86title "Alma Offset"step 0.01inline '1a'group GRP_MA)
    inputAlmaSigma_T    input.int(defval 3title "... Sigma"inline '1a'group GRP_MA)

    phase_T             input.int(defval 2title "Jurik Phase"step 1inline '1j'group GRP_MA)
    power_T             input.float(defval 0.9title "... Power"step 0.1inline '1j'group GRP_MA)

    fac_t3_T            input.float(0step 0.1title 'Tillson T3 Volume Factor'inline '1t'group GRP_MA)

    var 
    string GRP_UI   '══════ UI ══════'
    up_                 input.color(#4caf50, '', inline = '2a', group = GRP_UI)
    dn_                 input.color(#ff5252, '', inline = '2a', group = GRP_UI)

    bkgrnd              input.bool(title 'Fill On/Off ?'defval trueinline='f'group GRP_UI)
    fader               input.int(75'Fade'inline 'f'group GRP_UI)

    bar_it              input.bool(true'Color candles On/Off ?'inline 'f1'group GRP_UI)
    fader_c             input.int(39'Fade'inline 'f1'group GRP_UI)

    // ===========================================================================================================
    //          Functions
    // ===========================================================================================================

    // @function Jurik Moving Average - TradingView: Moving Averages
    Jurik(srcsimple int lenjurik_phasejurik_power) =>
        
    phaseRatio_l jurik_phase < -100 0.5 jurik_phase 100 2.5 jurik_phase 100 1.5
        beta_l 
    0.45 * (len 1) / (0.45 * (len 1) + 2)
        
    alpha_l math.pow(beta_ljurik_power)
        
    jma_l 0.0
        e0_l 
    0.0
        e0_l 
    := (alpha_l) * src alpha_l nz(e0_l[1])
        
    e1_l 0.0
        e1_l 
    := (src e0_l) * (beta_l) + beta_l nz(e1_l[1])
        
    e2_l 0.0
        e2_l 
    := (e0_l phaseRatio_l e1_l nz(jma_l[1])) * math.pow(alpha_l2) + math.pow(alpha_l2) * nz(e2_l[1])
        
    jma_l := e2_l nz(jma_l[1])

    // @function T3 MA from Tilson3Average © KioseffTrading
    t(srcxa1_t3) =>
        
    y1 ta.ema(src,x)
        
    y2 ta.ema(y1x)
        
    y3 ta.ema(y2x)
        
    y4 ta.ema(y3x)
        
    y5 ta.ema(y4x)
        
    y6 ta.ema(y5x)
        
    = -a1_t3 math.pow(a1_t3,2)
        
    v2 math.pow(a1_t3,2) + math.pow(a1_t3,3)
        
    v3 = -math.pow(a1_t32) - a1_t3 math.pow(a1_t33)
        
    v4 a1_t3 a1_t3 math.pow(a1_t32) + math.pow(a1_t32)
        
    v1 y6 v2 y5 v3 y4 v4 y3
        v1

    // Super Smoother Function 
    ss(SeriesPeriod) =>  // Super Smoother Function
        
    var PI 2.0 math.asin(1.0)
        var 
    SQRT2 math.sqrt(2.0)
        
    lambda PI SQRT2 Period
        a1 
    math.exp(-lambda)
        
    coeff2 2.0 a1 math.cos(lambda)
        
    coeff3 = -math.pow(a12.0)
        
    coeff1 1.0 coeff2 coeff3
        filt1 
    0.0
        filt1 
    := coeff1 * (Series nz(Series[1])) * 0.5 coeff2 nz(filt1[1]) + coeff3 nz(filt1[2])
        
    filt1

    // Hann Window Smoothing – Credits to @cheatcountry
    doHannWindow(float _seriesfloat _hannWindowLength) =>
        
    sum 0.0coef 0.0
        
    for 1 to _hannWindowLength
            cosine 
    math.cos(math.pi / (_hannWindowLength 1))
            
    sum := sum + (cosine nz(_series[1]))
            
    coef := coef cosine
        h 
    coef != sum coef 0

    // Choose MA type
    MA_Calc(_data_lenMAOption) =>
        
    value 
              
    MAOption == SMA ta.sma(_data_len) : 
              
    MAOption == EMA ta.ema(_data_len) :
              
    MAOption == WMA ta.wma(_data_len) : 
              
    MAOption == VWMA ta.vwma(_data_len) : 
              
    MAOption == ALMA ta.alma(_data_leninputAlmaOffset_TinputAlmaSigma_T) :
              
    MAOption == JURIK Jurik(_data_lenphase_Tpower_T) : 
              
    MAOption == T3 t(_data_lenfac_t3_T) :
              
    MAOption == RSIMA ta.rma(_data_len) :
              
    MAOption == MEDIAN ta.median(_data_len) :
              
    MAOption == SS ss(_data_len) :
              
    MAOption == HANN doHannWindow(_data_len) :
          
    na

    ipr_array
    (lendnnyuppy) =>
        
    float[]   hiArray   =   array.new_float (0)
        
    float[]   loArray   =   array.new_float (0)
        
    float[]   cmArray   =   array.new_float (0)

        for 
    0 to len 1
            
    array.push  (hiArrayhigh[i])
            array.
    push  (loArraylow[i])
            array.
    push  (cmArrayhlcc4[i])

        
    hlArray     =   array.concat (hiArrayloArray)
        
    hlcmArray   =   array.concat (hlArraycmArray)
        
        
    q1          =   array.percentile_linear_interpolation (hlcmArraydnny)
        
    q3          =   array.percentile_linear_interpolation (hlcmArrayuppy)

        
    iqr = (q3 q1) / 2

    // =================================================================================================
    //                                  Calculations
    // =================================================================================================

    atrFactor   atrActive atrMult MA_Calc(ta.tr(true), periodatr_move)                             : 0
    airFactor   
    airActive airMult MA_Calc(ipr_array(periodspacer100 spacer), periodair_move) : 0

    blender 
    nz(atrFactor) + nz(airFactor)

    ipr_supertrend(sourcelenmulti) =>
        
    up source multi blender
        up1 
    nz(up[1], up)
        
    up := close[1] > up1 math.max(upup1) : up
        dn 
    source multi blender
        dn1 
    nz(dn[1], dn)
        
    dn := close[1] < dn1 math.min(dndn1) : dn
        trend 
    1
        trend 
    := nz(trend[1], trend)
        
    trend := trend == -and close dn1 trend == and close up1 ? -trend
        
    [updntrend]

    [
    upperlowersupertrend] = ipr_supertrend(srcperiodmultiplier

    // =================================================================================================
    //                                  Plots
    // =================================================================================================

    upPlot          plot(supertrend == upper natitle='+++'style=plot.style_linebrlinewidth=2color=color.new(up_100))
    buySignal       supertrend == and supertrend[1] == -1
    dnPlot          
    plot(supertrend == na lowertitle='---'style=plot.style_linebrlinewidth=2color=color.new(dn_100))
    sellSignal      supertrend == -and supertrend[1] == 1

    plotshape
    (buySignal upper natitle='Uptrend Begins'location=location.absolutestyle=shape.circlesize=size.smallcolor=color.new(up_0))
    plotshape(sellSignal lower natitle='Downtrend Begins'location=location.absolutestyle=shape.circlesize=size.smallcolor=color.new(dn_0))

    midPlot         plot(ohlc4title ''style plot.style_circlesdisplay display.none)
    //fill(midPlot, upPlot, title = 'Uptrend Fill', color = bkgrnd ? color.new(up_, fader) : na)
    //fill(midPlot, dnPlot, title = 'Downtrend Fill', color = bkgrnd ? color.new(dn_, fader) : na)

    color_b         supertrend == up_ dn_
    barcolor
    (bar_it color.new(color_bfader_c) : na)

    // =================================================================================================
    //                                  Alerts
    // =================================================================================================

    alertcondition(buySignaltitle='.Supertrend Buy 🟢'message='Supertrend Buy 🟢')
    alertcondition(sellSignaltitle='.Supertrend Sell 🔴'message='Supertrend Sell 🔴')
    changeCond      supertrend != supertrend[1]
    alertcondition(changeCondtitle='Supertrend Direction Change 🟢/🔴'message='Supertrend has changed direction 🟢/🔴')


    //-----------------------------------------------------------------------------------------------------------------------------------------------------------------
    //Settings
    //-----------------------------------------------------------------------------{
    length88 input.int(200'Length'minval 2)
    mult88   input.float(6.'Factor'minval 0step .5)
    tf     input.timeframe('''Timeframe')
    src88    input(close'Source')

    //-----------------------------------------------------------------------------}
    //Function
    //-----------------------------------------------------------------------------{
    pred_ranges(length88mult88)=>
        var 
    avg src88
        
    var hold_atr 0.

        atr 
    nz(ta.atr(length88)) * mult88
            
        avg 
    := src88 avg atr avg atr 
          
    avg src88 atr avg atr 
          
    avg
            
        hold_atr 
    := avg != avg[1] ? atr hold_atr
            
        
    [avg hold_atr 2avg hold_atravgavg hold_atravg hold_atr 2]

    //-----------------------------------------------------------------------------}
    //Calculation
    //-----------------------------------------------------------------------------{
    [prR2
      
    prR1
      
    avg
      
    prS1
      
    prS2] = request.security(syminfo.tickeridtfpred_ranges(length88mult88))

    //-----------------------------------------------------------------------------}
    //Plots
    //-----------------------------------------------------------------------------{
    plot_pru2  plot(prR2'+2'avg != avg[1] ? na #fa071b00)
    plot_pru1  plot(prR1'+1'avg != avg[1] ? na #fa071b00)
    plot_pravg plot(avg '0'avg != avg[1] ? na #f3f706)
    plot_prl1  plot(prS1'-1'avg != avg[1] ? na #04f8cf00)
    plot_prl2  plot(prS2'-2'avg != avg[1] ? na #05fcd300)

    //Fills
    //fill(plot_pru2, plot_pru1, avg != avg[1] ? na : color.new(#f23645, 95))
    //fill(plot_prl1, plot_prl2, avg != avg[1] ? na : color.new(#089981, 95))

    //-----------------------------------------------------------------------------}
    // Custom cosh function
    cosh(float x) =>
        (
    math.exp(x) + math.exp(-x)) / 2

    // Custom acosh function
    acosh(float x) =>
        
    na math.log(math.sqrt(1))

    // Custom sinh function
    sinh(float x) =>
        (
    math.exp(x) - math.exp(-x)) / 2

    // Custom asinh function
    asinh(float x) =>
        
    math.log(math.sqrt(1))

    // Custom inverse tangent function
    atan(float x) =>
        
    math.pi math.atan(x)

    // Chebyshev Type I Moving Average
    chebyshevI(float srcint lenfloat ripple) =>
        
    0.
        b 
    0.
        g 
    0.
        chebyshev 
    0.
        
        a 
    := cosh(len acosh(/ (ripple)))
        
    := sinh(len asinh(ripple))
        
    := (b) / (b)
        
    chebyshev := (g) * src nz(chebyshev[1])
        
    chebyshev

    bool_to_float
    (bool source) =>
        
    source 0

    ema
    (source)=>
        var 
    float ema 0.0
        
    var int count 0
        count 
    := nz(count[1]) + 1
        ema 
    := (1.0 2.0 / (count 1.0)) * nz(ema[1]) + 2.0 / (count 1.0) * source
        ema

    atan2
    (yx) =>
        var 
    float angle 0.0
        
    if 0
            angle 
    := math.atan(x)
        else
            if 
    and >= 0
                angle 
    := math.atan(x) + math.pi
            
    else
                if 
    and 0
                    angle 
    := math.atan(x) - math.pi
                
    else
                    if 
    == and 0
                        angle 
    := math.pi 2
                    
    else
                        if 
    == and 0
                            angle 
    := -math.pi 2
        angle

    degrees
    (float source) =>
        
    source 180 math.pi

    tra
    ()=>
        
    atr ema(ta.tr)
        
    slope = (close close[10]) / (atr 10)
        
    angle_rad atan2(slope1)
        
    degrees degrees(angle_rad)
        
    source ta.sma((degrees high low), 2)

    mats(sourcelength) =>
        
    smooth 0.
        higher_high 
    math.max(math.sign(ta.change(ta.highest(length))), 0)
        
    lower_low math.max(math.sign(ta.change(ta.lowest(length)) * -1), 0)
        
    time_constant math.pow(ta.sma(bool_to_float(higher_high or lower_low), length), 2)
        
    smooth := nz(smooth[1] + time_constant * (source smooth[1]), source)

        
    wilders_period length 1

        atr 
    math.abs(nz(smooth[1]) - smooth)
        
    ma_atr ta.ema(atrwilders_period)
        
    delta_fast_atr ta.ema(ma_atrwilders_period) * length 0.4

        result 
    0.0
        
    if smooth nz(result[1])
            if 
    smooth delta_fast_atr result[1]
                
    result := result[1]
            else
                
    result := smooth delta_fast_atr
        
    else
            if 
    smooth delta_fast_atr result[1]
                
    result := result[1]
            else
                
    result := smooth delta_fast_atr

        
    // Return
        
    result

    length 
    input.int(30"Length"2)
    up_color input.color(color.rgb(2139250), ""inline "color")
    down_color input.color(color.rgb(2144252), ""inline "color")
    enable_glow input.bool(true"Enable Glow"inline "color")

    mats mats(tra(), length)

    atr ta.atr(length)

    colour ta.sma(close2) > mats up_color down_color

    atr_10 
    ema(ta.tr) / 2

    alpha 
    color.new(color.black100)

    max mats atr_10
    min 
    mats atr_10

    center 
    plot(mats"!!!"coloureditable true)
    //plot(mats, "Moving Average Trend Sniper", color.new(colour, 70), 2, editable = true)
    //plot(mats, "Moving Average Trend Sniper", color.new(colour, 80), 3, editable = true)
    //plot(mats, "Moving Average Trend Sniper", color.new(colour, 90), 4, editable = true)

    //top = plot(enable_glow ? max : na, "Moving Average Trend Sniper", alpha)
    //bottom = plot(enable_glow ? min : na, "Moving Average Trend Sniper", alpha)

    //fill(top, center, top_value =  max, bottom_value = mats, bottom_color = color.new(colour, 75), top_color = alpha, editable = true)
    //fill(center, bottom, top_value =  mats, bottom_value = min, bottom_color = alpha, top_color = color.new(colour, 75), editable = true) 

    PHP Code:
    //@version=5
    indicator("Z-Score"overlaytruescale=scale.none)

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                                                            Tooltips                                                                                 ///
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    t1 "Determines the Length of Z-Score Assessment. Defaults to a 75 lookback period" 
    t2 "Determines the length of the SMA if the user selects Show SMA. Default is 75, but for a more responsive SMA you can reduce it to 14. Optional."
    t3 "Shows the probability zones in colour." 
    t4 "Will Display a summarized Z-Table." 
    t5 "Display's the SMA."  

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                                                            User Inputs                                                                              ///
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    len input.int(75"Lookback Length"tooltip=t1)
    smalen input.int(75"SMA Length"tooltip=t2
    probfill input.bool(false"Distribution Probaiblity Fills"tooltip=t3
    showztable input.bool(true"Show Z-Table"tooltip=t4
    showsma input.bool(false"Show SMA"tooltip=t5

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                                                            Z-Score/SMA Calculations                                                                  ///
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    = (close ta.sma(closelen)) / ta.stdev(closelen

    cl_sma ta.sma(closelen
    cl_sd ta.stdev(closelen

    // SMA 
    var float z_sma 0.0 

    if showsma 
        z_sma 
    := ta.sma(zsmalen

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                                                           Colours                                                                                  ///
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    color red color.red 
    color green 
    color.green 
    color orange 
    color.orange 
    color yellow 
    color.yellow 
    color labelcolor 
    color.new(color.white100
    color gray color.new(color.gray25
    color white color.white 
    // Colour for Probability Distribution 
    color greenfill color.new(color.green75
    color yellowfill color.new(color.yellow75
    color redfill color.new(color.red75


    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                                                            Logical Assessments                                                                      ///
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    bool zero_one >= and 
    bool one_two 
    >= and 2.01 
    bool two_three 
    >= and 3.01 
    bool three 
    >= 
    bool zero 
    >= 0.99 and <= -0.99 
    bool neg_zero_one 
    and > -
    bool neg_one_two 
    <= -and > -
    bool neg_two_three 
    <= -and > -
    bool neg_three 
    <= -
    falling 
    ta.falling(z_sma3
    rising ta.rising(z_sma3


    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                                                         Plots                                                                                        ///
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //color z_color_plot = z > 0 ? green : z <= 0 ? red : orange 
    plot(z"Z-Score"color=color.rgb(7617579100) : <= color.rgb(2558282100) : orangestyle=plot.style_line
    //plot(z_sma, "Z-SMA", color=showsma ? white : labelcolor, linewidth=2) 

    neutral 
    onesd 

    twosd 

    threesd 

    neg_onesd 
    = -
    neg_twosd 
    = -
    neg_threesd 
    = -

    //a = plot(neutral, color=greenfill)  
    //b = plot(onesd, color=yellowfill)  
    //c = plot(twosd, color=redfill) 
    //d = plot(threesd, color=redfill)  
    //e = plot(neg_onesd, color=greenfill)  
    //f = plot(neg_twosd, color=yellowfill) 
    //g = plot(neg_threesd, color=redfill) 

    //fill(a, b, color=probfill ? greenfill : na) 
    //fill(b, c, color=probfill ? yellowfill : na) 
    //fill(c, d, color=probfill ? redfill : na) 
    //fill(a, e, color=probfill ? greenfill : na) 
    //fill(e, f, color=probfill ? yellowfill : na) 
    //fill(f, g, color=probfill ? redfill : na) 

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                                                           Price Level Calculations                                                                  ///
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    neutral_price = (cl_sma) + (cl_sd
    onesd_price = (cl_sma) + (cl_sd
    twosd_price = (cl_sma) + (cl_sd
    threesd_price = (cl_sma) + (cl_sd
    neg_onesd_price = (cl_sma) + (-cl_sd
    neg_twosd_price = (cl_sma) + (-cl_sd
    neg_threesd_price = (cl_sma) + (-cl_sd

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                                                            Line Plots                                                                              ///
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    var label neutral_price_line na 
    var label onesd_price_line na
    var label twosd_price_line na 
    var label threesd_price_line na 
    var label neg_onesd_price_line na 
    var label neg_twosd_price_line na 
    var label neg_threesd_price_line na


    if bar_index >= 75 
        label
    .delete(neutral_price_line
        
    label.delete(onesd_price_line
        
    label.delete(twosd_price_line)
        
    label.delete(threesd_price_line
        
    label.delete(neg_onesd_price_line
        
    label.delete(neg_twosd_price_line)
        
    label.delete(neg_threesd_price_line
        
    neutral_price_line := label.new(bar_indexy=neutraltext=str.tostring(math.round(neutral_price,2)), color=labelcolorstyle=label.style_label_lefttextcolor color.whitesize=size.normaltextalign text.align_right)
        
    onesd_price_line := label.new(bar_index 5onesdstr.tostring(math.round(onesd_price,2)), color=labelcolorstyle=label.style_label_lefttextcolor color.whitesize=size.normaltextalign text.align_right
        
    twosd_price_line := label.new(bar_index 5twosdstr.tostring(math.round(twosd_price,2)), color=labelcolorstyle=label.style_label_lefttextcolor color.whitesize=size.normaltextalign text.align_right
        
    threesd_price_line := label.new(bar_index 5threesdstr.tostring(math.round(threesd_price,2)), color=labelcolorstyle=label.style_label_lefttextcolor color.whitesize=size.normaltextalign text.align_right
        
    neg_onesd_price_line := label.new(bar_index 5neg_onesdstr.tostring(math.round(neg_onesd_price,2)), color=labelcolorstyle=label.style_label_lefttextcolor color.whitesize=size.normaltextalign text.align_right
        
    neg_twosd_price_line := label.new(bar_index 5neg_twosdstr.tostring(math.round(neg_twosd_price,2)), color=labelcolorstyle=label.style_label_lefttextcolor color.whitesize=size.normaltextalign text.align_right
        
    neg_threesd_price_line := label.new(bar_index 5neg_threesdstr.tostring(math.round(neg_threesd_price,2)), color=labelcolorstyle=label.style_label_lefttextcolor color.whitesize=size.normaltextalign text.align_right


    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///                                                            Z-Table                                                                                 ///
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    var ztable table.new(position.bottom_center103bgcolor color.white

    if 
    showztable 
        
    // Z-Score / Columns 
        
    table.cell(ztable11text="Z-Score:"bgcolor color.whitetext_color color.black
        
    table.cell(ztable21text "-3"bgcolor neg_three gray whitetext_color=color.black
        
    table.cell(ztable31text="-2"bgcolor neg_two_three gray whitetext_color color.black
        
    table.cell(ztable41text="-1"bgcolor neg_zero_one gray whitetext_color=color.black
        
    table.cell(ztable51text="0"bgcolorzero gray whitetext_color=color.black
        
    table.cell(ztable61text="1"bgcolor=zero_one gray whitetext_color=color.black
        
    table.cell(ztable71text="2"bgcolor=two_three gray whitetext_color=color.black
        
    table.cell(ztable81text="3"bgcolor=three gray whitetext_color=color.black
        
    // Probability / Rows 
        
    table.cell(ztable12text="Probability:"bgcolor color.whitetext_color color.black
        
    table.cell(ztable22text "0.0013"bgcolor redtext_color=color.black
        
    table.cell(ztable32text="0.0228"bgcolor yellowtext_color color.black
        
    table.cell(ztable42text="0.1600"bgcolor greentext_color=color.black
        
    table.cell(ztable52text="0.5000"bgcolor=greentext_color=color.black
        
    table.cell(ztable62text="0.8500"bgcolor=greentext_color=color.black
        
    table.cell(ztable72text="0.9800"bgcolor=yellowtext_color=color.black
        
    table.cell(ztable82text="0.9998"bgcolor=redtext_color=color.black

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

    //@version=5
    indicator("Predictive Ranges [LuxAlgo]""***"overlay true)
    //------------------------------------------------------------------------------
    //Settings
    //-----------------------------------------------------------------------------{
    length input.int(200'Length'minval 2)
    mult   input.float(6.'Factor'minval 0step .5)
    tf     input.timeframe('''Timeframe')
    src    input(close'Source')

    //-----------------------------------------------------------------------------}
    //Function
    //-----------------------------------------------------------------------------{
    pred_ranges(lengthmult)=>
        var 
    avg src
        
    var hold_atr 0.

        atr 
    nz(ta.atr(length)) * mult
            
        avg 
    := src avg atr avg atr 
          
    avg src atr avg atr 
          
    avg
            
        hold_atr 
    := avg != avg[1] ? atr hold_atr
            
        
    [avg hold_atr 2avg hold_atravgavg hold_atravg hold_atr 2]

    //-----------------------------------------------------------------------------}
    //Calculation
    //-----------------------------------------------------------------------------{
    [prR2
      
    prR1
      
    avg
      
    prS1
      
    prS2] = request.security(syminfo.tickeridtfpred_ranges(lengthmult))

    //-----------------------------------------------------------------------------}
    //Plots
    //-----------------------------------------------------------------------------{
    plot_pru2  plot(prR2'+2'avg != avg[1] ? na #fa071b)
    plot_pru1  plot(prR1'+1'avg != avg[1] ? na #fa071b)
    plot_pravg plot(avg '0'avg != avg[1] ? na #f3f706)
    plot_prl1  plot(prS1'-1'avg != avg[1] ? na #04f8d0)
    plot_prl2  plot(prS2'-2'avg != avg[1] ? na #05fcd2)

    //Fills
    //fill(plot_pru2, plot_pru1, avg != avg[1] ? na : color.new(#f23645, 95))
    //fill(plot_prl1, plot_prl2, avg != avg[1] ? na : color.new(#089981, 95))

    //-----------------------------------------------------------------------------} 
    PHP Code:
     // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © Steversteves

    //@version=5
    indicator("Z-Score"overlay=truemax_labels_count 500)

    lengthInput input.int(50"Length"minval 2)
    // Calculating High Z Score

    ta.sma(closelengthInput)
    ta.stdev(closelengthInput)
    = (close a) / 



    // Highest and Lowest

    highz ta.highest(clengthInput)

    lowz ta.lowest(clengthInput

    // Condition Alerts

    var wait 0

    wait 
    := wait 1

    if (<= lowz) and (wait 30)
        
    wait := 10
        label
    .new(x=bar_indexy=hightext="sat"size size.tinycolor=color.rgb(24777))
        
    alert("sat tepe "+syminfo.tickeralert.freq_once_per_bar)
        

    if (
    >= highz) and (wait 30)
        
    wait := 10
        label
    .new(x=bar_indexy=hightext="al"size size.tinycolor=color.rgb(6624811))
        
    alert("al ralli "+syminfo.tickeralert.freq_once_per_bar)

    // Colors

    color bear color.new(color.orange0
    color bull color.new(color.lime0

    bool overbought >= 
    bool oversold 
    <= -

    brcolor 
    overbought bear oversold bull na

    //barcolor(brcolor)
    //////////////////////////
    Length22 input(50)
    stddevs input(1.69)
    src22 close

    basis 
    ta.ema(src22Length22)

    zscore = (src22-basis)/ta.stdev(src22Length22)

    diff math.abs(src22 basis)
    absZscore math.abs(zscore)
    bounds diff absZscore stddevs
    upper 
    basis bounds
    lower 
    basis bounds

    zscoreColor 
    zscore 0.0 zscore >= zscore[1] ? zscore >= stddevs color.blue color.green color.new(color.green70) : zscore <= zscore[1] ? zscore <= -stddevs color.blue color.red color.new(color.red70)

    plot(ta.ema(upper5), title="Upper "linewidth=2)
    //plot(ta.ema(basis, 5), title="Median", color=color.new(color.white, 60), linewidth=2)
    plot(ta.ema(lower5), title="Lower "linewidth=2
    PHP Code:
     // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © carefulCode53358
    //@version=5
    indicator("*"overlay truemax_boxes_count=100,max_lines_count 100max_labels_count 100format=format.price)
    // Custom cosh function
    cosh(float x) =>
        (
    math.exp(x) + math.exp(-x)) / 2

    // Custom acosh function
    acosh(float x) =>
        
    na math.log(math.sqrt(1))

    // Custom sinh function
    sinh(float x) =>
        (
    math.exp(x) - math.exp(-x)) / 2

    // Custom asinh function
    asinh(float x) =>
        
    math.log(math.sqrt(1))

    // Custom inverse tangent function
    atan(float x) =>
        
    math.pi math.atan(x)

    // Chebyshev Type I Moving Average
    chebyshevI(float srcint lenfloat ripple) =>
        
    0.
        b 
    0.
        g 
    0.
        chebyshev 
    0.
        
        a 
    := cosh(len acosh(/ (ripple)))
        
    := sinh(len asinh(ripple))
        
    := (b) / (b)
        
    chebyshev := (g) * src nz(chebyshev[1])
        
    chebyshev

    bool_to_float
    (bool source) =>
        
    source 0

    ema
    (source)=>
        var 
    float ema 0.0
        
    var int count 0
        count 
    := nz(count[1]) + 1
        ema 
    := (1.0 2.0 / (count 1.0)) * nz(ema[1]) + 2.0 / (count 1.0) * source
        ema

    atan2
    (yx) =>
        var 
    float angle 0.0
        
    if 0
            angle 
    := math.atan(x)
        else
            if 
    and >= 0
                angle 
    := math.atan(x) + math.pi
            
    else
                if 
    and 0
                    angle 
    := math.atan(x) - math.pi
                
    else
                    if 
    == and 0
                        angle 
    := math.pi 2
                    
    else
                        if 
    == and 0
                            angle 
    := -math.pi 2
        angle

    degrees
    (float source) =>
        
    source 180 math.pi

    tra
    ()=>
        
    atr ema(ta.tr)
        
    slope = (close close[10]) / (atr 10)
        
    angle_rad atan2(slope1)
        
    degrees degrees(angle_rad)
        
    source ta.sma((degrees high low), 2)

    mats(sourcelength) =>
        
    smooth 0.
        higher_high 
    math.max(math.sign(ta.change(ta.highest(length))), 0)
        
    lower_low math.max(math.sign(ta.change(ta.lowest(length)) * -1), 0)
        
    time_constant math.pow(ta.sma(bool_to_float(higher_high or lower_low), length), 2)
        
    smooth := nz(smooth[1] + time_constant * (source smooth[1]), source)

        
    wilders_period length 1

        atr 
    math.abs(nz(smooth[1]) - smooth)
        
    ma_atr ta.ema(atrwilders_period)
        
    delta_fast_atr ta.ema(ma_atrwilders_period) * length 0.4

        result 
    0.0
        
    if smooth nz(result[1])
            if 
    smooth delta_fast_atr result[1]
                
    result := result[1]
            else
                
    result := smooth delta_fast_atr
        
    else
            if 
    smooth delta_fast_atr result[1]
                
    result := result[1]
            else
                
    result := smooth delta_fast_atr

        
    // Return
        
    result

    length20 
    input.int(5"Length"1)

    up_color input.color(color.lime""inline "color")
    down_color input.color(color.red""inline "color")
    enable_glow input.bool(true"Enable Glow"inline "color")

    mats20 mats(tra(), length20)


    atr20 ta.atr(length20)


    colour20 ta.sma(close1) > mats20 up_color down_color


    atr_10 
    ema(ta.tr) / 2

    alpha 
    color.new(color.black100)

    max20 mats20 atr_10

    min20 
    mats20 atr_10


    center20 
    plot(mats20"T0"colour20style=plot.style_stepline,  editable true)

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


    // User inputs
    prd22 input.int(defval=2title=' Period for Pivot Points'minval=1maxval=50)
    max_num_of_pivots input.int(defval=5title=' Maximum Number of Pivots'minval=5maxval=10)
    max_lines input.int(defval=1title=' Maximum number of trend lines'minval=1maxval=10)
    show_lines input.bool(defval=truetitle=' Show trend lines')
    show_pivots input.bool(defval=truetitle=' Show Pivot Points')

    float ph ta.pivothigh(highprd22prd22)
    float pl ta.pivotlow(lowprd22prd22)

    //plotshape(ph and show_pivots, style=shape.triangledown, location=location.abovebar, offset=-prd22, size=size.small)
    //plotshape(pl and show_pivots, style=shape.triangleup, location=location.belowbar, offset=-prd22, size=size.small)

    // Creating array of pivots
    var pivots_high = array.new_float(0)
    var 
    pivots_low = array.new_float(0)

    var 
    high_ind = array.new_int(0)
    var 
    low_ind = array.new_int(0)

    if 
    ph 
        
    array.push(pivots_highph)
        array.
    push(high_indbar_index prd22)
        if array.
    size(pivots_high) > max_num_of_pivots  // limit the array size
            
    array.shift(pivots_high)
            array.
    shift(high_ind)

    if 
    pl
        
    array.push(pivots_lowpl)
        array.
    push(low_indbar_index prd22)
        if array.
    size(pivots_low) > max_num_of_pivots  // limit the array size
            
    array.shift(pivots_low)
            array.
    shift(low_ind)

    // Create arrays to store slopes and lines
    var res_lines = array.new_line()
    var 
    res_slopes = array.new_float()

    len_lines = array.size(res_lines)

    if (
    len_lines >= 1)
        for 
    ind 0 to len_lines 
            to_delete 
    = array.pop(res_lines)
            array.
    pop(res_slopes)
            
    line.delete(to_delete)
            
    // line.set_extend(to_delete, extend=extend.none)



    count_slope(ph1ph2pos1pos2) => (ph2 ph1) / (pos2 pos1)


    if array.
    size(pivots_high) == max_num_of_pivots
        index_of_biggest_slope 
    0
        
    for ind1 0 to max_num_of_pivots 2
            
    for ind2 ind1 1 to max_num_of_pivots 1
                p1 
    = array.get(pivots_highind1)
                
    p2 = array.get(pivots_highind2)
                
    pos1 = array.get(high_indind1)
                
    pos2 = array.get(high_indind2)
                
    count_slope(p1p2pos1pos2)
                
    p1 pos1

                
    // ok = k * bar_index + b > high
                
    ok true
                
    // label.new(pos1, p1, str.tostring(ok))
                
    for ind3 ind2 to max_num_of_pivots 1
                    p3 
    = array.get(pivots_highind3)
                    
    pos3 = array.get(high_indind3)
                    if 
    p3 pos3 
                        ok 
    := false
                        
    // label.new(pos3, p3, 'cross')
                        
    break

                if 
    ind2 ind1 >= 1
                    
    for ind3 ind1 1 to ind2 1
                        p3 
    = array.get(pivots_highind3)
                        
    pos3 = array.get(high_indind3)
                        if 
    p3 pos3 
                            ok 
    := false
                            
    // label.new(pos3, p3, 'cross')
                            
    break

                for 
    ind 0 to prd22 1
                    
    if high[ind] * 0.996 bar_index[ind] + b
                        ok 
    := false
                        
    break
                
                
                if 
    ok //and not (high > k * bar_index + b) // 'and not' for the last line to check if the crosses the price action
                    
    if array.size(res_slopes) < max_lines // max_lines // for now only 1 lines is to be shown
                        
    line line.new(pos1p1pos2p2extend=extend.right)
                        array.
    push(res_linesline)
                        array.
    push(res_slopesk)  
                    else
                        
    max_slope = array.max(res_slopes)
                        
    max_slope_ind = array.indexof(res_slopesmax_slope)
                        if 
    max_lines == 1
                            max_slope_ind 
    := 0
                        
    if max_slope
                            line_to_delete 
    = array.get(res_linesmax_slope_ind)
                            
    line.delete(line_to_delete
                            
    new_line line.new(pos1p1pos2p2extend=extend.right)
                            array.
    insert(res_linesmax_slope_indnew_line)
                            array.
    insert(res_slopesmax_slope_indk)
                            array.
    remove(res_linesmax_slope_ind 1)
                            array.
    remove(res_slopesmax_slope_ind 1)
                            
    // label.new(pos1, p1, str.tostring(res_slopes))

    // if barstate.islast
    //     label.new(bar_index, high, str.tostring(array.size(res_lines)))

    if array.size(res_lines) >= and barstate.islast
        
    for ind=0 to array.size(res_lines) - 
            l 
    = array.get(res_linesind)
            
    = array.get(res_slopesind)
            
    x1 line.get_x1(l)
            
    x2 line.get_x2(l
            
    prev_lable_ind 0//x2 + prd - 5
            
    for ind1=x2 to bar_index
                p 
    line.get_price(lind1
                if (
    math.abs(high[bar_index ind1]) < 0.005
                    if 
    ind1 prev_lable_ind 10 and ind1 x2 >= prd22
                        
    //label.new(ind1, high[bar_index - ind1], text='S', style=label.style_label_down, color=color.red)
                        
    prev_lable_ind := ind1

    if not show_lines
        len_l 
    = array.size(res_lines)
        if (
    len_l >= 1)
            for 
    ind 0 to len_l 
                to_delete 
    = array.pop(res_lines)
                array.
    pop(res_slopes)
                
    line.delete(to_delete)

    var 
    sup_lines = array.new_line()
    var 
    sup_slopes = array.new_float()

    len_lines1 = array.size(sup_lines)

    if (
    len_lines1 >= 1)
        for 
    ind 0 to len_lines1 
            to_delete 
    = array.pop(sup_lines)
            array.
    pop(sup_slopes)
            
    line.delete(to_delete)

    if array.
    size(pivots_low) == max_num_of_pivots
        
    for ind1 0 to max_num_of_pivots 2
            
    for ind2 ind1 1 to max_num_of_pivots 1
                p1 
    = array.get(pivots_lowind1)
                
    p2 = array.get(pivots_lowind2)
                
    pos1 = array.get(low_indind1)
                
    pos2 = array.get(low_indind2)
                
    count_slope(p1p2pos1pos2)
                
    p1 pos1

                
    // check if pivot points in the future are lower than the line between two points 
                
    ok true
                
    for ind3 ind2 to max_num_of_pivots 1
                    p3 
    = array.get(pivots_lowind3)
                    
    pos3 = array.get(low_indind3)
                    if 
    p3 pos3 b
                        ok 
    := false
                        
    // label.new(pos3, p3, 'cross')
                        
    break

                
    // check if pivot points in the middle of two points is lower
                
    if ind2 ind1 >= 1
                    
    for ind3 ind1 1 to ind2 1
                        p3 
    = array.get(pivots_lowind3)
                        
    pos3 = array.get(low_indind3)
                        if 
    p3 pos3 b
                            ok 
    := false
                            
    // label.new(pos3, p3, 'cross')
                            
    break
                
                for 
    ind 0 to prd22 2
                    
    if low[ind] * 1.008 bar_index[ind] + b
                        ok 
    := false
                        
    break
                
                if 
    ok //and not (low < k * bar_index + b) // 'and not' for the last line to check if the it crosses the price action
                    
    if array.size(sup_slopes) < max_lines // max_lines // for now only 1 lines is to be shown
                        
    line line.new(pos1p1pos2p2extend=extend.right)
                        
    // label.new(pos1, p1, 'ok to print')
                        
    array.push(sup_linesline)
                        array.
    push(sup_slopesk)  
                    else
                        
    max_slope = array.min(sup_slopes)
                        
    max_slope_ind = array.indexof(sup_slopesmax_slope)
                        if 
    max_lines == 1
                            max_slope_ind 
    := 0
                        
    if max_slope
                            line_to_delete 
    = array.get(sup_linesmax_slope_ind)
                            
    line.delete(line_to_delete
                            
    new_line line.new(pos1p1pos2p2extend=extend.right)
                            array.
    insert(sup_linesmax_slope_indnew_line)
                            array.
    insert(sup_slopesmax_slope_indk)
                            array.
    remove(sup_linesmax_slope_ind 1)
                            array.
    remove(sup_slopesmax_slope_ind 1)
                            
    // label.new(pos1, p1, str.tostring(sup_slopes))


    if array.size(sup_lines) >= and barstate.islast
        
    for ind=0 to array.size(sup_lines) - 
            l 
    = array.get(sup_linesind)
            
    = array.get(sup_slopesind)
            
    x1 line.get_x1(l)
            
    x2 line.get_x2(l
            
    prev_lable_ind 0//x2 + prd - 5
            
    for ind1=x2 to bar_index
                p 
    line.get_price(lind1
                if (
    math.abs(low[bar_index ind1]) < 0.005
                    if 
    ind1 prev_lable_ind 10 and ind1 x2 >= prd22
                        
    //label.new(ind1, low[bar_index - ind1], text='A', style=label.style_label_up, color=color.green)
                        
    prev_lable_ind := ind1

    if not show_lines
        len_l 
    = array.size(sup_lines)
        if (
    len_l >= 1)
            for 
    ind 0 to len_l 
                to_delete 
    = array.pop(sup_lines)
                array.
    pop(sup_slopes)
                
    line.delete(to_delete)
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


    //Settings
    //-----------------------------------------------------------------------------{
    length input.int(200'Length'minval 2)
    mult   input.float(6.'Factor'minval 0step .5)
    tf     input.timeframe('''Timeframe')
    src    input(close'Source')

    //-----------------------------------------------------------------------------}
    //Function
    //-----------------------------------------------------------------------------{
    pred_ranges(lengthmult)=>
        var 
    avg src
        
    var hold_atr 0.

        atr 
    nz(ta.atr(length)) * mult
            
        avg 
    := src avg atr avg atr 
          
    avg src atr avg atr 
          
    avg
            
        hold_atr 
    := avg != avg[1] ? atr hold_atr
            
        
    [avg hold_atr 2avg hold_atravgavg hold_atravg hold_atr 2]

    //-----------------------------------------------------------------------------}
    //Calculation
    //-----------------------------------------------------------------------------{
    [prR2
      
    prR1
      
    avg
      
    prS1
      
    prS2] = request.security(syminfo.tickeridtfpred_ranges(lengthmult))

    //-----------------------------------------------------------------------------}
    //Plots
    //-----------------------------------------------------------------------------{
    plot_pru2  plot(prR2'+RH2'avg != avg[1] ? na #f2364600)
    plot_pru1  plot(prR1'+RH1'avg != avg[1] ? na #f2364600)
    plot_pravg plot(avg 'RH0'avg != avg[1] ? na #f3f70700)
    plot_prl1  plot(prS1'-RH1'avg != avg[1] ? na #08998100)
    plot_prl2  plot(prS2'-RH2'avg != avg[1] ? na #08998100)

    //Fills
    fill(plot_pru2plot_pru1avg != avg[1] ? na color.new(#f23645,55))
    fill(plot_prl1plot_prl2avg != avg[1] ? na color.new(#089981, 55))

    //-----------------------------------------------------------------------------}
    //Settings
    //-----------------------------------------------------------------------------{
    length33      input.int(70
      
    minval 0)

    extrapolate input.int(10
      
    minval 0)

    degree      input.int(3'Polynomial Degree'
      
    minval 0
      
    maxval 8)

    src33         input(close)

    lock        input(false'Lock Forecast')

    //Style
    up_css input.color(#0cb51a, 'Upward Color'
      
    group 'Style')
      
    dn_css input.color(#ff1100, 'Downward Color'
      
    group 'Style')

    ex_css input.color(#ea00ff, 'Extrapolation Color'
      
    group 'Style')
      
    width  input(3'Width'
      
    group 'Style')

    //-----------------------------------------------------------------------------}
    //Fill lines array
    //-----------------------------------------------------------------------------{
    var lines = array.new_line(0)

    if 
    barstate.isfirst
        
    for = -extrapolate to length33-1
            
    array.push(linesline.new(nananana))

    //-----------------------------------------------------------------------------}
    //Get design matrix & partially solve system
    //-----------------------------------------------------------------------------{
    n33 bar_index

    var design   matrix.new<float>(00)
    var 
    response matrix.new<float>(00)

    if 
    barstate.isfirst
        
    for 0 to degree
            column 
    = array.new_float(0)
            
            for 
    0 to length33-1
                
    array.push(columnmath.pow(j,i))
            
            
    matrix.add_col(designicolumn)

    var 
    matrix.inv(matrix.mult(matrix.transpose(design), design))
    var 
    matrix.mult(amatrix.transpose(design))

    //-----------------------------------------------------------------------------}
    //Get response matrix and compute roling polynomial regression
    //-----------------------------------------------------------------------------{
    var pass 1
    var matrix<floatcoefficients na
    var = -extrapolate
    var float forecast na

    if barstate.islast 
        
    if pass
            prices 
    = array.new_float(0)
            
            for 
    0 to length33-1
                
    array.push(pricessrc33[i])
            
            
    matrix.add_col(response0prices)
            
            
    coefficients := matrix.mult(bresponse)
            
            
    float y1 na
            idx 
    0
            
            
    for = -extrapolate to length33-1
                y2 
    0.
                
                
    for 0 to degree
                    y2 
    += math.pow(ij)*matrix.get(coefficientsj0)
                
                if 
    idx == 0
                    forecast 
    := y2
                    
                
    //------------------------------------------------------------------
                //Set lines
                //------------------------------------------------------------------
                
    css33 y2 y1 up_css dn_css
                
                get_line 
    = array.get(linesidx)
                
                
    line.set_xy1(get_linen33 1y1)
                
                
    line.set_xy2(get_linen33 iy2)
                
                
    line.set_color(get_line<= ex_css css33)
                
                
    line.set_width(get_linewidth)
                
                
    y1 := y2
                idx 
    += 1
                
            
    if lock
                pass 
    := 0
        
    else
            
    y2 0.
            x 
    -= 1
            
            
    for 0 to degree
                y2 
    += math.pow(xj)*matrix.get(coefficientsj0)
            
            
    forecast := y2

    plot
    (pass == forecast na'Extrapolation'
      
    color     ex_css
      
    offset    extrapolate
      
    linewidth width)

    //----------------------- 
    PHP Code:
      // //////////////////////trend hesaplama kısmı////////////////////
    //@version=5

    indicator('Average Interpercentile Range AIR Supertrend','---'overlay=trueformat=format.price)

    // Moving Averages Types
    var string SMA      'Simple Moving Average'
    var string EMA      'Exponential Moving Average'
    var string WMA      'Weighted Moving Average'
    var string VWMA     'Volume Weighted Moving average'
    var string ALMA     'Arnaud Legoux Moving Average'
    var string JURIK    'Jurik Moving Average'
    var string T3       'Tillson T3 Moving Average'
    var string RSIMA    'RSI Moving Average'
    var string MEDIAN   'Median'
    var string SS        'Super Smoother Moving Average'
    var string HANN       'Ehlers Hann Moving Average'

    src                 input.source(hl2title 'Source'inline '1')
    period              input.int(title 'Length'defval 5inline '1')
    multiplier          input.float(title 'Multiplier'step 0.1defval 3.3inline '1')

    var 
    string GRP_RF   '══════ Range mix ══════'
    atrActive           input.bool(true'ATR,'inline='42'group=GRP_RF)
    atrMult             input.float(0.3'Mult'step=0.1inline='42'group=GRP_RF)
    atr_move            input.string(T3'MA'options=[SMAEMAWMAVWMAALMAJURIKT3RSIMAMEDIANSSHANN], group=GRP_RFinline='42'

    airActive           input.bool(true'AIR,'inline='44'group=GRP_RF)
    airMult             input.float(0.6'Mult'step=0.1inline='44'group=GRP_RF)
    air_move            input.string(T3'MA'options=[SMAEMAWMAVWMAALMAJURIKT3RSIMAMEDIANSSHANN], group=GRP_RFinline='44'
    spacer              input.int(16'%'inline='44'group=GRP_RF)

    var 
    string GRP_MA   'Global MA Settings'
    inputAlmaOffset_T   input.float(defval 0.86title "Alma Offset"step 0.01inline '1a'group GRP_MA)
    inputAlmaSigma_T    input.int(defval 3title "... Sigma"inline '1a'group GRP_MA)

    phase_T             input.int(defval 2title "Jurik Phase"step 1inline '1j'group GRP_MA)
    power_T             input.float(defval 0.9title "... Power"step 0.1inline '1j'group GRP_MA)

    fac_t3_T            input.float(0step 0.1title 'Tillson T3 Volume Factor'inline '1t'group GRP_MA)

    var 
    string GRP_UI   '══════ UI ══════'
    up_                 input.color(#4caf50, '', inline = '2a', group = GRP_UI)
    dn_                 input.color(#ff5252, '', inline = '2a', group = GRP_UI)

    bkgrnd              input.bool(title 'Fill On/Off ?'defval trueinline='f'group GRP_UI)
    fader               input.int(75'Fade'inline 'f'group GRP_UI)

    bar_it              input.bool(true'Color candles On/Off ?'inline 'f1'group GRP_UI)
    fader_c             input.int(39'Fade'inline 'f1'group GRP_UI)

    // ===========================================================================================================
    //          Functions
    // ===========================================================================================================

    // @function Jurik Moving Average - TradingView: Moving Averages
    Jurik(srcsimple int lenjurik_phasejurik_power) =>
        
    phaseRatio_l jurik_phase < -100 0.5 jurik_phase 100 2.5 jurik_phase 100 1.5
        beta_l 
    0.45 * (len 1) / (0.45 * (len 1) + 2)
        
    alpha_l math.pow(beta_ljurik_power)
        
    jma_l 0.0
        e0_l 
    0.0
        e0_l 
    := (alpha_l) * src alpha_l nz(e0_l[1])
        
    e1_l 0.0
        e1_l 
    := (src e0_l) * (beta_l) + beta_l nz(e1_l[1])
        
    e2_l 0.0
        e2_l 
    := (e0_l phaseRatio_l e1_l nz(jma_l[1])) * math.pow(alpha_l2) + math.pow(alpha_l2) * nz(e2_l[1])
        
    jma_l := e2_l nz(jma_l[1])

    // @function T3 MA from Tilson3Average © KioseffTrading
    t(srcxa1_t3) =>
        
    y1 ta.ema(src,x)
        
    y2 ta.ema(y1x)
        
    y3 ta.ema(y2x)
        
    y4 ta.ema(y3x)
        
    y5 ta.ema(y4x)
        
    y6 ta.ema(y5x)
        
    = -a1_t3 math.pow(a1_t3,2)
        
    v2 math.pow(a1_t3,2) + math.pow(a1_t3,3)
        
    v3 = -math.pow(a1_t32) - a1_t3 math.pow(a1_t33)
        
    v4 a1_t3 a1_t3 math.pow(a1_t32) + math.pow(a1_t32)
        
    v1 y6 v2 y5 v3 y4 v4 y3
        v1

    // Super Smoother Function 
    ss(SeriesPeriod) =>  // Super Smoother Function
        
    var PI 2.0 math.asin(1.0)
        var 
    SQRT2 math.sqrt(2.0)
        
    lambda PI SQRT2 Period
        a1 
    math.exp(-lambda)
        
    coeff2 2.0 a1 math.cos(lambda)
        
    coeff3 = -math.pow(a12.0)
        
    coeff1 1.0 coeff2 coeff3
        filt1 
    0.0
        filt1 
    := coeff1 * (Series nz(Series[1])) * 0.5 coeff2 nz(filt1[1]) + coeff3 nz(filt1[2])
        
    filt1

    // Hann Window Smoothing – Credits to @cheatcountry
    doHannWindow(float _seriesfloat _hannWindowLength) =>
        
    sum 0.0coef 0.0
        
    for 1 to _hannWindowLength
            cosine 
    math.cos(math.pi / (_hannWindowLength 1))
            
    sum := sum + (cosine nz(_series[1]))
            
    coef := coef cosine
        h 
    coef != sum coef 0

    // Choose MA type
    MA_Calc(_data_lenMAOption) =>
        
    value 
              
    MAOption == SMA ta.sma(_data_len) : 
              
    MAOption == EMA ta.ema(_data_len) :
              
    MAOption == WMA ta.wma(_data_len) : 
              
    MAOption == VWMA ta.vwma(_data_len) : 
              
    MAOption == ALMA ta.alma(_data_leninputAlmaOffset_TinputAlmaSigma_T) :
              
    MAOption == JURIK Jurik(_data_lenphase_Tpower_T) : 
              
    MAOption == T3 t(_data_lenfac_t3_T) :
              
    MAOption == RSIMA ta.rma(_data_len) :
              
    MAOption == MEDIAN ta.median(_data_len) :
              
    MAOption == SS ss(_data_len) :
              
    MAOption == HANN doHannWindow(_data_len) :
          
    na

    ipr_array
    (lendnnyuppy) =>
        
    float[]   hiArray   =   array.new_float (0)
        
    float[]   loArray   =   array.new_float (0)
        
    float[]   cmArray   =   array.new_float (0)

        for 
    0 to len 1
            
    array.push  (hiArrayhigh[i])
            array.
    push  (loArraylow[i])
            array.
    push  (cmArrayhlcc4[i])

        
    hlArray     =   array.concat (hiArrayloArray)
        
    hlcmArray   =   array.concat (hlArraycmArray)
        
        
    q1          =   array.percentile_linear_interpolation (hlcmArraydnny)
        
    q3          =   array.percentile_linear_interpolation (hlcmArrayuppy)

        
    iqr = (q3 q1) / 2

    // =================================================================================================
    //                                  Calculations
    // =================================================================================================

    atrFactor   atrActive atrMult MA_Calc(ta.tr(true), periodatr_move)                             : 0
    airFactor   
    airActive airMult MA_Calc(ipr_array(periodspacer100 spacer), periodair_move) : 0

    blender 
    nz(atrFactor) + nz(airFactor)

    ipr_supertrend(sourcelenmulti) =>
        
    up source multi blender
        up1 
    nz(up[1], up)
        
    up := close[1] > up1 math.max(upup1) : up
        dn 
    source multi blender
        dn1 
    nz(dn[1], dn)
        
    dn := close[1] < dn1 math.min(dndn1) : dn
        trend 
    1
        trend 
    := nz(trend[1], trend)
        
    trend := trend == -and close dn1 trend == and close up1 ? -trend
        
    [updntrend]

    [
    upperlowersupertrend] = ipr_supertrend(srcperiodmultiplier

    // =================================================================================================
    //                                  Plots
    // =================================================================================================

    upPlot          plot(supertrend == upper natitle='Uptrend'style=plot.style_linebrlinewidth=2color=color.new(up_100))
    buySignal       supertrend == and supertrend[1] == -1
    dnPlot          
    plot(supertrend == na lowertitle='Downtrend'style=plot.style_linebrlinewidth=2color=color.new(dn_100))
    sellSignal      supertrend == -and supertrend[1] == 1

    plotshape
    (buySignal upper natitle='Uptrend Begins'location=location.absolutestyle=shape.circlesize=size.smallcolor=color.new(up_0))
    plotshape(sellSignal lower natitle='Downtrend Begins'location=location.absolutestyle=shape.circlesize=size.smallcolor=color.new(dn_0))

    midPlot         plot(ohlc4title ''style plot.style_circlesdisplay display.none)
    //fill(midPlot, upPlot, title = 'Uptrend Fill', color = bkgrnd ? color.new(up_, fader) : na)
    //fill(midPlot, dnPlot, title = 'Downtrend Fill', color = bkgrnd ? color.new(dn_, fader) : na)

    color_b         supertrend == up_ dn_
    barcolor
    (bar_it color.new(color_bfader_c) : na)

    // =================================================================================================
    //                                  Alerts
    // =================================================================================================

    alertcondition(buySignaltitle='.Supertrend Buy 🟢'message='Supertrend Buy 🟢')
    alertcondition(sellSignaltitle='.Supertrend Sell 🔴'message='Supertrend Sell 🔴')
    changeCond      supertrend != supertrend[1]
    alertcondition(changeCondtitle='Supertrend Direction Change 🟢/🔴'message='Supertrend has changed direction 🟢/🔴')


    //-----------------------------------------------------------------------------------------------------------------------------------------------------------------
    //Settings//////////////////////ma hesaplama kısmı///////////////////////
    //-----------------------------------------------------------------------------{
    length22 input(100)

    incr   input(10"Increment")

    fast   input(10)

    src22    input(close)

    //-----------------------------------------------------------------------------}
    //Calculations
    //-----------------------------------------------------------------------------{
    var ma22    0.
    var fma   0.
    var alpha 0.
    var k     incr

    upper22 
    ta.highest(length22)
    lower22 ta.lowest(length22)
    init_ma ta.sma(src22length22)

    cross ta.cross(src22,ma22)

    alpha := cross / (length22 1)
      : 
    src22 ma22 and upper22 upper22[1] ? alpha k
      
    src22 ma22 and lower22 lower22[1] ? alpha k
      
    alpha

    ma22 
    := nz(ma22[1] + alpha[1] * (src22 ma22[1]), init_ma)
      
    fma := nz(cross math.avg(src22fma[1])
      : 
    src22 ma22 math.max(src22fma[1]) + (src22 fma[1]) / fast
      
    math.min(src22fma[1]) + (src22 fma[1]) / fast,src22)

    //-----------------------------------------------------------------------------}
    //Plots
    //-----------------------------------------------------------------------------{
    css22 fma ma22 color.rgb(462456) : color.red



    plot122 
    plot(ma22"Stop"style=plot.style_circleslinewidth=2
      
    color css22)
    ///////////////////////////////////////dinamik range hesaplama kısmı/////////////////////

    string reversal_type input.string(defval='ATR'options=['ATR''Traditional'], title='Reversal Type:'inline='rt')
    float reversal_modifier input.float(defval=14title=''inline='rt')
    float reversal_multiplier input.float(defval=3title=''inline='rt'tooltip='-The type of range to use for the width of the channel. \n-Price modifier or atr length parameter depending on type. \n-Multiplier to apply to range.')
    string ALT_TF input.string(defval='D'title='Timeframe:'inline='itf')
    bool USE_ALT_TF input.bool(defval=truetitle='Use Alternative Timeframe?'inline='itf')
    float expansion_rate input.float(defval=0.25title='Expansion Rate:'inline='er')
    bool expand_range input.bool(defval=truetitle='Expand Range'inline='er'tooltip='Expand Channel by rate when price touches extremes.')

    float atr_1 ta.atr(math.max(1math.round(reversal_modifier)))
    float reversal_block 
     switch (
    reversal_type)
        (
    'ATR') => reversal_multiplier atr_1 
        
    ('Traditional') => reversal_multiplier reversal_modifier 
        
    => 0.0

    bot_function
    () =>
        
    float _bot_base high reversal_block
        float _previous 
    nz(_bot_base[1], _bot_base)
        if 
    _previous reversal_block high
            _bot_base 
    := high reversal_block
        
    else if low _previous
            
    if expand_range
                _bot_base 
    := low reversal_block expansion_rate 
            
    else
                
    _bot_base := low
        
    else
            
    _bot_base := _previous

    top_function
    () =>
        
    float _top_base low reversal_block
        float _previous 
    nz(_top_base[1], _top_base)
        if 
    _previous reversal_block low
            _top_base 
    := low reversal_block
        
    else if high _previous
            
    if expand_range
                _top_base 
    := high reversal_block expansion_rate 
            
    else
                
    _top_base := high
        
    else
            
    _top_base := _previous

    bot_function_1 
    bot_function()
    security_1 request.security(syminfo.tickeridALT_TFbot_function_1)
    bot_function_2 bot_function()
    bot USE_ALT_TF security_1 bot_function_2
    top_function_1 
    top_function()
    security_2 request.security(syminfo.tickeridALT_TFtop_function_1)
    top_function_2 top_function()
    top USE_ALT_TF security_2 top_function_2

    top_f 
    ta.change(bot) < or ta.change(top) < top na
    bot_f 
    ta.change(bot) < or ta.change(top) < bot na
    top_r 
    ta.change(bot) > or ta.change(top) > top na
    bot_r 
    ta.change(bot) > or ta.change(top) > bot na

    top_border 
    top - (top bot) * 0.25
    bot_border 
    bot + (top bot) * 0.25
    mid_border 
    bot + (top bot) * 0.50

    p_top_f 
    plot(series=top_ftitle='0'color=color.new(color.lime0), style=plot.style_linebr)
    //p_bot_f = plot(series=bot_f, title='tf', color=color.new(color.lime, 0), style=plot.style_linebr)
    p_top_r plot(series=top_rtitle='1'color=color.new(color.red0), style=plot.style_linebr)
    //p_bot_r = plot(series=bot_r, title='tr', color=color.new(color.red, 0), style=plot.style_linebr)
    //fill(p_top_f, p_bot_f, color.new(color.lime, 90), title='direction fill')
    //fill(p_top_r, p_bot_r, color.new(color.red, 90), title='direction fill')

    plot(title='0'series=botcolor=color.new(color.lime0))
    plot(title='1'series=topcolor=color.new(color.red0))

    plot(title='1'series=top_borderstyle=plot.style_circlescolor=color.new(color.red0))
    plot(title='0'series=bot_borderstyle=plot.style_circlescolor=color.new(color.lime0))
    plot(title='01'series=mid_borderstyle=plot.style_circlescolor=color.new(#537cee, 0))
    ///////////////////////////////
    //------------------------------------------------------------------------------
    //Tooltips
    //-----------------------------------------------------------------------------{
    widthTooltip  "Bin width percentage. Determine the length of the returned profile bin as a percentage of the Length setting"
    offsetTooltip "Determine the amount of bars each graphical elements are shifted by"

    //-----------------------------------------------------------------------------}
    //Settings
    //-----------------------------------------------------------------------------{
    length69 input.int(200minval 2)
    rows   input.int(2minval 2)
    useIb  input(false'Use Intrabar'inline 'intrabar'
    tf     input.timeframe('1'''    inline 'intrabar')

    //Style
    width69     input.float(10'Width %'minval 0maxval 100group 'Style'tooltip widthTooltip)

    showRange input(false'Show Range Levels'inline 'range'group 'Style')
    rangeCss  input(color.gray''         inline 'range'group 'Style')

    bullBin   input(#f321f3, 'Bullish Bin', inline = 'bull', group = 'Style')
    bullMax   input(true'Maximum'         inline 'bull'group 'Style'
    bearBin   input(#fbff00, 'Bearish Bin', inline = 'bear', group = 'Style')
    bearMax   input(true'Minimum'         inline 'bear'group 'Style')

    showFill input(false'Show Fill'             inline 'fill'group 'Style')
    bullFill input(color.new(#2157f3, 90), ''  , inline = 'fill', group = 'Style')
    bearFill input(color.new(#ff5d00, 90), ''  , inline = 'fill', group = 'Style')

    offset input.int(8group 'Style'tooltip offsetTooltip)

    //-----------------------------------------------------------------------------}
    //Function
    //-----------------------------------------------------------------------------{
    get_data() => [closeopen]

    //-----------------------------------------------------------------------------}
    //Main variables
    //-----------------------------------------------------------------------------{
    var boxes69 = array.new<box>(0)

    //Populate bins array
    if barstate.isfirst
        
    for 0 to rows-1
            boxes69
    .push(box.new(na,na,na,na,na
              
    text_valign text.align_center
              
    text_color color.white))

    n69 bar_index
    upper69 
    ta.highest(length69)
    lower69 ta.lowest(length69)
    sumad math.sum(math.abs(close open), length69)

    //Get intrabar data
    [get_closeget_open] = request.security_lower_tf(syminfo.tickeridtfget_data())

    //-----------------------------------------------------------------------------}
    //Set profile
    //-----------------------------------------------------------------------------{
    //Range levels
    var ltop line.new(na,na,na,nacolor rangeCss)
    var 
    l75  line.new(na,na,na,nacolor rangeCssstyle line.style_dashed)
    var 
    l50  line.new(na,na,na,nacolor rangeCss)
    var 
    l25  line.new(na,na,na,nacolor rangeCssstyle line.style_dashed)
    var 
    lbtm line.new(na,na,na,nacolor rangeCss)
    var 
    fill linefill.new(ltoplbtmna)

    //Max / Min levels
    var bull_max line.new(na,na,na,nacolor bullBin)
    var 
    bear_min line.new(na,na,na,nacolor bearBin)

    //Set profile
    if barstate.islast
        avg 
    math.avg(upper69lower69)
        
    avg75 math.avg(upper69avg)
        
    avg25 math.avg(lower69avg)

        
    //Set lines coordinates
        
    ltop.set_xy1(n69 length69upper69), ltop.set_xy2(n69 offsetupper69)
        
    lbtm.set_xy1(n69 length69lower69), lbtm.set_xy2(n69 offsetlower69)
        
        
    //Display range levels
        
    if showRange
            l75
    .set_xy1(n69 length69avg75) , l75.set_xy2(n69 offsetavg75)
            
    l50.set_xy1(n69 length69avg)   , l50.set_xy2(n69 offsetavg)
            
    l25.set_xy1(n69 length69avg25) , l25.set_xy2(n69 offsetavg25)
        else
            
    ltop.set_color(na)
            
    lbtm.set_color(na)

        
    //Get bullish/absolute delta sums for each row
        
    up69 upper69
        dn69 
    upper69
        sums     
    = array.new_float(0)
        
    sums_abs = array.new_float(0)

        
    //Loop trough each rows
        
    for 0 to rows-1
            dn69 
    -= (upper69 lower69) / rows
            sum 
    0.
            den 
    0.
            
            
    //Loop trough most recent bars
            
    for 0 to length69-1
                
    if useIb //Loop trough intrabar prices
                    
    for 0 to (get_close[j]).size()-1
                        c 
    = (get_close[j]).get(k)
                        
    = (get_open[j]).get(k)
                        
    sum += math.max(co) <= up69 and math.min(co) >= dn69 0
                
    else
                    
    sum += high[j] > dn69 and low[j] < up69 close[j] - open[j] : 0
            
            sums
    .push(sum)
            
    sums_abs.push(math.abs(sum))

            
    up69 := dn69

        
    //Set profile bins
        
    max sums_abs.max()
        
    up69 := upper69
        dn69 
    := upper69
        
        
    for [indexelementin sums
            dn69 
    -= (upper69 lower69) / rows
            x2 
    n69 int(element max length69 * (width69 100))
            
            
    css element color.new(bullBin50) : color.new(bearBin50)

            
    //Set box coordinates
            
    get_bx boxes69.get(index)
            
    get_bx.set_lefttop(n69 offset.9 up69 .1 dn69)
            
    get_bx.set_rightbottom(x2 offset.9 dn69 .1 up69)
            
    get_bx.set_bgcolor(css)
            
    get_bx.set_text(str.tostring(element sumad 100format.percent))
            
            
    //Set area MAX/MIN levels
            
    if element == sums.max() and bullMax
                bull_max_val 
    math.avg(up69dn69)
                
    bull_max.set_xy1(n69 offsetbull_max_val)
                
    bull_max.set_xy2(n69 length69bull_max_val)

            if 
    element == sums.min() and bearMax
                bear_min_val 
    math.avg(up69dn69)
                
    bear_min.set_xy1(x2 offsetbear_min_val)
                
    bear_min.set_xy2(n69 length69bear_min_val)
                
            
    up69 := dn69
        
        
    //Fill Area
        
    if showFill
            fill
    .set_color(sums.sum() > color.new(bullBin90) : color.new(bearBin90))

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

    //@version=5
    indicator("Predictive Ranges [LuxAlgo]""*"overlay true,max_boxes_count 500max_lines_count 500max_bars_back 500)
    //------------------------------------------------------------------------------
    //Settings
    //-----------------------------------------------------------------------------{
    length input.int(200'Length'minval 2)
    mult55   input.float(6.'Factor'minval 0step .5)
    tf     input.timeframe('''Timeframe')
    src    input(close'Source')

    //-----------------------------------------------------------------------------}
    //Function
    //-----------------------------------------------------------------------------{
    pred_ranges(lengthmult55)=>
        var 
    avg src
        
    var hold_atr 0.

        atr 
    nz(ta.atr(length)) * mult55
            
        avg 
    := src avg atr avg atr 
          
    avg src atr avg atr 
          
    avg
            
        hold_atr 
    := avg != avg[1] ? atr hold_atr
            
        
    [avg hold_atr 2avg hold_atravgavg hold_atravg hold_atr 2]

    //-----------------------------------------------------------------------------}
    //Calculation
    //-----------------------------------------------------------------------------{
    [prR2
      
    prR1
      
    avg
      
    prS1
      
    prS2] = request.security(syminfo.tickeridtfpred_ranges(lengthmult55))

    //-----------------------------------------------------------------------------}
    //Plots
    //-----------------------------------------------------------------------------{
    plot_pru2  plot(prR2'Direnç2'avg != avg[1] ? na #f2364600)
    plot_pru1  plot(prR1'Direnç1'avg != avg[1] ? na #f2364600)
    plot_pravg plot(avg 'Ortalama'avg != avg[1] ? na #f1ce0b)
    plot_prl1  plot(prS1'Destek1'avg != avg[1] ? na #08998100)
    plot_prl2  plot(prS2'Destek2'avg != avg[1] ? na #08998100)

    //Fills
    fill(plot_pru2plot_pru1avg != avg[1] ? na color.new(#f23645, 65))
    fill(plot_prl1plot_prl2avg != avg[1] ? na color.new(#089981, 65))

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

    //------------------------------------------------------------------------------
    //Settings
    //-----------------------------------------------------------------------------{
    length11 input(20)

    src11 input(close)

    //------------------------------------------------------------------------------
    //Signal moving average
    //-----------------------------------------------------------------------------{
    var ma 0.
    var os 0.

    target 
    ta.sma(src11length11)
    abs_diff math.abs(target target[1])

    r2 math.pow(ta.correlation(closebar_indexlength11), 2)

    os := r2 0.5 math.sign(src11[1] - target[1]) : os

    ma 
    := r2 0.5 r2 target + (r2) * nz(ma[1], target)
      : 
    ma[1] - abs_diff os
      
      
    //-----------------------------------------------------------------------------}
    //Plots
    //-----------------------------------------------------------------------------{
    plot0 plot(src11display display.noneeditable false)

    css os == #0cb51a : #ff1100
    plot1 plot(ma'MA0'
      
    css)
      
    fill_css src ma color.new(#0cb51a, 80) : color.new(#ff1100, 80)
    //fill(plot0, plot1, fill_css, 'Fill')

    //-----------------------------------------------------------------------------}
    //Settings
    //-----------------------------------------------------------------------------{
    length22 input(100)

    incr   input(10"Increment")

    fast   input(10)

    src22    input(close)

    //-----------------------------------------------------------------------------}
    //Calculations
    //-----------------------------------------------------------------------------{
    var ma22    0.
    var fma   0.
    var alpha 0.
    var k     incr

    upper 
    ta.highest(length22)
    lower ta.lowest(length22)
    init_ma ta.sma(src22length22)

    cross ta.cross(src22,ma22)

    alpha := cross / (length 1)
      : 
    src22 ma22 and upper upper[1] ? alpha k
      
    src22 ma22 and lower lower[1] ? alpha k
      
    alpha

    ma22 
    := nz(ma22[1] + alpha[1] * (src22 ma22[1]), init_ma)
      
    fma := nz(cross math.avg(src22fma[1])
      : 
    src22 ma22 math.max(src22fma[1]) + (src22 fma[1]) / fast
      
    math.min(src22fma[1]) + (src22 fma[1]) / fast,src22)

    //-----------------------------------------------------------------------------}
    //Plots
    //-----------------------------------------------------------------------------{
    css22 fma ma22 color.rgb(462456) : color.red



    plot122 
    plot(ma22"MA1"
      
    color css22)

    //-----------------------------------------------------------------------------} 
    16.07.2024 - 10.12.2024

Sayfa 213/276 İlkİlk ... 113163203211212213214215223263 ... 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
  •