// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=5 indicator("Bos_HH_LL_v2.1",overlay=true,max_lines_count=500,max_labels_count=500) depth=input(1000,"Глубина") colHH=input(color.gray,"color HH","text color HH","colorfront","Text color") colLH=input(color.gray,"color LH","text color LH","colorfront","Text color") colHL=input(color.gray,"color HL","text color HL","colorfront","Text color") colLL=input(color.gray,"color LL","text color LL","colorfront","Text color") colHHbg=input(color.navy,"color HH","background color HH","inline=colorbg","Background color") colLHbg=input(color.navy,"color LH","background color LH","inline=colorbg","Background color") colHLbg=input(color.navy,"color HL","background color HL","inline=colorbg","Background color") colLLbg=input(color.navy,"color LL","background color LL","inline=colorbg","Background color") colBosHi=input(color.blue,"color High Trend Bos line","color High Bos line","inline=colorbos") colBosLo=input(color.red,"color Low Trend Bos line","color Low Bos line","inline=colorbos") styleBosHiIn=input.string(defval="solid",title="style High Bos line",options=["solid","dot","dash"],tooltip="style High Bos line",inline="stylebos") styleBosLoIn=input.string(defval="solid",title="style Low Bos line",options=["solid","dot","dash"],tooltip="style Low Bos line",inline="stylebos") var styleBosHi=line.style_solid if styleBosHiIn=="solid" styleBosHi:=line.style_solid if styleBosHiIn=="dot" styleBosHi:=line.style_dotted if styleBosHiIn=="dash" styleBosHi:=line.style_dashed var styleBosLo=line.style_solid if styleBosLoIn=="solid" styleBosLo:=line.style_solid if styleBosLoIn=="dot" styleBosLo:=line.style_dotted if styleBosLoIn=="dash" styleBosLo:=line.style_dashed DrawLine(line l,int x1,int x2,float y,color col,string st=line.style_solid )=> //float x2, float y2, newl=line.new(x1,y,x2,y,color=col,style=st) //line.set_x1(l,x1) //line.set_x2(l,x2) //line.set_y1(l,y) //line.set_y2(l,y) //line.set_color(l,col) newl ReDrawLine(line l,int x1,int x2,float y,color col)=> //float x2, float y2, //newl=line.new(x1,y,x2,y,color=col) line.set_x1(l,x1) line.set_x2(l,x2) line.set_y1(l,y) line.set_y2(l,y) line.set_color(l,col) l tipHi="Highest High" tipLo="Lowest Low" textHH="HH" textHL="HL" textLL="LL" textLH="LH" var textHi=textHH var textLo=textLL var prevtextHi="" var prevtextLo="" Check(string cur)=> res=true if prevtextHi==textHH and prevtextLo==textHL and cur==textLH //cur!=textHH and cur!=textLL res:=false if prevtextLo==textLL and prevtextHi==textLH and cur==textHL //cur!=textHH and cur!=textLL res:=false res var txt="" thresold=0.3 var hiarr=array.new_label() var loarr=array.new_label() size=size.normal var float lastHi=na var idxHi=0 var idxLo=0 var int countHi=0 var int countLo=0 var float lastLo=na var float prevHi=na var float prevLo=na var float Hi=na var float Lo=na var float cHi=na var float cLo=na var float y=na //var float y1=na var labelHi=label(na) var labelLo=label(na) var BosRed=line(na) var BosBlue=line(na) var signalHi=false var signalLo=false styleHi=label.style_label_down styleLo=label.style_label_up float check=0 float check2=0 renewHi=false renewLo=false if (last_bar_index-bar_index)low[1] and low[2]>low[1])?low[1]:na if (high[1]>lastHi[1] and na(lastHi[1])==false) cHi:=high[1] renewHi:=true if na(lastLo[1])==false and low[1](idxLo[1]+2) or idxLo[1]==0 or (cHi>lastHi[1] and na(lastHi[1])==false)) check:=check+1 if (na(lastHi[1]) or cHi>lastHi[1]) //textHi==textHH and Hi:=cHi check:=check+2 else if (((idxHi[1]thresold*(lastHi[1]-lastLo[1]))) or textHi=="" //textHi!=textHH and Hi:=cHi check:=check+1 if (na(lastHi[1]) or cHi>lastHi[1]) textHi:=textHH check:=check+10 else textHi:=textLH check:=check+20 //if (idxHi==0 or idxHi[1]thresold*(lastHi[1]-prevLo[1]) if na(Hi)==false if array.size(hiarr)>0 labelHi:=array.get(hiarr,array.size(hiarr)-1) y:=label.get_y(labelHi) if Hi>y textHi:=textHH check:=777 else textHi:=textLH check:=888 //if Check() if (idxHi[1]==0 or idxHi[1]1 labelHi:=array.get(hiarr,array.size(hiarr)-2) y:=label.get_y(labelHi) if Hi>y textHi:=textHH check:=55 else textHi:=textLH check:=99 if array.size(hiarr)>0 //and Check(textHi) check:=check*100 labelHi:=array.get(hiarr,array.size(hiarr)-1) label.set_x(labelHi,bar_index-1) label.set_y(labelHi,Hi) txt:=label.get_text(labelHi) if str.startswith(txt,textHi)==false //txt:=txt+"x" //else txt:=textHi+str.substring(txt,2) colHi=textHi==textHH?colHH:colLH colHibg=textHi==textHH?colHHbg:colLHbg label.set_textcolor(labelHi,colHi) label.set_color(labelHi,colHibg) label.set_text(labelHi,txt) if Check(textHi)==false textHi:=prevtextHi Hi:=na else prevtextHi:=textHi idxHi:=na(Hi)?idxHi[1]:bar_index if na(cLo)==false and na(Hi) and (((bar_index>(idxHi[1]+2)) and (idxHi[1]>=idxHi)) or idxHi[1]==0 )//or (na(lastLo[1])==false and cLothresold*(lastHi[1]-lastLo[1]))) or textLo=="" //textLo!=textLL and if (idxLo[1]thresold*(lastLo[1]-prevLo[1]) //if true or Check() if na(Lo)==false check2:=check2*10 if array.size(loarr)>0 labelLo:=array.get(loarr,array.size(loarr)-1) y:=label.get_y(labelLo) if Lo1 labelLo:=array.get(loarr,array.size(loarr)-2) y:=label.get_y(labelLo) if Lo0 //and Check(textLo) check2:=check2*100 labelLo:=array.get(loarr,array.size(loarr)-1) //textLo:=textLL label.set_x(labelLo,bar_index-1) label.set_y(labelLo,Lo) txt:=label.get_text(labelLo) if str.startswith(txt,textLo)==false // txt:=txt+"x" //else txt:=textLo+str.substring(txt,2) colLo=textLo==textLL?colLL:colHL colLobg=textLo==textLL?colLLbg:colHLbg label.set_textcolor(labelLo,colLo) label.set_color(labelLo,colLobg) label.set_text(labelLo,txt) if Check(textLo)==false textLo:=prevtextLo Lo:=na else prevtextLo:=textLo idxLo:=na(Lo)?idxLo[1]:bar_index lastHi:=na(Hi)?lastHi[1]:Hi prevHi:=(lastHi==lastHi[1] or na(lastHi))?prevHi[1]:lastHi[1] lastLo:=na(Lo)?lastLo[1]:Lo prevLo:=(lastLo==lastLo[1] or na(lastLo))?prevLo[1]:lastLo[1] if textHi==textHH and textLo==textHL and idxLo>0 if signalHi==false signalHi:=true alert("up trend is going on",alert.freq_once_per_bar) if na(BosBlue) if idxLo>idxLo[1] line lin=line(na) BosBlue:=DrawLine(lin,idxLo,bar_index,lastLo,colBosHi,styleBosHi) else ReDrawLine(BosBlue,idxLo,bar_index,lastLo,colBosHi) signalHi:=false else ReDrawLine(BosBlue,bar_index,bar_index,lastLo,color(na)) if textLo==textLL and textHi==textLH and idxHi>0 if signalLo==false signalLo:=true alert("down trend is going on",alert.freq_once_per_bar) if na(BosRed) if idxHi>idxHi[1] line lin=line(na) BosRed:=DrawLine(lin,idxHi,bar_index,lastHi,colBosLo,styleBosLo) else ReDrawLine(BosRed,idxHi,bar_index,lastHi,colBosLo) else ReDrawLine(BosRed,bar_index,bar_index,lastHi,color(na)) signalLo:=false plot((cHi-lastLo[1])>thresold*(lastHi[1]-lastLo[1])?1:0,offset=-1,color=na) plot((lastHi[1]-cLo)>thresold*(lastHi[1]-lastLo[1])?1:0,offset=-1,color=na) //plot(lastHi-lastLo) //plot((lastHi-prevLo)*thresold) //plot(lastHi) //plot(lastLo) //plot(cLo,offset=-1,style=plot.style_circles) //plot(cHi,offset=-1,style=plot.style_circles) //plot(Lo,offset=-1,style=plot.style_cross,linewidth=3) //plot(Hi,offset=-1,style=plot.style_cross,linewidth=3) plot(idxHi,color=na) plot(idxLo,color=na) plot(bar_index,color=na) plot(check,offset=-1,color=na) plot(check2,offset=-1,color=na) //plot(close)