Traduzione codice TW Bull Bear power ONF

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #245657 quote
    Msport71
    Participant
    Junior

    Buongiorno,

     

    mi piacerebbe testare questo indicatore Bull Bear, che rispetto a quelli presenti aggiunge anche una EMA per una migliore interpretazione.

    Grazie per il consueto aiuto.

    https://it.tradingview.com/script/Zrc0KWJ5-Bull-Bear-Power-with-Optional-Normalization-Function/

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

    //@version=5
    indicator(“Bull/Bear Power with Normalization Function”, shorttitle=”NBBP”)

    // Inputs
    lengthInput = input.int(50, title=”BBP Length”)
    maLength = input.int(50, title=’Moving Average Length’)
    isNormalized = input.bool(true, title=’Use Normalization Function?’)

    // Math
    bullPower = high – ta.ema(close, lengthInput)
    bearPower = low – ta.ema(close, lengthInput)

    bbP = bullPower + bearPower

    bbP_h = ta.max(bbP)
    bbP_l = ta.min(bbP)
    bbP_n = ((bbP – bbP_l) / (bbP_h – bbP_l) – 0.5) * 2

    bbP_final = isNormalized ? bbP_n : bbP

    zeroLine = 0

    upCondition = ta.crossover(bbP_final, zeroLine)
    downCondition = ta.crossunder(bbP_final, zeroLine)

    movingAverage = ta.ema(bbP_final, maLength)

    // Coloration
    bbpColor = bbP_final > 0 ? color.green : color.red
    fillColor = bbP_final > 0 ? color.new(color.lime, 50) : color.new(color.fuchsia, 50)
    barcolor(bbpColor)

    // Plotting
    bbP_n_plot = plot(bbP_final, title=’Bull/Bear Power’, color=bbpColor, linewidth = 4)
    zeroLineplot = plot(zeroLine, title = ‘Zero Line’, linewidth = 3)
    plot(movingAverage, title = ‘Exponential MA’, color=color.white, linewidth = 3)
    fill(bbP_n_plot, zeroLineplot, color=fillColor)

    Screenshot-2025-04-07-at-10-40-59-Bull-Bear-Power-with-Optional-Normalization-Function-—-Indicatore-di-LeafAlgo.png Screenshot-2025-04-07-at-10-40-59-Bull-Bear-Power-with-Optional-Normalization-Function-—-Indicatore-di-LeafAlgo.png
    #245669 quote
    Iván González
    Moderator
    Master

    Ecco qui:

    // Inputs
    lengthInput = 50
    maLength = 50
    isNormalized = 1
    
    // Math
    bullPower = high - average[lengthInput,1](close)
    bearPower = low - average[lengthInput,1](close)
    
    bbP = bullPower + bearPower
    
    if barindex>lengthInput then
    bbPh = max(bbP,bbPh[1])
    bbPl = min(bbP,bbPl[1])
    bbPn = ((bbP - bbPl) / (bbPh - bbPl) - 0.5) * 2
    endif
    
    if isNormalized then
    bbPfinal = bbPn
    else
    bbPfinal = bbP
    endif
    
    zeroLine = 0
    
    upCondition = bbPfinal crosses over zeroLine 
    downCondition = bbPfinal crosses under zeroLine
    
    movingAverage = average[maLength,1](bbPfinal)
    
    if bbPfinal > 0 then
    r=0
    g=255
    else
    r=255
    g=0
    endif
    
    colorbetween(bbPfinal,0,r,g,0,50)
    //drawcandle(open,high,low,close)coloured(r,g,0)
    
    return bbPfinal as "Bull/Bear Power"coloured(r,g,0)style(line,3), zeroLine as "zero", movingAverage as "MA" coloured("blue")style(line,2)
    Msport71 thanked this post
    #245675 quote
    Msport71
    Participant
    Junior

    Grazie, molto gentile.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Traduzione codice TW Bull Bear power ONF


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
Msport71 @carlo-pasca Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Msport71
10 months, 4 weeks ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 04/07/2025
Status: Active
Attachments: 1 files
Logo Logo
Loading...