wahabdeen Posted March 12 Report Share Posted March 12 Please two indicator compine one indicator please helpmeOrder Block Finder V5.txtOrder Block Detector LuxAlgo.txt Quote Link to comment Share on other sites More sharing options...
4Candles Posted March 12 Report Share Posted March 12 It is very simple In pine script editor copy Both the scripts, then from second part of script remove Version info line and indicator info line and save. Example if you copy " Order Block Finder V5 " below "Order Block Detector LuxAlgo" then remove below two lines from (Order Block Finder V5) script //@version=5 indicator('Order Block Finder', overlay=true) ... and save and apply. Quote Link to comment Share on other sites More sharing options...
wahabdeen Posted March 12 Author Report Share Posted March 12 Not work friend Quote Link to comment Share on other sites More sharing options...
⭐ pyramidswaroop Posted March 12 Report Share Posted March 12 // 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=5 indicator("Order Block Detector" ,overlay=true ,max_boxes_count=500 ,max_labels_count=500 ,max_lines_count=500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ length=input.int(5,'Volume Pivot Length' ,minval=1) bull_ext_last=input.int(3,'Bullish OB ' ,minval=1 ,inline='bull') bg_bull_css=input.color(color.new(#169400,80),'' ,inline='bull') bull_css=input.color(#169400,'' ,inline='bull') bull_avg_css=input.color(color.new(#9598a1,37),'' ,inline='bull') bear_ext_last=input.int(3,'Bearish OB' ,minval=1 ,inline='bear') bg_bear_css=input.color(color.new(#ff1100,80),'' ,inline='bear') bear_css=input.color(#ff1100,'' ,inline='bear') bear_avg_css=input.color(color.new(#9598a1,37),'' ,inline='bear') line_style=input.string('⎯⎯⎯','Average Line Style' ,options= ['⎯⎯⎯','----','····']) line_width=input.int(1,'Average Line Width' ,minval=1) mitigation=input.string('Wick','Mitigation Methods' ,options= ['Wick','Close']) //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ //Line Style function get_line_style(style) => out=switchstyle '⎯⎯⎯' =>line.style_solid '----'=>line.style_dashed '····'=>line.style_dotted //Function to get order block coordinates get_coordinates(condition,top,btm,ob_val)=> varob_top =array.new_float(0) varob_btm =array.new_float(0) varob_avg =array.new_float(0) varob_left=array.new_int(0) floatob=na //Append coordinates to arrays ifcondition avg=math.avg(top,btm) array.unshift(ob_top,top) array.unshift(ob_btm,btm) array.unshift(ob_avg,avg) array.unshift(ob_left,time[length]) ob:=ob_val [ob_top,ob_btm,ob_avg,ob_left,ob] //Function to remove mitigated order blocks from coordinate arrays remove_mitigated(ob_top,ob_btm,ob_left,ob_avg,target,bull)=> mitigated=false target_array=bull?ob_btm:ob_top forelementintarget_array idx=array.indexof(target_array,element) if (bull?target<element:target>element) mitigated:=true array.remove(ob_top,idx) array.remove(ob_btm,idx) array.remove(ob_avg,idx) array.remove(ob_left,idx) mitigated //Function to set order blocks set_order_blocks(ob_top,ob_btm,ob_left,ob_avg,ext_last,bg_css,border_css,lvl_css)=> varob_box=array.new_box(0) varob_lvl=array.new_line(0) //Fill arrays with boxes/lines ifbarstate.isfirst fori=0toext_last-1 array.unshift(ob_box,box.new(na,na,na,na ,xloc=xloc.bar_time ,extend=extend.right ,bgcolor=bg_css ,border_color=color.new(border_css,70))) array.unshift(ob_lvl,line.new(na,na,na,na ,xloc=xloc.bar_time ,extend=extend.right ,color=lvl_css ,style=get_line_style(line_style) ,width=line_width)) //Set order blocks ifbarstate.islast ifarray.size(ob_top) >0 fori=0tomath.min(ext_last-1,array.size(ob_top)-1) get_box=array.get(ob_box,i) get_lvl=array.get(ob_lvl,i) box.set_lefttop(get_box,array.get(ob_left,i),array.get(ob_top,i)) box.set_rightbottom(get_box,array.get(ob_left,i),array.get(ob_btm,i)) line.set_xy1(get_lvl,array.get(ob_left,i),array.get(ob_avg,i)) line.set_xy2(get_lvl,array.get(ob_left,i)+1,array.get(ob_avg,i)) //-----------------------------------------------------------------------------} //Global elements //-----------------------------------------------------------------------------{ varos=0 vartarget_bull=0. vartarget_bear=0. n=bar_index upper=ta.highest(length) lower=ta.lowest(length) ifmitigation=='Close' target_bull:=ta.lowest(close,length) target_bear:=ta.highest(close,length) else target_bull:=lower target_bear:=upper os:=high[length] >upper?0:low[length] <lower?1:os[1] phv=ta.pivothigh(volume,length,length) //-----------------------------------------------------------------------------} //Get bullish/bearish order blocks coordinates //-----------------------------------------------------------------------------{ [bull_top ,bull_btm ,bull_avg ,bull_left ,bull_ob] =get_coordinates(phvandos==1,hl2[length],low[length],low[length]) [bear_top ,bear_btm ,bear_avg ,bear_left ,bear_ob] =get_coordinates(phvandos==0,high[length],hl2[length],high[length]) //-----------------------------------------------------------------------------} //Remove mitigated order blocks //-----------------------------------------------------------------------------{ mitigated_bull=remove_mitigated(bull_top ,bull_btm ,bull_left ,bull_avg ,target_bull ,true) mitigated_bear=remove_mitigated(bear_top ,bear_btm ,bear_left ,bear_avg ,target_bear ,false) //-----------------------------------------------------------------------------} //Display order blocks //-----------------------------------------------------------------------------{ //Set bullish order blocks set_order_blocks(bull_top ,bull_btm ,bull_left ,bull_avg ,bull_ext_last ,bg_bull_css ,bull_css ,bull_avg_css) //Set bearish order blocks set_order_blocks(bear_top ,bear_btm ,bear_left ,bear_avg ,bear_ext_last ,bg_bear_css ,bear_css ,bear_avg_css) //Show detected order blocks plot(bull_ob,'Bull OB',bull_css,2,plot.style_linebr ,offset=-length ,display=display.none) plot(bear_ob,'Bear OB',bear_css,2,plot.style_linebr ,offset=-length ,display=display.none) //-----------------------------------------------------------------------------} //Alerts //-----------------------------------------------------------------------------{ alertcondition(bull_ob,'Bullish OB Formed','Bullish order block detected') alertcondition(bear_ob,'Bearish OB Formed','bearish order block detected') alertcondition(mitigated_bull,'Bullish OB Mitigated','Bullish order block mitigated') alertcondition(mitigated_bear,'Bearish OB Mitigated','bearish order block mitigated') //-----------------------------------------------------------------------------} colors=input.string(title='Color Scheme',defval='DARK',options=['DARK','BRIGHT']) periods=input(5,'Relevant Periods to identify OB') // Required number of subsequent candles in the same direction to identify Order Block threshold=input.float(0.0,'Min. Percent move to identify OB',step=0.1) // Required minimum % move (from potential OB close to last subsequent candle to identify Order Block) usewicks=input(false,'Use whole range [High/Low] for OB marking?') // Display High/Low range for each OB instead of Open/Low for Bullish / Open/High for Bearish showbull=input(true,'Show latest Bullish Channel?') // Show Channel for latest Bullish OB? showbear=input(true,'Show latest Bearish Channel?') // Show Channel for latest Bearish OB? showdocu=input(false,'Show Label for documentation tooltip?') // Show Label which shows documentation as tooltip? info_pan=input(false,'Show Latest OB Panel?') // Show Info Panel with latest OB Stats ob_period=periods+1 // Identify location of relevant Order Block candle absmove=math.abs(close[ob_period] -close[1]) /close[ob_period] *100 // Calculate absolute percent move from potential OB to last candle of subsequent candles relmove=absmove>=threshold // Identify "Relevant move" by comparing the absolute move to the threshold // Color Scheme bullcolor=colors=='DARK'?color.white:color.green bearcolor=colors=='DARK'?color.blue:color.red // Bullish Order Block Identification bullishOB=close[ob_period] <open[ob_period] // Determine potential Bullish OB candle (red candle) intupcandles=0 fori=1toperiodsby1 upcandles+= (close[i] >open[i] ?1:0) // Determine color of subsequent candles (must all be green to identify a valid Bearish OB) upcandles OB_bull=bullishOBandupcandles==periodsandrelmove // Identification logic (red OB candle & subsequent green candles) OB_bull_high=OB_bull?usewicks?high[ob_period] :open[ob_period] :na // Determine OB upper limit (Open or High depending on input) OB_bull_low=OB_bull?low[ob_period] :na // Determine OB lower limit (Low) OB_bull_avg= (OB_bull_high+OB_bull_low) /2 // Determine OB middle line // Bearish Order Block Identification bearishOB=close[ob_period] >open[ob_period] // Determine potential Bearish OB candle (green candle) intdowncandles=0 fori=1toperiodsby1 downcandles+= (close[i] <open[i] ?1:0) // Determine color of subsequent candles (must all be red to identify a valid Bearish OB) downcandles OB_bear=bearishOBanddowncandles==periodsandrelmove // Identification logic (green OB candle & subsequent green candles) OB_bear_high=OB_bear?high[ob_period] :na // Determine OB upper limit (High) OB_bear_low=OB_bear?usewicks?low[ob_period] :open[ob_period] :na // Determine OB lower limit (Open or Low depending on input) OB_bear_avg= (OB_bear_low+OB_bear_high) /2 // Determine OB middle line // Plotting plotshape(OB_bull,title='Bullish OB',style=shape.triangleup,color=bullcolor,textcolor=bullcolor,size=size.tiny,location=location.belowbar,offset=-ob_period,text='Bullish OB') // Bullish OB Indicator bull1=plot(OB_bull_high,title='Bullish OB High',style=plot.style_linebr,color=bullcolor,offset=-ob_period,linewidth=3) // Bullish OB Upper Limit bull2=plot(OB_bull_low,title='Bullish OB Low',style=plot.style_linebr,color=bullcolor,offset=-ob_period,linewidth=3) // Bullish OB Lower Limit fill(bull1,bull2,color=bullcolor,title='Bullish OB fill',transp=0) // Fill Bullish OB plotshape(OB_bull_avg,title='Bullish OB Average',style=shape.cross,color=bullcolor,size=size.normal,location=location.absolute,offset=-ob_period) // Bullish OB Average plotshape(OB_bear,title='Bearish OB',style=shape.triangledown,color=bearcolor,textcolor=bearcolor,size=size.tiny,location=location.abovebar,offset=-ob_period,text='Bearish OB') // Bearish OB Indicator bear1=plot(OB_bear_low,title='Bearish OB Low',style=plot.style_linebr,color=bearcolor,offset=-ob_period,linewidth=3) // Bearish OB Lower Limit bear2=plot(OB_bear_high,title='Bearish OB High',style=plot.style_linebr,color=bearcolor,offset=-ob_period,linewidth=3) // Bearish OB Upper Limit fill(bear1,bear2,color=bearcolor,title='Bearish OB fill',transp=0) // Fill Bearish OB plotshape(OB_bear_avg,title='Bearish OB Average',style=shape.cross,color=bearcolor,size=size.normal,location=location.absolute,offset=-ob_period) // Bullish OB Average varlinelinebull1=na // Bullish OB average varlinelinebull2=na // Bullish OB open varlinelinebull3=na // Bullish OB low varlinelinebear1=na // Bearish OB average varlinelinebear2=na // Bearish OB high varlinelinebear3=na // Bearish OB open ifOB_bullandshowbull line.delete(linebull1) linebull1:=line.new(x1=bar_index,y1=OB_bull_avg,x2=bar_index-1,y2=OB_bull_avg,extend=extend.left,color=bullcolor,style=line.style_solid,width=1) line.delete(linebull2) linebull2:=line.new(x1=bar_index,y1=OB_bull_high,x2=bar_index-1,y2=OB_bull_high,extend=extend.left,color=bullcolor,style=line.style_dashed,width=1) line.delete(linebull3) linebull3:=line.new(x1=bar_index,y1=OB_bull_low,x2=bar_index-1,y2=OB_bull_low,extend=extend.left,color=bullcolor,style=line.style_dashed,width=1) linebull3 ifOB_bearandshowbear line.delete(linebear1) linebear1:=line.new(x1=bar_index,y1=OB_bear_avg,x2=bar_index-1,y2=OB_bear_avg,extend=extend.left,color=bearcolor,style=line.style_solid,width=1) line.delete(linebear2) linebear2:=line.new(x1=bar_index,y1=OB_bear_high,x2=bar_index-1,y2=OB_bear_high,extend=extend.left,color=bearcolor,style=line.style_dashed,width=1) line.delete(linebear3) linebear3:=line.new(x1=bar_index,y1=OB_bear_low,x2=bar_index-1,y2=OB_bear_low,extend=extend.left,color=bearcolor,style=line.style_dashed,width=1) linebear3 // Alerts for Order Blocks Detection alertcondition(OB_bull,title='New Bullish OB detected',message='New Bullish OB detected - This is NOT a BUY signal!') alertcondition(OB_bear,title='New Bearish OB detected',message='New Bearish OB detected - This is NOT a SELL signal!') // Print latest Order Blocks in Data Window varlatest_bull_high=0.0 // Variable to keep latest Bull OB high varlatest_bull_avg=0.0 // Variable to keep latest Bull OB average varlatest_bull_low=0.0 // Variable to keep latest Bull OB low varlatest_bear_high=0.0 // Variable to keep latest Bear OB high varlatest_bear_avg=0.0 // Variable to keep latest Bear OB average varlatest_bear_low=0.0 // Variable to keep latest Bear OB low // Assign latest values to variables ifOB_bull_high>0 latest_bull_high:=OB_bull_high latest_bull_high ifOB_bull_avg>0 latest_bull_avg:=OB_bull_avg latest_bull_avg ifOB_bull_low>0 latest_bull_low:=OB_bull_low latest_bull_low ifOB_bear_high>0 latest_bear_high:=OB_bear_high latest_bear_high ifOB_bear_avg>0 latest_bear_avg:=OB_bear_avg latest_bear_avg ifOB_bear_low>0 latest_bear_low:=OB_bear_low latest_bear_low // Plot invisible characters to be able to show the values in the Data Window plotchar(latest_bull_high,char=' ',location=location.abovebar,color=color.new(#777777,100),size=size.tiny,title='Latest Bull High') plotchar(latest_bull_avg,char=' ',location=location.abovebar,color=color.new(#777777,100),size=size.tiny,title='Latest Bull Avg') plotchar(latest_bull_low,char=' ',location=location.abovebar,color=color.new(#777777,100),size=size.tiny,title='Latest Bull Low') plotchar(latest_bear_high,char=' ',location=location.abovebar,color=color.new(#777777,100),size=size.tiny,title='Latest Bear High') plotchar(latest_bear_avg,char=' ',location=location.abovebar,color=color.new(#777777,100),size=size.tiny,title='Latest Bear Avg') plotchar(latest_bear_low,char=' ',location=location.abovebar,color=color.new(#777777,100),size=size.tiny,title='Latest Bear Low') //InfoPanel for latest Order Blocks draw_InfoPanel(_text,_x,_y,font_size) => varlabella_panel=na label.delete(la_panel) la_panel:=label.new(x=_x,y=_y,text=_text,xloc=xloc.bar_time,yloc=yloc.price,color=color.new(#383838,5),style=label.style_label_left,textcolor=color.white,size=font_size) la_panel info_panel_x=time_close+math.round(ta.change(time) *100) info_panel_y=close title='LATEST ORDER BLOCKS' row0='-----------------------------------------------------' row1=' Bullish - High: '+str.tostring(latest_bull_high,'#.##') row2=' Bullish - Avg: '+str.tostring(latest_bull_avg,'#.##') row3=' Bullish - Low: '+str.tostring(latest_bull_low,'#.##') row4='-----------------------------------------------------' row5=' Bearish - High: '+str.tostring(latest_bear_high,'#.##') row6=' Bearish - Avg: '+str.tostring(latest_bear_avg,'#.##') row7=' Bearish - Low: '+str.tostring(latest_bear_low,'#.##') panel_text='\n'+title+'\n'+row0+'\n'+row1+'\n'+row2+'\n'+row3+'\n'+row4+'\n\n'+row5+'\n'+row6+'\n'+row7+'\n' ifinfo_pan draw_InfoPanel(panel_text,info_panel_x,info_panel_y,size.normal) // === Label for Documentation/Tooltip === chper=time-time[1] chper:=ta.change(chper) >0?chper[1] :chper // === Tooltip text === varvartooltip='Indicator to help identifying instituational Order Blocks. Often these blocks signal the beginning of a strong move, but there is a high probability, that these prices will be revisited at a later point in time again and therefore are interesting levels to place limit orders. \nBullish Order block is the last down candle before a sequence of up candles. \nBearish Order Block is the last up candle before a sequence of down candles. \nIn the settings the number of required sequential candles can be adjusted. \nFurthermore a %-threshold can be entered which the sequential move needs to achieve in order to validate a relevant Order Block. \nChannels for the last Bullish/Bearish Block can be shown/hidden.' // === Print Label === varlabell_docu=na label.delete(l_docu) ifshowdocu l_docu:=label.new(x=time+chper*35,y=close,text='DOCU OB',color=color.gray,textcolor=color.white,style=label.style_label_center,xloc=xloc.bar_time,yloc=yloc.price,size=size.tiny,textalign=text.align_left,tooltip=vartooltip) l_docu Quote Link to comment Share on other sites More sharing options...
wahabdeen Posted March 12 Author Report Share Posted March 12 thanks for your help not worked ERROR Error at 37:42 Syntax error at input '⎯⎯⎯' Quote Link to comment Share on other sites More sharing options...
4Candles Posted March 12 Report Share Posted March 12 (edited) I tried & it works for me. Please ignore the link unable to provied link nor delete. Apologies 4shared.com - free file sharing and storage Edited March 12 by 4Candles Quote Link to comment Share on other sites More sharing options...
4Candles Posted March 12 Report Share Posted March 12 // 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=5 indicator("Order Block Detector [LuxAlgo]" , overlay = true , max_boxes_count = 500 , max_labels_count = 500 , max_lines_count = 500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ length = input.int(5, 'Volume Pivot Length' , minval = 1) bull_ext_last = input.int(3, 'Bullish OB ' , minval = 1 , inline = 'bull') bg_bull_css = input.color(color.new(#169400, 80), '' , inline = 'bull') bull_css = input.color(#169400, '' , inline = 'bull') bull_avg_css = input.color(color.new(#9598a1, 37), '' , inline = 'bull') bear_ext_last = input.int(3, 'Bearish OB' , minval = 1 , inline = 'bear') bg_bear_css = input.color(color.new(#ff1100, 80), '' , inline = 'bear') bear_css = input.color(#ff1100, '' , inline = 'bear') bear_avg_css = input.color(color.new(#9598a1, 37), '' , inline = 'bear') line_style = input.string('⎯⎯⎯', 'Average Line Style' , options = ['⎯⎯⎯', '----', '····']) line_width = input.int(1, 'Average Line Width' , minval = 1) mitigation = input.string('Wick', 'Mitigation Methods' , options = ['Wick', 'Close']) //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ //Line Style function get_line_style(style) => out = switch style '⎯⎯⎯' => line.style_solid '----' => line.style_dashed '····' => line.style_dotted //Function to get order block coordinates get_coordinates(condition, top, btm, ob_val)=> var ob_top = array.new_float(0) var ob_btm = array.new_float(0) var ob_avg = array.new_float(0) var ob_left = array.new_int(0) float ob = na //Append coordinates to arrays if condition avg = math.avg(top, btm) array.unshift(ob_top, top) array.unshift(ob_btm, btm) array.unshift(ob_avg, avg) array.unshift(ob_left, time[length]) ob := ob_val [ob_top, ob_btm, ob_avg, ob_left, ob] //Function to remove mitigated order blocks from coordinate arrays remove_mitigated(ob_top, ob_btm, ob_left, ob_avg, target, bull)=> mitigated = false target_array = bull ? ob_btm : ob_top for element in target_array idx = array.indexof(target_array, element) if (bull ? target < element : target > element) mitigated := true array.remove(ob_top, idx) array.remove(ob_btm, idx) array.remove(ob_avg, idx) array.remove(ob_left, idx) mitigated //Function to set order blocks set_order_blocks(ob_top, ob_btm, ob_left, ob_avg, ext_last, bg_css, border_css, lvl_css)=> var ob_box = array.new_box(0) var ob_lvl = array.new_line(0) //Fill arrays with boxes/lines if barstate.isfirst for i = 0 to ext_last-1 array.unshift(ob_box, box.new(na,na,na,na , xloc = xloc.bar_time , extend= extend.right , bgcolor = bg_css , border_color = color.new(border_css, 70))) array.unshift(ob_lvl, line.new(na,na,na,na , xloc = xloc.bar_time , extend = extend.right , color = lvl_css , style = get_line_style(line_style) , width = line_width)) //Set order blocks if barstate.islast if array.size(ob_top) > 0 for i = 0 to math.min(ext_last-1, array.size(ob_top)-1) get_box = array.get(ob_box, i) get_lvl = array.get(ob_lvl, i) box.set_lefttop(get_box, array.get(ob_left, i), array.get(ob_top, i)) box.set_rightbottom(get_box, array.get(ob_left, i), array.get(ob_btm, i)) line.set_xy1(get_lvl, array.get(ob_left, i), array.get(ob_avg, i)) line.set_xy2(get_lvl, array.get(ob_left, i)+1, array.get(ob_avg, i)) //-----------------------------------------------------------------------------} //Global elements //-----------------------------------------------------------------------------{ var os = 0 var target_bull = 0. var target_bear = 0. n = bar_index upper = ta.highest(length) lower = ta.lowest(length) if mitigation == 'Close' target_bull := ta.lowest(close, length) target_bear := ta.highest(close, length) else target_bull := lower target_bear := upper os := high[length] > upper ? 0 : low[length] < lower ? 1 : os[1] phv = ta.pivothigh(volume, length, length) //-----------------------------------------------------------------------------} //Get bullish/bearish order blocks coordinates //-----------------------------------------------------------------------------{ [bull_top , bull_btm , bull_avg , bull_left , bull_ob] = get_coordinates(phv and os == 1, hl2[length], low[length], low[length]) [bear_top , bear_btm , bear_avg , bear_left , bear_ob] = get_coordinates(phv and os == 0, high[length], hl2[length], high[length]) //-----------------------------------------------------------------------------} //Remove mitigated order blocks //-----------------------------------------------------------------------------{ mitigated_bull = remove_mitigated(bull_top , bull_btm , bull_left , bull_avg , target_bull , true) mitigated_bear = remove_mitigated(bear_top , bear_btm , bear_left , bear_avg , target_bear , false) //-----------------------------------------------------------------------------} //Display order blocks //-----------------------------------------------------------------------------{ //Set bullish order blocks set_order_blocks(bull_top , bull_btm , bull_left , bull_avg , bull_ext_last , bg_bull_css , bull_css , bull_avg_css) //Set bearish order blocks set_order_blocks(bear_top , bear_btm , bear_left , bear_avg , bear_ext_last , bg_bear_css , bear_css , bear_avg_css) //Show detected order blocks plot(bull_ob, 'Bull OB', bull_css, 2, plot.style_linebr , offset = -length , display = display.none) plot(bear_ob, 'Bear OB', bear_css, 2, plot.style_linebr , offset = -length , display = display.none) //-----------------------------------------------------------------------------} //Alerts //-----------------------------------------------------------------------------{ alertcondition(bull_ob, 'Bullish OB Formed', 'Bullish order block detected') alertcondition(bear_ob, 'Bearish OB Formed', 'bearish order block detected') alertcondition(mitigated_bull, 'Bullish OB Mitigated', 'Bullish order block mitigated') alertcondition(mitigated_bear, 'Bearish OB Mitigated', 'bearish order block mitigated') //-----------------------------------------------------------------------------} // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © wugamlo // This experimental Indicator helps identifying instituational Order Blocks. // Often these blocks signal the beginning of a strong move, but there is a significant probability that these price levels will be revisited at a later point in time again. // Therefore these are interesting levels to place limit orders (Buy Orders for Bullish OB / Sell Orders for Bearish OB). // // A Bullish Order block is defined as the last down candle before a sequence of up candles. (Relevant price range "Open" to "Low" is marked) / Optionally full range "High" to "Low" // A Bearish Order Block is defined as the last up candle before a sequence of down candles. (Relevant price range "Open" to "High" is marked) / Optionally full range "High" to "Low" // // In the settings the number of required sequential candles can be adjusted. // Furthermore a %-threshold can be entered. It defines which %-change the sequential move needs to achieve in order to identify a relevant Order Block. // Channels for the last Bullish/Bearish Block can be shown/hidden. // // In addition to the upper/lower limits of each Order Block, also the equlibrium (average value) is marked as this is an interesting area for price interaction. // // Alerts added: Alerts fire when an Order Block is detected. The delay is based on the "Relevant Periods" input. Means with the default setting "5" the alert will trigger after the // number of consecutive candles is reached. colors = input.string(title='Color Scheme', defval='DARK', options=['DARK', 'BRIGHT']) periods = input(5, 'Relevant Periods to identify OB') // Required number of subsequent candles in the same direction to identify Order Block threshold = input.float(0.0, 'Min. Percent move to identify OB', step=0.1) // Required minimum % move (from potential OB close to last subsequent candle to identify Order Block) usewicks = input(false, 'Use whole range [High/Low] for OB marking?') // Display High/Low range for each OB instead of Open/Low for Bullish / Open/High for Bearish showbull = input(true, 'Show latest Bullish Channel?') // Show Channel for latest Bullish OB? showbear = input(true, 'Show latest Bearish Channel?') // Show Channel for latest Bearish OB? showdocu = input(false, 'Show Label for documentation tooltip?') // Show Label which shows documentation as tooltip? info_pan = input(false, 'Show Latest OB Panel?') // Show Info Panel with latest OB Stats ob_period = periods + 1 // Identify location of relevant Order Block candle absmove = math.abs(close[ob_period] - close[1]) / close[ob_period] * 100 // Calculate absolute percent move from potential OB to last candle of subsequent candles relmove = absmove >= threshold // Identify "Relevant move" by comparing the absolute move to the threshold // Color Scheme bullcolor = colors == 'DARK' ? color.white : color.green bearcolor = colors == 'DARK' ? color.blue : color.red // Bullish Order Block Identification bullishOB = close[ob_period] < open[ob_period] // Determine potential Bullish OB candle (red candle) int upcandles = 0 for i = 1 to periods by 1 upcandles += (close > open ? 1 : 0) // Determine color of subsequent candles (must all be green to identify a valid Bearish OB) upcandles OB_bull = bullishOB and upcandles == periods and relmove // Identification logic (red OB candle & subsequent green candles) OB_bull_high = OB_bull ? usewicks ? high[ob_period] : open[ob_period] : na // Determine OB upper limit (Open or High depending on input) OB_bull_low = OB_bull ? low[ob_period] : na // Determine OB lower limit (Low) OB_bull_avg = (OB_bull_high + OB_bull_low) / 2 // Determine OB middle line // Bearish Order Block Identification bearishOB = close[ob_period] > open[ob_period] // Determine potential Bearish OB candle (green candle) int downcandles = 0 for i = 1 to periods by 1 downcandles += (close < open ? 1 : 0) // Determine color of subsequent candles (must all be red to identify a valid Bearish OB) downcandles OB_bear = bearishOB and downcandles == periods and relmove // Identification logic (green OB candle & subsequent green candles) OB_bear_high = OB_bear ? high[ob_period] : na // Determine OB upper limit (High) OB_bear_low = OB_bear ? usewicks ? low[ob_period] : open[ob_period] : na // Determine OB lower limit (Open or Low depending on input) OB_bear_avg = (OB_bear_low + OB_bear_high) / 2 // Determine OB middle line // Plotting plotshape(OB_bull, title='Bullish OB', style=shape.triangleup, color=bullcolor, textcolor=bullcolor, size=size.tiny, location=location.belowbar, offset=-ob_period, text='Bullish OB') // Bullish OB Indicator bull1 = plot(OB_bull_high, title='Bullish OB High', style=plot.style_linebr, color=bullcolor, offset=-ob_period, linewidth=3) // Bullish OB Upper Limit bull2 = plot(OB_bull_low, title='Bullish OB Low', style=plot.style_linebr, color=bullcolor, offset=-ob_period, linewidth=3) // Bullish OB Lower Limit fill(bull1, bull2, color=bullcolor, title='Bullish OB fill', transp=0) // Fill Bullish OB plotshape(OB_bull_avg, title='Bullish OB Average', style=shape.cross, color=bullcolor, size=size.normal, location=location.absolute, offset=-ob_period) // Bullish OB Average plotshape(OB_bear, title='Bearish OB', style=shape.triangledown, color=bearcolor, textcolor=bearcolor, size=size.tiny, location=location.abovebar, offset=-ob_period, text='Bearish OB') // Bearish OB Indicator bear1 = plot(OB_bear_low, title='Bearish OB Low', style=plot.style_linebr, color=bearcolor, offset=-ob_period, linewidth=3) // Bearish OB Lower Limit bear2 = plot(OB_bear_high, title='Bearish OB High', style=plot.style_linebr, color=bearcolor, offset=-ob_period, linewidth=3) // Bearish OB Upper Limit fill(bear1, bear2, color=bearcolor, title='Bearish OB fill', transp=0) // Fill Bearish OB plotshape(OB_bear_avg, title='Bearish OB Average', style=shape.cross, color=bearcolor, size=size.normal, location=location.absolute, offset=-ob_period) // Bullish OB Average var line linebull1 = na // Bullish OB average var line linebull2 = na // Bullish OB open var line linebull3 = na // Bullish OB low var line linebear1 = na // Bearish OB average var line linebear2 = na // Bearish OB high var line linebear3 = na // Bearish OB open if OB_bull and showbull line.delete(linebull1) linebull1 := line.new(x1=bar_index, y1=OB_bull_avg, x2=bar_index - 1, y2=OB_bull_avg, extend=extend.left, color=bullcolor, style=line.style_solid, width=1) line.delete(linebull2) linebull2 := line.new(x1=bar_index, y1=OB_bull_high, x2=bar_index - 1, y2=OB_bull_high, extend=extend.left, color=bullcolor, style=line.style_dashed, width=1) line.delete(linebull3) linebull3 := line.new(x1=bar_index, y1=OB_bull_low, x2=bar_index - 1, y2=OB_bull_low, extend=extend.left, color=bullcolor, style=line.style_dashed, width=1) linebull3 if OB_bear and showbear line.delete(linebear1) linebear1 := line.new(x1=bar_index, y1=OB_bear_avg, x2=bar_index - 1, y2=OB_bear_avg, extend=extend.left, color=bearcolor, style=line.style_solid, width=1) line.delete(linebear2) linebear2 := line.new(x1=bar_index, y1=OB_bear_high, x2=bar_index - 1, y2=OB_bear_high, extend=extend.left, color=bearcolor, style=line.style_dashed, width=1) line.delete(linebear3) linebear3 := line.new(x1=bar_index, y1=OB_bear_low, x2=bar_index - 1, y2=OB_bear_low, extend=extend.left, color=bearcolor, style=line.style_dashed, width=1) linebear3 // Alerts for Order Blocks Detection alertcondition(OB_bull, title='New Bullish OB detected', message='New Bullish OB detected - This is NOT a BUY signal!') alertcondition(OB_bear, title='New Bearish OB detected', message='New Bearish OB detected - This is NOT a SELL signal!') // Print latest Order Blocks in Data Window var latest_bull_high = 0.0 // Variable to keep latest Bull OB high var latest_bull_avg = 0.0 // Variable to keep latest Bull OB average var latest_bull_low = 0.0 // Variable to keep latest Bull OB low var latest_bear_high = 0.0 // Variable to keep latest Bear OB high var latest_bear_avg = 0.0 // Variable to keep latest Bear OB average var latest_bear_low = 0.0 // Variable to keep latest Bear OB low // Assign latest values to variables if OB_bull_high > 0 latest_bull_high := OB_bull_high latest_bull_high if OB_bull_avg > 0 latest_bull_avg := OB_bull_avg latest_bull_avg if OB_bull_low > 0 latest_bull_low := OB_bull_low latest_bull_low if OB_bear_high > 0 latest_bear_high := OB_bear_high latest_bear_high if OB_bear_avg > 0 latest_bear_avg := OB_bear_avg latest_bear_avg if OB_bear_low > 0 latest_bear_low := OB_bear_low latest_bear_low // Plot invisible characters to be able to show the values in the Data Window plotchar(latest_bull_high, char=' ', location=location.abovebar, color=color.new(#777777, 100), size=size.tiny, title='Latest Bull High') plotchar(latest_bull_avg, char=' ', location=location.abovebar, color=color.new(#777777, 100), size=size.tiny, title='Latest Bull Avg') plotchar(latest_bull_low, char=' ', location=location.abovebar, color=color.new(#777777, 100), size=size.tiny, title='Latest Bull Low') plotchar(latest_bear_high, char=' ', location=location.abovebar, color=color.new(#777777, 100), size=size.tiny, title='Latest Bear High') plotchar(latest_bear_avg, char=' ', location=location.abovebar, color=color.new(#777777, 100), size=size.tiny, title='Latest Bear Avg') plotchar(latest_bear_low, char=' ', location=location.abovebar, color=color.new(#777777, 100), size=size.tiny, title='Latest Bear Low') //InfoPanel for latest Order Blocks draw_InfoPanel(_text, _x, _y, font_size) => var label la_panel = na label.delete(la_panel) la_panel := label.new(x=_x, y=_y, text=_text, xloc=xloc.bar_time, yloc=yloc.price, color=color.new(#383838, 5), style=label.style_label_left, textcolor=color.white, size=font_size) la_panel info_panel_x = time_close + math.round(ta.change(time) * 100) info_panel_y = close title = 'LATEST ORDER BLOCKS' row0 = '-----------------------------------------------------' row1 = ' Bullish - High: ' + str.tostring(latest_bull_high, '#.##') row2 = ' Bullish - Avg: ' + str.tostring(latest_bull_avg, '#.##') row3 = ' Bullish - Low: ' + str.tostring(latest_bull_low, '#.##') row4 = '-----------------------------------------------------' row5 = ' Bearish - High: ' + str.tostring(latest_bear_high, '#.##') row6 = ' Bearish - Avg: ' + str.tostring(latest_bear_avg, '#.##') row7 = ' Bearish - Low: ' + str.tostring(latest_bear_low, '#.##') panel_text = '\n' + title + '\n' + row0 + '\n' + row1 + '\n' + row2 + '\n' + row3 + '\n' + row4 + '\n\n' + row5 + '\n' + row6 + '\n' + row7 + '\n' if info_pan draw_InfoPanel(panel_text, info_panel_x, info_panel_y, size.normal) // === Label for Documentation/Tooltip === chper = time - time[1] chper := ta.change(chper) > 0 ? chper[1] : chper // === Tooltip text === var vartooltip = 'Indicator to help identifying instituational Order Blocks. Often these blocks signal the beginning of a strong move, but there is a high probability, that these prices will be revisited at a later point in time again and therefore are interesting levels to place limit orders. \nBullish Order block is the last down candle before a sequence of up candles. \nBearish Order Block is the last up candle before a sequence of down candles. \nIn the settings the number of required sequential candles can be adjusted. \nFurthermore a %-threshold can be entered which the sequential move needs to achieve in order to validate a relevant Order Block. \nChannels for the last Bullish/Bearish Block can be shown/hidden.' // === Print Label === var label l_docu = na label.delete(l_docu) if showdocu l_docu := label.new(x=time + chper * 35, y=close, text='DOCU OB', color=color.gray, textcolor=color.white, style=label.style_label_center, xloc=xloc.bar_time, yloc=yloc.price, size=size.tiny, textalign=text.align_left, tooltip=vartooltip) l_docu Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.