‘Swing Failure Pattern
Forums › ProRealTime English forum › ProBuilder support › ‘Swing Failure Pattern
- This topic has 1 reply, 1 voice, and was last updated 17 hours ago by
Aragorna.
Viewing 2 posts - 1 through 2 (of 2 total)
-
-
05/03/2025 at 12:29 AM #246734Hi, I’ve found this interesting indicator for trading view. It’s be interesting to use it in a system. somone can help for conversion to PRT? thanks in advanceAlessio// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/// © LuxAlgo//@version=5indicator( ‘Swing Failure Pattern [LuxAlgo]’, ‘LuxAlgo – Swing Failure Pattern’, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500, overlay = true)//———————————————————————————————————————}//Settings//———————————————————————————————————————{sp = ‘ ‘len = input.int ( 5 , ‘Swings’ , minval= 1 )bull = input.bool ( true , ‘Bullish SFP’ )bear = input.bool ( true , ‘Bearish SFP’ )iVal = input.string (‘None’, ‘Validation’+sp+ ‘ ‘, group=’Volume Validation’, options = [‘Volume outside swing < Threshold’ ,’Volume outside swing > Threshold’,’None’])percent = input.float (25, ‘Volume Threshold %’ , inline=’valy’, group=’Volume Validation’, tooltip = ‘% of Total Volume’ , minval= 0 , maxval=100 )auto = input.bool (true, ” , inline=’auto’, group=’Volume Validation’ )mlt = input.int (50 , ‘ Auto’ + sp , inline=’auto’, group=’Volume Validation’ )res = input.timeframe(‘1′ , sp +’ LTF’ + sp +’ ‘, inline=’ltf’ , group=’Volume Validation’ )prem = input.bool (false ,’ Premium’ , group=’Volume Validation’, tooltip = ‘Premium Plan or higher’ )showDash = input.bool (true , ‘Show Dashboard’ , group= ‘Dashboard’ )dashLoc = input.string ( ‘Top Right’ , ‘Location’, options = [‘Top Right’, ‘Bottom Right’, ‘Bottom Left’] , group= ‘Dashboard’ )textSize = input.string ( ‘Normal’ , ‘Size’, options = [‘Tiny’, ‘Small’, ‘Normal’] , group= ‘Dashboard’ )dSwingLine = input.bool (true , ‘Swing Lines’ , group= ‘Style’ )dOpposLine = input.bool (true , ‘Confirmation Lines’ , group= ‘Style’ )dSFP_Line = input.bool (true , ‘Swing Failure Wick’ , group= ‘Style’ )dSFP_Label = input.bool (true , ‘Swing Failure Label’ , group= ‘Style’ )colBl = input.color (#089981 , ‘Lines / Labels’ , inline=’lin’ , group= ‘Style’ )colBr = input.color (#f23645 , ” , inline=’lin’ , group= ‘Style’, tooltip = ‘Bullish/Bearish’ )colBl2 = input.color (#08998180, ‘SFP Wicks ‘, inline=’wic’ , group= ‘Style’ )colBr2 = input.color (#f2364580, ” , inline=’wic’ , group= ‘Style’, tooltip = ‘Wick outside Swing, Bullish/Bearish’ )//—————————————————————————–}//UDT//—————————————————————————–{type pivfloat swing_prc // priceint swing_bix // bar_indexfloat oppos_prc // priceint oppos_bix // bar_indexbool activebool confirmedline swing_lineline oppos_lineline wicky_linelabel wicky_labeltypeswingint bixfloatprc//—————————————————————————–}//Variables//—————————————————————————–{n =bar_indexINV = color(na)FGc = chart.fg_colortable_position=dashLoc==’Bottom Left’?position.bottom_left:dashLoc==’Top Right’?position.top_right: position.bottom_righttable_size=textSize==’Tiny’?size.tiny:textSize==’Small’?size.small: size.normalvar tb = table.new(table_position, 2, 3, bgcolor = #1e222d, border_color = #373a46, border_width = 1, frame_color = #373a46, frame_width = 1)varswingswingH=swing.new()varswingswingL=swing.new()var piv pivH = piv.new()var piv pivL = piv.new()validate=iVal!=’None’valHigher= iVal == ‘Volume outside swing > Threshold’valLower = iVal == ‘Volume outside swing < Threshold’//———————————————————————————————————————}//Method//———————————————————————————————————————{method n(float piv) => bool out = not na(piv)//———————————————————————————————————————}//Execution//———————————————————————————————————————{tfS = timeframe.in_seconds( res )tfC = timeframe.in_seconds(timeframe.period)rs =auto?tfC/mlt:tfSif not validateres:=timeframe.periodelsers := prem ? rs : math.max(60, rs)res := timeframe.from_seconds(math.min(tfC, rs))ph = ta.pivothigh(len, 1)pl = ta.pivotlow (len, 1)[ltf_close, ltf_volume] = request.security_lower_tf(syminfo.tickerid, res, [close, volume])ltf_size = ltf_close.size()ifvalidateifltf_size>0andltf_size[1]==0line.new(n, close, n, close + syminfo.mintick, color=color.silver, style=line.style_dotted, extend=extend.both)//———————————————————————————————————————}//Bearish Pattern//———————————————————————————————————————{if bearifph.n()swingH.bix:=n-1swingH.prc:=phsw = swingH.prcbx = swingH.bixifhigh>swand open < swand close < swvalid = trueifvalidateifltf_close.size()>0outsideVolume = 0.totalVolume=ltf_volume.sum()forj=0toltf_close.size()-1if ltf_close.get(j) > swoutsideVolume += ltf_volume.get(j)if(valHigher?100/totalVolume*outsideVolume<percent:100/totalVolume*outsideVolume>percent)valid := false//if valid// label.new(n, high, text=str.format(“Total Volume: {0}\nWick Volume: {1}”, totalVolume, outsideVolume))ifvalidopposL=swopposB = nfor i = 1 to n – bx -1iflow[i]<opposLopposL := low [i]opposB := n – iif not pivH.confirmedpivH.swing_line .delete()pivH.oppos_line .delete()pivH.wicky_line .delete()pivH.wicky_label.delete()pivH := piv.new(sw, bx, opposL, opposB, true, false)ifdSwingLinepivH.swing_line := line.new (bx , sw , n, sw , color=colBr)ifdOpposLinepivH.oppos_line := line.new (opposB, opposL, n, opposL, color=colBr, style=line.style_dotted)ifdSFP_LinepivH.wicky_line := line.new (n , high , n, sw , color=colBr2, width=3)if dSFP_LabelpivH.wicky_label := label.new(n , high, style=label.style_label_down, text=’SFP’, textcolor=colBr, color=INV, size=size.normal)ifpivH.activeandnotpivH.confirmedpivH.swing_line.set_x2(n)pivH.oppos_line.set_x2(n)if close < pivH.oppos_prcpivH.confirmed := trueif pivH.wicky_label.get_x() == npivH.wicky_label.set_text(‘SFP\n▼’)elselabel.new(n, high, style=label.style_label_down, text=’▼’, textcolor=colBr, color=INV, size=size.normal)ifn-pivH.swing_bix>500or close > pivH.swing_prcpivH.active:=falseif not pivH.confirmedpivH.swing_line .delete()pivH.oppos_line .delete()pivH.wicky_line .delete()pivH.wicky_label.delete()//———————————————————————————————————————}//Bullish Pattern//———————————————————————————————————————{if bullifpl.n()swingL.bix:=n-1swingL.prc:=plsw = swingL.prcbx = swingL.bixiflow <swand open > swand close > swvalid = trueifvalidateifltf_close.size()>0outsideVolume = 0.totalVolume=ltf_volume.sum()forj=0toltf_close.size()-1if ltf_close.get(j) < swoutsideVolume += ltf_volume.get(j)if(valHigher?100/totalVolume*outsideVolume<percent:100/totalVolume*outsideVolume>percent)valid := falseifvalidopposH=swopposB = nfor i = 1 to n – bx -1ifhigh[i]>opposHopposH := high[i]opposB := n – iif not pivL.confirmedpivL.swing_line .delete()pivL.oppos_line .delete()pivL.wicky_line .delete()pivL.wicky_label.delete()pivL := piv.new(sw, bx, opposH, opposB, true, false)ifdSwingLinepivL.swing_line := line.new (bx , sw , n, sw , color=colBl )ifdOpposLinepivL.oppos_line := line.new (opposB, opposH, n, opposH, color=colBl , style=line.style_dotted)ifdSFP_LinepivL.wicky_line := line.new (n , low , n, sw , color=colBl2, width=3)if dSFP_LabelpivL.wicky_label := label.new(n , low, style=label.style_label_up, text=’SFP’, textcolor=colBl, color=INV, size=size.normal)ifpivL.activeandnotpivL.confirmedpivL.swing_line.set_x2(n)pivL.oppos_line.set_x2(n)if close > pivL.oppos_prcpivL.confirmed := trueif pivL.wicky_label.get_x() == npivL.wicky_label.set_text(‘▲\nSFP’)elselabel.new(n, low, style=label.style_label_up, text=’▲’, textcolor=colBl, color=INV, size=size.normal)ifn-pivL.swing_bix>500or close < pivL.swing_prcpivL.active:=falseif not pivL.confirmedpivL.swing_line .delete()pivL.oppos_line .delete()pivL.wicky_line .delete()pivL.wicky_label.delete()//———————————————————————————————————————}//Dashboard//———————————————————————————————————————{if barstate.islast and validate and showDashtb.cell(0, 0, str.format(“LTF: {0}”, res), text_color=color.white, text_size=table_size)//———————————————————————————————————————}05/03/2025 at 12:35 AM #246735
I add the youtube link where I found it.
thanks
https://www.youtube.com/watch?v=coVXCNjPBm4&ab_channel=TomCrown
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)