INDICADOR SWEEP |||||||||||||||||||||||||
Forums › ProRealTime foro Español › Soporte ProBuilder › INDICADOR SWEEP |||||||||||||||||||||||||
- This topic has 15 replies, 4 voices, and was last updated 4 months ago by NEOMKEY.
-
-
02/28/2024 at 1:23 AM #228909
Hola todos, me podéis ayudar a transcribir el siguiente indicador de Tradingview llamado Sweep Institutional. Gracias
//@version=5indicator(‘Sweep institutional’, overlay=true, max_lines_count=500, max_labels_count = 500)//INPUTScooldownPeriod = input.int(10,title=”Cooldown Period”, minval=0, group = “Settings”)lbLeft = 20lbRight = 20showSwing = input.bool(true,title=”Show Swings?”, inline=”s_1″, group = ‘Swing Detaction’)swingClr = input.color(color.new(color.black, 0), title=”, inline=”s_1″, group = ‘Swing Detaction’)bullWidth = input.int(1, title=’Line Width:’, group=’Bullish Sweep’)bullStyle = input.string(‘Dashed’, title=’Line Style:’, options=[‘Solid’, ‘Dotted’, ‘Dashed’], group=’Bullish Sweep’)bullColor = input.color(color.new(color.teal, 0), title=’Bullish Color:’, group=’Bullish Sweep’)bearWidth = input.int(1, title=’Line Width:’, group=’Bearish Sweep’)bearStyle = input.string(‘Dashed’, title=’Line Style:’, options=[‘Solid’, ‘Dotted’, ‘Dashed’], group=’Bearish Sweep’)bearColor = input.color(color.new(color.maroon, 0), title=’Bearish Color:’, group=’Bearish Sweep’)//FUNCTIONSlineStyle(s) =>if s == ‘Solid’line.style_solidelse if s == ‘Dotted’line.style_dottedelseline.style_dashed//VARSvar int bullSignalIndex = 0var int bearSignalIndex = 0var line bullLine = navar line bearLine = navar line highLine = navar line lowLine = navar label swingHighLbl = navar label swingLowLbl = navar label swingHighLblTxt = navar label swingLowLblTxt = navar float swingLowVal = navar float swingHighVal = na//CALCULATIONSpLow = ta.pivotlow(low, lbLeft, lbRight)pHigh = ta.pivothigh(high, lbLeft, lbRight)pLowVal = ta.valuewhen(not na(pLow), low[lbRight], 0)pHighVal = ta.valuewhen(not na(pHigh), high[lbRight], 0)prevLowIndex = ta.valuewhen(not na(pLow), bar_index[lbRight], 0)prevHighIndex = ta.valuewhen(not na(pHigh), bar_index[lbRight], 0)lp = ta.lowest(low, lbLeft)hp = ta.highest(high, lbLeft)highestClose = ta.highest(close, lbLeft)lowestClose = ta.lowest(close, lbLeft)bullishSFP = low < pLowVal and close > pLowVal and open > pLowVal and low == lp and lowestClose >= pLowValbearishSFP = high > pHighVal and close < pHighVal and open < pHighVal and high == hp and highestClose <= pHighValbullCond = bullishSFP[3] and (close > pLowVal) and (close[1] > pLowVal[1]) and (close[2] > pLowVal[2]) and bar_index >= bullSignalIndex + cooldownPeriodbearCond = bearishSFP[3] and (close < pHighVal) and (close[1] < pHighVal[1]) and (close[2] < pHighVal[2]) and bar_index >= bearSignalIndex + cooldownPeriod//Check Swing H/L Stoppervar int swingLowCounter = 0var int swingHighCounter = 0var bool isSwingLowCheck = falsevar bool isSwingHighCheck = falsevar bool stopPrintingLow = falsevar bool stopPrintingHigh = falseif high < swingLowVal and isSwingLowCheckswingLowCounter := swingLowCounter+1if low > swingHighVal and isSwingHighCheckswingHighCounter := swingHighCounter+1if ta.crossunder(close, swingLowVal) and isSwingLowCheck == falseisSwingLowCheck := trueswingLowCounter := 1if ta.crossover(close, swingHighVal) and isSwingHighCheck == falseisSwingHighCheck := trueswingHighCounter := 1if swingLowCounter == 5 and isSwingLowCheckstopPrintingLow := trueisSwingLowCheck := falseline.set_x2(lowLine,bar_index[4])if swingHighCounter == 5 and isSwingHighCheckstopPrintingHigh := trueisSwingHighCheck := falseline.set_x2(highLine,bar_index[4])//Draw sweep linesif bullCondbullSignalIndex := bar_indexbullLine := line.new(prevLowIndex, pLowVal, bar_index-3, pLowVal, color=bullColor, width=bullWidth, style=lineStyle(bullStyle))if bearCondbearSignalIndex := bar_indexbearLine := line.new(prevHighIndex, pHighVal, bar_index-3, pHighVal, color=bearColor, width=bearWidth, style=lineStyle(bearStyle))var swingHighArr = array.new_label(0)var swingHighTextArr = array.new_label(0)var swingLowArr = array.new_label(0)var swingLowTextArr = array.new_label(0)if array.size(swingHighArr) >= 3label.delete(array.shift(swingHighArr))label.delete(array.shift(swingHighTextArr))if array.size(swingLowArr) >= 3label.delete(array.shift(swingLowArr))label.delete(array.shift(swingLowTextArr))//Draw range linesif showSwingifstopPrintingHigh==falseline.set_x2(highLine,bar_index+5)if stopPrintingLow == falseline.set_x2(lowLine,bar_index+5)if showSwing and not na(pHigh) and bearishSFP[lbRight] == falsestopPrintingHigh := falseswingHighVal := high[lbRight]line.delete(highLine)highLine := line.new(bar_index[lbRight], high[lbRight], bar_index+10, high[lbRight], color = swingClr, width = 2)swingHighLbl := label.new(bar_index[lbRight], high[lbRight], text=””, yloc=yloc.abovebar, color = swingClr, textcolor = swingClr, style = label.style_triangledown, size = size.auto)swingHighLblTxt := label.new(bar_index[lbRight], high[lbRight], text=”Swing\nH”, yloc=yloc.abovebar, color = swingClr, textcolor = swingClr, style = label.style_none, size = size.small)array.push(swingHighArr, swingHighLbl)array.push(swingHighTextArr, swingHighLblTxt)if showSwing and not na(pLow) and bullishSFP[lbRight] == falsestopPrintingLow := falseswingLowVal := low[lbRight]line.delete(lowLine)lowLine := line.new(bar_index[lbRight], low[lbRight], bar_index+10, low[lbRight], color = swingClr, width = 2)swingLowLbl := label.new(bar_index[lbRight], low[lbRight], text=””, yloc=yloc.belowbar, color = swingClr, textcolor = swingClr, style = label.style_triangleup, size = size.auto)swingLowLblTxt := label.new(bar_index[lbRight], low[lbRight], text=”Swing\nL”, yloc=yloc.belowbar, color = swingClr, textcolor = swingClr, style = label.style_none, size = size.small)array.push(swingLowArr, swingLowLbl)array.push(swingLowTextArr, swingLowLblTxt)//PLOTSplotshape(bullCond, text=’Sweep’, color=bullColor, textcolor=bullColor, location=location.belowbar, offset = -3)plotshape(bearCond, text=’Sweep’, color=bearColor, textcolor=bearColor, location=location.abovebar, offset = -3)//ALERTSalertcondition(bullishSFP, title=’Bullish Sweep’, message='{{ticker}} Bullish Sweep, Price:{{close}}’)alertcondition(bearishSFP, title=’Bearish Sweep’, message='{{ticker}} Bearish Sweep, Price:{{close}}’)02/28/2024 at 3:53 PM #228942Muy buenas
Aquí tienes el código:
PRC_Sweep Institucional1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980//PRC_Sweep Institucional//version = 0//28.02.24//Iván González @ www.prorealcode.com//Sharing ProRealTime knowledge////////////////////////////////////////////////////////////inputs////////////////////////////cooldownPeriod =10 //"Cooldown Period"prd = 20src1 = lowsrc2 = highshowswing = 1////////Calculations///////////////////////////////pivots lowif src1 > src1[prd] and lowest[prd](src1) > src1[prd] and src1[prd] < lowest[prd](src1)[prd+1] then$prevpivotlowy[lastset($prevpivotlowy)+1] = $pivotlowy[max(lastset($pivotlowy),1)]$prevpivotlowx[lastset($prevpivotlowx)+1] = $pivotlowx[max(lastset($pivotlowx),1)]$pivotlowy[lastset($pivotlowy)+1] = src1[prd]$pivotlowx[lastset($pivotlowx)+1] = barindex[prd]z = z + 1drawpoint(barindex[prd],src1[prd],1)coloured("White")drawtext("L",barindex[prd],src1[prd]-0.5*tr)coloured("green")endif/////pivots highif src2 < src2[prd] and highest[prd](src2)<src2[prd] and src2[prd]>highest[prd](src2)[prd+1] then$prevpivothighy[lastset($prevpivothighy)+1] = $pivothighy[max(lastset($pivothighy),1)]$prevpivothighx[lastset($prevpivothighx)+1] = $pivothighx[max(lastset($pivothighx),1)]$pivothighy[lastset($pivothighy)+1]=src2[prd]$pivothighx[lastset($pivothighx)+1]=barindex[prd]t=t+1drawpoint(barindex[prd],src2[prd],1)coloured("White")drawtext("H",barindex[prd],src2[prd]+0.5*tr)coloured("red")endif////////////////////////////////////////////////////////pLow = $pivotlowy[max(1,lastset($pivotlowy))]pHigh = $pivothighy[max(1,lastset($pivothighy))]pLowindex = $pivotlowx[max(1,lastset($pivotlowx))]pHighindex = $pivothighx[max(1,lastset($pivothighx))]lp = lowest[prd](low)hp = highest[prd](high)lowestclose = lowest[prd](close)highestclose = highest[prd](close)////////////////////////Sweep conditions///////////////////////////////////////////bullishSFP = low < pLow and close > pLow and open > pLow and low = lp and lowestClose >= pLowbearishSFP = high > pHigh and close < pHigh and open < pHigh and high = hp and highestClose <= pHighbullCond = bullishSFP[3] and (close > pLow) and (close[1] > pLow[1]) and (close[2] > pLow[2]) and barindex >= bullSignalIndex + cooldownPeriodbearCond = bearishSFP[3] and (close < pHigh) and (close[1] < pHigh[1]) and (close[2] < pHigh[2]) and barindex >= bearSignalIndex + cooldownPeriod//Draw sweep linesif bullcond thenbullsignalindex = barindexdrawsegment(pLowindex,pLow,barindex[3],pLow)style(dottedline,2)coloured(120,255,120)drawtext("Sweep",barindex+1,plow-0.25*tr)coloured(120,255,120)elsif bearcond thenbearSignalIndex = barindexdrawsegment(pHighindex,pHigh,barindex[3],pHigh)style(dottedline,2)coloured(255,120,120)drawtext("Sweep",barindex+1,pHigh+0.25*tr)coloured(255,50,50)endifprint bearSignalIndex+cooldownPeriodprint barindex//Draw last Pivot High/Low lineif islastbarupdate thenif low > pHigh thenx = barssince(low crosses over pHigh)drawsegment(pHighindex,pHigh,barindex-x,pHigh)style(line,2)coloured("red")elsif high < pLow theny = barssince(high crosses under pLow)drawsegment(pHighindex,pHigh,barindex-y,pLow)style(line,2)coloured("green")ELSEdrawsegment(pHighindex,pHigh,barindex+10,pHigh)style(line,2)coloured("red")drawsegment(pLowindex,pLow,barindex+10,pLow)style(line,2)coloured("green")endifendifreturn02/28/2024 at 4:54 PM #22894302/29/2024 at 1:02 PM #22898202/29/2024 at 1:50 PM #228991Hola, en el código traducido, ¿ cómoswing=1 no sirve de nada?
02/29/2024 at 1:56 PM #22899202/29/2024 at 2:12 PM #228995Exacto… lo introduje al principio de la traducción de código y se me ha pasado borrarlo.
1 user thanked author for this post.
04/12/2024 at 6:52 AM #231423hola iván
¿Tiene un ejemplo de una estrategia con este indicador?
O cómo integrar la (H) (L) en una estrategia después de cuántas velas aparecen. No puedo entender bien este código.
tu ayuda sería invaluable.
Que tenga un buen día04/12/2024 at 7:52 AM #231428Hola
No lo he utilizado en una estrategia. Me limité a traducir el código de tradingview a prt.
Las H y L son pivot points, por lo tanto para que aparezcan tienen que ser los máximos y mínimos de las últimas “prd” velas por delante y por detrás.
Una forma de integrarlo en un sistema sería aprovechar para introducir órdenes cuando se produzca el barrido (Sweep), ver líneas de código 54 a 63.07/11/2024 at 6:27 PM #23511607/12/2024 at 5:31 PM #23519707/24/2024 at 3:25 PM #23572407/24/2024 at 4:23 PM #23572807/25/2024 at 11:30 AM #235761Cuando adjuntas el indicador aparece esa ventana “Modo Dinámico” y es un coñazo muy gordo. Lo que necesito es que cuando use ese indicador no aparezca, por favor, esa ventana. Muchas gracias de antemano Iván. Cojonudo tu trabajo. Enhorabuena !!!
07/25/2024 at 11:51 AM #235775 -
AuthorPosts
Find exclusive trading pro-tools on