INDICADOR BULLS and BEARS TRADINGVIEW !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Forums › ProRealTime foro Español › Soporte ProBuilder › INDICADOR BULLS and BEARS TRADINGVIEW !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- This topic has 2 replies, 2 voices, and was last updated 2 months ago by NEOMKEY.
Viewing 3 posts - 1 through 3 (of 3 total)
-
-
08/23/2024 at 10:31 AM #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=5indicator(“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 valueshighest = math.max(high, open, close, low)lowest = math.min(high, open, close, low)src = (highest – lowest) / 2 + lowest// Relative Strength Index (RSI) conditionrsi_condition = ta.rsi(close, 14) > 50// Bullish and Bearish conditionsbullish_condition = src > src[1] and rsi_condition ? 100 : 0bearish_condition = src < src[1] and not rsi_condition ? 100 : 0// Super Smoother functionsuper_smoother(src, length) =>freq = (1.414 * math.pi) / lengtha = math.exp(-freq)c2 = 2 * a * math.cos(freq)c3 = -a * ac1 = 1 – c2 – c3smooth = 0.0smooth := c1 * (src + src[1]) * 0.5 + c2 * nz(smooth[1]) + c3 * nz(smooth[2])smooth// Input for length differencelength_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 conditionsma_bullish = super_smoother(bullish_condition, length_difference)if ma_bullish < 0.2ma_bullish := 0ma_bearish = super_smoother(bearish_condition, length_difference)if ma_bearish < 0.2ma_bearish := 0// _display_switch==1 Standard// Plot the super smooth moving averagesplot_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 fillingplot_lim=plot(_display_switch==1 or _display_switch==4?lim:na, display=display.none, editable=false)// Fill the areas based on conditionsfill(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 == Barplot(_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 conditionsbullish_bearish = src > src[1] and rsi_condition ? 100 : src < src[1] and not rsi_condition ? -100 : 0ma_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 inputslen3 = 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) : 0DMM = 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 = navar float SDMP = navar float SDMM = na// Calculate smoothed valuesSTR := nz(STR[1]) – (nz(STR[1]) / len3) + TRSDMP := nz(SDMP[1]) – (nz(SDMP[1]) / len3) + DMPSDMM := nz(SDMM[1]) – (nz(SDMM[1]) / len3) + DMM// Calculate DI+ and DI-DIPlus = SDMP / STR * 100DIMinus = SDMM / STR * 100// Calculate DX and Zero-lag ADX (ZADX)DX = math.abs(DIPlus – DIMinus) / (DIPlus + DIMinus) * 100Lag = (len3 – 1) / 2ZADX = ta.hma(DX + (DX – DX[Lag]), len3)if ZADX < 0ZADX := 0// RSI calculation settingsrsiLengthInput = input.int(3, minval=1, title=”RSI Length”, group=”RSI Settings”)rsiSourceInput = input.source(close, “Source”, group=”RSI Settings”)// Calculate RSIup = 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 conditionssell = ZADX > th and rsi[2] > 80 and ma_bearish <= signal_th and _display_switch==4buy = ZADX > th and rsi[2] < 25 and ma_bullish <= signal_th and _display_switch==4// Plot buy and sell signalsplotshape(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 disclaimertable.cell(tb, 0, 0, _display_switch_input, text_size = size.small, text_color = #cc2f3c)08/30/2024 at 11:47 AM #236895Buenas. Aquí tienes el indicador.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109//--------------------------------------------------------------------////PRC_Bulls and Bears//version = 0//30.08.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge//--------------------------------------------------------------------////-----Inputs---------------------------------------------------------////--------------------------------------------------------------------//lengthDifference=16 //Length Differencelim=5 //Length threshold//---Strategy ADX and RSI inputslen3=9 //Length ADXth=30 //Thresold ADXSignalTh=5 //Signal Threshold (decimal 0-5)rsiLenghtInput=3rsiSourceInput=closePlotSignals=0//--------------------------------------------------------------------////-----Calculate maximun and minimum values---------------------------////--------------------------------------------------------------------//maximum=highminimum=lowsrc=(maximum-minimum)/2+minimum//--------------------------------------------------------------------////-----RSI condition--------------------------------------------------////--------------------------------------------------------------------//rsiCondition=rsi[14](close)>50//--------------------------------------------------------------------////-----Bullish and Bearish conditions---------------------------------////--------------------------------------------------------------------//bullishCondition=(src>src[1] and rsiCondition)*100bearishCondition=(src<src[1] and not rsiCondition)*100//--------------------------------------------------------------------////-----Calculate Super Smooth Moving averages-------------------------////--------------------------------------------------------------------////---Bullish MAfreqbull=(1.414*3.14159)/lengthDifferenceabull=exp(-freqbull)c2bull=2*abull*cos(180/3.14159*freqbull)c3bull=-abull*abullc1bull=1-c2bull-c3bullif barindex>1 thenMABullish=c1bull*(bullishCondition+bullishCondition[1])*0.5+c2bull*MABullish[1]+c3bull*MABullish[2]elseMABullish=0endifif MABullish < 0.2 thenMABullish = 0endif//---Bearish MAfreqbear=(1.414*3.14159)/lengthDifferenceabear=exp(-freqbear)c2bear=2*abear*cos(180/3.14159*freqbear)c3bear=-abear*abearc1bear=1-c2bear-c3bearif barindex>1 thenMABearish=c1bear*(bearishCondition+bearishCondition[1])*0.5+c2bear*MABearish[1]+c3bear*MABearish[2]elseMABearish=0endifif MABearish < 0.2 thenMABearish = 0endif//--------------------------------------------------------------------////-----ADX and RSI strategy-------------------------------------------////--------------------------------------------------------------------////---Calculate True RangeTRa=max(max(high-low,abs(high-close[1])),abs(low-close[1]))//---Calculate Directional Movementif (high-high[1])>(low[1]-low) thenDMP=max(high-high[1],0)elseDMP=0endifif (low[1]-low)>(high-high[1]) thenDMM=max(low[1]-low,0)elseDMM=0endif//---Calculate Smoothed valuesif barindex>1 thenSTR=STR[1]-(STR[1]/len3)+TRaSDMP=SDMP[1]-(SDMP[1]/len3)+DMPSDMM=SDMM[1]-(SDMM[1]/len3)+DMMendif//---Calculate DI+ and DI-DIP=SDMP/STR*100DIM=SDMM/STR*100//---Calculate DX and Zero-lag ADXDX=abs(DIP-DIM)/(DIP+DIM)*100lag=(len3-1)/2ZADX=hullaverage[len3](DX+(DX-DX[lag]))if ZADX<0 thenZADX=0endif//---RSI CalculationmyRSI=rsi[rsiLenghtInput](rsiSourceInput)//---Buy and Sell SignalssellSignal=ZADX>th and myRSI[2]>80 and MABearish<=signalThbuySignal=ZADX>th and myRSI[2]<25 and MABullish<=signalTh//---Plot signalsif PlotSignals and sellSignal and not sellSignal[1] thendrawpoint(barindex,lim,2)coloured("red")elsif PlotSignals and buySignal and not buySignal[1] thendrawpoint(barindex,lim,2)coloured("green")endif//--------------------------------------------------------------------//return MABullish style(line,2)coloured(0,255,51), MABearish style(line,2) coloured(255,0,0), lim coloured("grey",5)1 user thanked author for this post.
08/30/2024 at 12:50 PM #236897 -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)