INDICADOR BULLS and BEARS TRADINGVIEW !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Forums ProRealTime foro Español Soporte ProBuilder INDICADOR BULLS and BEARS TRADINGVIEW !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Viewing 3 posts - 1 through 3 (of 3 total)
  • #236633

    Hola todos, me podéis ayudar a transcribir el siguiente indicador de Tradingview llamado Bulls and Bears. Gracias

    https://es.tradingview.com/v/m3V9AJfi/

     

    //@version=5
    indicator(“Bulls And Bears [CHE]”, overlay=false)
    //
    _display_switch_input = input.string(“Standard”, “Display”, group=”Select Display”, options=[“Standard”, “Bar”, “Oscillator”, “Standard plus signals”])
    // Assign values to the input based on the selected option
    _display_switch = _display_switch_input == ‘Standard’? 1:
     _display_switch_input == ‘Bar’? 2:
     _display_switch_input == ‘Oscillator’? 3:
     _display_switch_input == ‘Standard plus signals’? 4:1
    // Calculate maximum and minimum values
    highest = math.max(high, open, close, low)
    lowest = math.min(high, open, close, low)
    src = (highest – lowest) / 2 + lowest
    // Relative Strength Index (RSI) condition
    rsi_condition = ta.rsi(close, 14) > 50
    // Bullish and Bearish conditions
    bullish_condition = src > src[1] and rsi_condition ? 100 : 0
    bearish_condition = src < src[1] and not rsi_condition ? 100 : 0
    // Super Smoother function
    super_smoother(src, length) =>
        freq = (1.414 * math.pi) / length
        a = math.exp(-freq)
        c2 = 2 * a * math.cos(freq)
        c3 = -a * a
        c1 = 1 – c2 – c3
        smooth = 0.0
        smooth := c1 * (src + src[1]) * 0.5 + c2 * nz(smooth[1]) + c3 * nz(smooth[2])
        smooth
    // Input for length difference
    length_difference = input.int(16, title=”Length Difference”, group = “Smoothing” )
    lim = input.int(5, title=”Length threshold”, group = “Graphic”)
    // Calculate super smooth moving averages for bullish and bearish conditions
    ma_bullish = super_smoother(bullish_condition, length_difference)
    if ma_bullish < 0.2
        ma_bullish := 0
    ma_bearish = super_smoother(bearish_condition, length_difference)
    if ma_bearish < 0.2
        ma_bearish := 0
    // _display_switch==1 Standard
    // Plot the super smooth moving averages
    plot_bullish = plot(_display_switch==1 or _display_switch==4?ma_bullish:na, “”, color=color.rgb(0, 255, 51))
    plot_bearish = plot(_display_switch==1 or _display_switch==4?ma_bearish:na, “”, color=color.rgb(255, 0, 0))
    // Plot to enable filling
    plot_lim=plot(_display_switch==1 or _display_switch==4?lim:na, display=display.none, editable=false)
    // Fill the areas based on conditions
    fill(plot_lim, plot_bullish, color=ma_bullish[1] < lim and _display_switch ? color.rgb(0, 255, 51, 50) : na)
    fill(plot_lim, plot_bearish, color=ma_bearish[1] < lim and _display_switch ? color.rgb(255, 0, 0, 50) : na)
    // _display_switch == Bar
    plot(_display_switch==2?bullish_condition:na,”Columns”,color=color.rgb(0, 255, 51), style=plot.style_columns)
    plot(_display_switch==2?bearish_condition:na,”Columns”,color=color.rgb(255, 0, 0), style=plot.style_columns)
    // _display_switch == Oscillator
    // Bullish and Bearish conditions
    bullish_bearish = src > src[1] and rsi_condition ? 100 : src < src[1] and not rsi_condition ? -100 : 0
    ma_oscillator = super_smoother(bullish_bearish, length_difference)
    plot(_display_switch==3?ma_oscillator:na,”Oscillator”, color=ma_oscillator>=0?color.rgb(0, 255, 51):color.rgb(255, 0, 0))
    midline = hline(0, “Middle Band”, _display_switch==3?color.new(#787B86, 50):na)
    // Add some useful Buy and Sell Signal
    //Custom ADX and RSI Strategy
    // User inputs
    len3 = input(9, “Length ADX”, group = “ADX Setting”)
    th = input(30, “Threshold”, group = “ADX Setting”)
    signal_th = input.float(5, minval=0, maxval=5, step=0.2, group = “Signal Threshold”)
    // Calculate True Range (TR)
    TR = math.max(math.max(high – low, math.abs(high – nz(close[1]))), math.abs(low – nz(close[1])))
    // Calculate Directional Movement (DMP and DMM)
    DMP = high – nz(high[1]) > nz(low[1]) – low ? math.max(high – nz(high[1]), 0) : 0
    DMM = nz(low[1]) – low > high – nz(high[1]) ? math.max(nz(low[1]) – low, 0) : 0
    // Initialize variables for Smoothed True Range (STR), Smoothed DMP (SDMP), and Smoothed DMM (SDMM)
    var float STR = na
    var float SDMP = na
    var float SDMM = na
    // Calculate smoothed values
    STR := nz(STR[1]) – (nz(STR[1]) / len3) + TR
    SDMP := nz(SDMP[1]) – (nz(SDMP[1]) / len3) + DMP
    SDMM := nz(SDMM[1]) – (nz(SDMM[1]) / len3) + DMM
    // Calculate DI+ and DI-
    DIPlus = SDMP / STR * 100
    DIMinus = SDMM / STR * 100
    // Calculate DX and Zero-lag ADX (ZADX)
    DX = math.abs(DIPlus – DIMinus) / (DIPlus + DIMinus) * 100
    Lag = (len3 – 1) / 2
    ZADX = ta.hma(DX + (DX – DX[Lag]), len3)
    if ZADX < 0
        ZADX := 0
    // RSI calculation settings
    rsiLengthInput = input.int(3, minval=1, title=”RSI Length”, group=”RSI Settings”)
    rsiSourceInput = input.source(close, “Source”, group=”RSI Settings”)
    // Calculate RSI
    up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
    down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
    rsi = down == 0 ? 100 : up == 0 ? 0 : 100 – (100 / (1 + up / down))
    // Buy and sell conditions
    sell = ZADX > th and rsi[2] > 80 and ma_bearish <= signal_th and _display_switch==4
    buy = ZADX > th and rsi[2] < 25 and ma_bullish <= signal_th and _display_switch==4
    // Plot buy and sell signals
    plotshape(buy and not buy[1]  ? lim : na, title=”Buy”, location=location.absolute, style=shape.circle, size=size.tiny, color=color.green)
    plotshape(sell and not sell[1]? lim : na, title=”Sell”, location=location.absolute, style=shape.circle, size=size.tiny, color=color.red)
    //—-
    bool disclaimer = input(false, ‘Hide Disclaimer’, group = “Disclaimer”)
    var tb = table.new(position.top_right, 1, 1
      , bgcolor = #35202b)
    if barstate.isfirst and not disclaimer
        table.cell(tb, 0, 0, _display_switch_input
          , text_size = size.small
          , text_color = #cc2f3c)
    #236895

    Buenas. Aquí tienes el indicador.

    1 user thanked author for this post.
    #236897

    Muchas gracias Iván. Excelente trabajo como siempre…..yo sigo deseando que publiques tu artillería pesada de indicadores personales…..jajjaja. Muchas gracias de nuevo,

Viewing 3 posts - 1 through 3 (of 3 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login