Conversion TTM SQUEEZE PRO de Tradingview

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #201769 quote
    maxlys
    Participant
    Senior

    Bonjour,
    Sur le site il y a le code pour le TTM SQUEEZE mais celui ci a un peu évolué. Est-il possible d’avoir la version “PRO” que l’on trouve sur TV ?
    Merci

    // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
    // © Beardy_Fred

    //@version=5
    indicator(‘Beardy Squeeze Pro’, shorttitle=’Squeeze’, overlay=false, precision=2)

    length = input.int(20, “TTM Squeeze Length”)

    //BOLLINGER BANDS
    BB_mult = input.float(2.0, “Bollinger Band STD Multiplier”)
    BB_basis = ta.sma(close, length)
    dev = BB_mult * ta.stdev(close, length)
    BB_upper = BB_basis + dev
    BB_lower = BB_basis – dev

    //KELTNER CHANNELS
    KC_mult_high = input.float(1.0, “Keltner Channel #1”)
    KC_mult_mid = input.float(1.5, “Keltner Channel #2”)
    KC_mult_low = input.float(2.0, “Keltner Channel #3”)
    KC_basis = ta.sma(close, length)
    devKC = ta.sma(ta.tr, length)
    KC_upper_high = KC_basis + devKC * KC_mult_high
    KC_lower_high = KC_basis – devKC * KC_mult_high
    KC_upper_mid = KC_basis + devKC * KC_mult_mid
    KC_lower_mid = KC_basis – devKC * KC_mult_mid
    KC_upper_low = KC_basis + devKC * KC_mult_low
    KC_lower_low = KC_basis – devKC * KC_mult_low

    //SQUEEZE CONDITIONS
    NoSqz = BB_lower < KC_lower_low or BB_upper > KC_upper_low //NO SQUEEZE: GREEN
    LowSqz = BB_lower >= KC_lower_low or BB_upper <= KC_upper_low //LOW COMPRESSION: BLACK MidSqz = BB_lower >= KC_lower_mid or BB_upper <= KC_upper_mid //MID COMPRESSION: RED HighSqz = BB_lower >= KC_lower_high or BB_upper <= KC_upper_high //HIGH COMPRESSION: ORANGE //MOMENTUM OSCILLATOR mom = ta.linreg(close - math.avg(math.avg(ta.highest(high, length), ta.lowest(low, length)), ta.sma(close, length)), length, 0) //MOMENTUM HISTOGRAM COLOR iff_1 = mom > nz(mom[1]) ? color.new(color.aqua, 0) : color.new(#2962ff, 0)
    iff_2 = mom < nz(mom[1]) ? color.new(color.red, 0) : color.new(color.yellow, 0) mom_color = mom > 0 ? iff_1 : iff_2

    //SQUEEZE DOTS COLOR
    sq_color = HighSqz ? color.new(color.orange, 0) : MidSqz ? color.new(color.red, 0) : LowSqz ? color.new(color.black, 0) : color.new(color.green, 0)

    //ALERTS
    Detect_Sqz_Start = input.bool(true, “Alert Price Action Squeeze”)
    Detect_Sqz_Fire = input.bool(true, “Alert Squeeze Firing”)

    if Detect_Sqz_Start and NoSqz[1] and not NoSqz
    alert(“Squeeze Started”)
    else if Detect_Sqz_Fire and NoSqz and not NoSqz[1]
    alert(“Squeeze Fired”)

    //PLOTS
    plot(mom, title=’MOM’, color=mom_color, style=plot.style_columns, linewidth=2)
    plot(0, title=’SQZ’, color=sq_color, style=plot.style_circles, linewidth=3)

    #202046 quote
    maxlys
    Participant
    Senior

    J’ai tenté de modifier le code de la version standard mais sans grand succés.

    J’ai déclaré les variables multKC2 = 2  et multKC1 = 1 pour les ecarts type du KC

    Car a la lecture du code de TV je pense en déduire que les points rouge correspondent au squeeze sur le KC 1,5 (origine du code), les noirs (low compression) sur le KC = 2 et le orange (high compression) sur le KC = 1
    J’ai fait le code ci dessous, mais cela ne fonctionne pas, quelles sont les modifications a apporter pour voir ces differents points ? Merci pour votre aide

    //PRC_TTM Squeeze for PRT v10.3| indicator
    //27.04.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    //---Settings
    //length=20
    //mult=2
    //lengthKC=20
    //multKC=1.5
    //multKC1=1
    //multKC2=2
    //squeezeDotsOffset=0
    //---End of settings
    
    //BB
    basis = average[length](close)
    dev = mult * Std[length](close)
    upperBB = basis + dev
    lowerBB = basis - dev
    
    //KC1,5
    ma = average[lengthKC](close)
    myrange = range[lengthKC]
    rangema = average[lengthKC](myrange)
    upperKC = ma+rangema * multKC
    lowerKC = ma-rangema * multKC
    
    //KC1
    ma = average[lengthKC](close)
    myrange = range[lengthKC]
    rangema = average[lengthKC](myrange)
    upperKC1 = ma+rangema * multKC1
    lowerKC1 = ma-rangema * multKC1
    
    
    //KC2
    ma = average[lengthKC](close)
    myrange = range[lengthKC]
    rangema = average[lengthKC](myrange)
    upperKC2 = ma+rangema * multKC2
    lowerKC2 = ma-rangema * multKC2
    
    
    value1 = (Highest[lengthKC](high)+Lowest[lengthKC](low)+average[lengthKC](close))/3
    val = linearregression[lengthKC](close-value1)
    
    
    // ROUGE MID COMPRESSION
    sqzOn = (lowerBB>lowerKC) AND (upperBB<upperKC)
    
    if(sqzOn=1) then
    scolorR = 255
    scolorG = 0
    else
    scolorR = 0
    scolorG = 255
    ENDIF
    
    
    // NOIR LOW COMPRESSION
    sqzOnoir = (lowerBB>lowerKC2) AND (upperBB<upperKC2)
    
    if(sqzOnoir=1) then
    scolorR = 0
    scolorG = 0
    else
    scolorR = 0
    scolorG = 255
    ENDIF
    
    // ORANGE HIGH COMPRESSION
    sqzOorange = (lowerBB>lowerKC1) AND (upperBB<upperKC1)
    
    if(sqzOorange=1) then
    scolorR = 237
    scolorG = 127
    else
    scolorR = 0
    scolorG = 255
    ENDIF
    
    
    if val>0 then
    sqz=-squeezeDotsOffset*pointsize
    else
    sqz=squeezeDotsOffset*pointsize
    endif
    
    
    //histogram modifications
    if val>0 and val>val[1] then
    plusI = val
    plusD = 0
    minusI = 0
    minusD = 0
    colorR=0
    colorG=245
    colorB=255
    elsif val>0 and val<val[1] then
    plusI = 0
    plusD = val
    minusI = 0
    minusD = 0
    colorR=0
    colorG=0
    colorB=255
    elsif val<0 and val<val[1] then
    plusI = 0
    plusD = 0
    minusI = 0
    minusD = val
    colorR=255
    colorG=0
    colorB=0
    elsif val<0 and val>val[1] then
    plusI = 0
    plusD = 0
    minusI = val
    minusD = 0
    colorR=255
    colorG=255
    colorB=0
    endif
    
    //candlesticks squeeze painting
    if CandlesticksSqueeze then
    drawcandle(open,high,low,close) coloured(colorR,colorG,colorB)
    endif
    
    RETURN plusI coloured(colorR,colorG,colorB) style(histogram,1) as "plus increase", plusD coloured(colorR,colorG,colorB) style(histogram,1) as "plus decrease", minusI coloured(colorR,colorG,colorB) style(histogram,1) as "minus increase", minusD coloured(colorR,colorG,colorB) style(histogram,1) as "minus decrease", sqz coloured(scolorR,scolorG,0) style(point,5) as "squeeze momentum"
    
    yprajapa thanked this post
    Essai_TTM-Squeeze-pro.itf
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Conversion TTM SQUEEZE PRO de Tradingview


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
maxlys @maxlys Participant
Summary

This topic contains 1 reply,
has 1 voice, and was last updated by maxlys
3 years, 5 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 10/02/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...