// 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 = 4 strategy(title=" Support and Resistance Levels with Breaks",shorttitle = " Support and Resistance Levels with Breaks", overlay = true , max_bars_back=1000) //======================================================================================================================================================================= toggleBreaks = input(true, title = "Show Breaks" ) leftBars = input(15, title = "Left Bars ") rightBars = input(12, title = "Right Bars") volumeThresh = input(20, title = "Volume Threshold") //======================================================================================================================================================================= //INTRADAY AlgoJi s=input(title="INTRA DAY TRADE SESSION",type=input.session,defval="0915-1450") st=time(timeframe.period,s) e=input(title="END SESSION",type=input.session,defval="1515-1520") et=time(timeframe.period,e) quant=input(title="Trade Quantity",defval=1) //======================================================================================================================================================================= highUsePivot = fixnan(pivothigh(leftBars, rightBars)[1]) lowUsePivot = fixnan(pivotlow(leftBars, rightBars)[1]) r1 = plot(highUsePivot, color=change(highUsePivot) ? na : #FF0000, linewidth=3, offset=-(rightBars+1), title="Resistance") s1 = plot(lowUsePivot, color=change(lowUsePivot) ? na : #233dee, linewidth=3, offset=-(rightBars+1), title="Support") //Volume % short = ema(volume, 5) long = ema(volume, 10) osc = 100 * (short - long) / long //For breaks with volume plotshape(toggleBreaks and crossunder(close,lowUsePivot) and not (open - close < high - open) and osc > volumeThresh, title = "Break", text = 'B', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny) plotshape(toggleBreaks and crossover(close,highUsePivot ) and not(open - low > close - open) and osc > volumeThresh, title = "Break", text = 'B', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny) //For bull / bear wicks plotshape(toggleBreaks and crossover(close,highUsePivot ) and open - low > close - open , title = "Break", text = 'Bull Wick', style = shape.labelup, location = location.belowbar, color= color.green,textcolor = color.white, transp = 0, size = size.tiny) plotshape(toggleBreaks and crossunder(close,lowUsePivot) and open - close < high - open , title = "Break", text = 'Bear Wick', style = shape.labeldown, location = location.abovebar, color= color.red,textcolor = color.white, transp = 0, size = size.tiny) sell_signal = (toggleBreaks and crossunder(close,lowUsePivot) and not (open - close < high - open) and osc > volumeThresh) or (toggleBreaks and crossunder(close,lowUsePivot) and open - close < high - open) buy_signal = (toggleBreaks and crossover(close,highUsePivot ) and not(open - low > close - open) and osc > volumeThresh) or (toggleBreaks and crossover(close,highUsePivot ) and open - low > close - open) support_broken = crossunder(close,lowUsePivot) and osc > volumeThresh res_broken = crossover(close,highUsePivot) and osc > volumeThresh alertcondition(support_broken , title = "Support Broken" , message = "Support Broken") alertcondition(res_broken, title = "Resistance Broken" , message = "Resistance Broken") //======================================================================================================================================================================= //AlgoJi adding stoploss and target option ut=input(defval=false,title="USE TARGET") us=input(defval=false,title="USE STOPLOSS") tar=input(defval=10.0,title="TARGET IN RS") stop=input(defval=7.0,title="STOP LOSS IN RS") tar:=tar/syminfo.mintick stop:=stop/syminfo.mintick //setting automated alerts required by apibridge lxse="TYPE: LX" + " :SYMBOL: " + syminfo.ticker + " :QTY: " + tostring(quant) + " :TYPE:SE " + " :SYMBOL: " + syminfo.ticker + " :QTY: " + tostring(quant) sxle="TYPE: SX" + " :SYMBOL: " + syminfo.ticker + " :QTY: " + tostring(quant) + " :TYPE:LE " + " :SYMBOL: " + syminfo.ticker + " :QTY: " + tostring(quant) le="TYPE:LE " + " :SYMBOL: " + syminfo.ticker + " :QTY: " + tostring(quant) lx="TYPE:LX " + " :SYMBOL: " + syminfo.ticker + " :QTY: " + tostring(quant) se="TYPE:SE " + " :SYMBOL: " + syminfo.ticker + " :QTY: " + tostring(quant) sx="TYPE:SX " + " :SYMBOL: " + syminfo.ticker + " :QTY: " + tostring(quant) if(buy_signal and st and strategy.position_size==0) strategy.entry("BUY",strategy.long,comment=le) if(sell_signal and st and strategy.position_size==0) strategy.entry("SELL",strategy.short,comment=se) if(buy_signal and st and strategy.position_size!=0) strategy.entry("BUY",strategy.long,comment=sxle) if(sell_signal and st and strategy.position_size!=0) strategy.entry("SELL",strategy.short,comment=lxse) if(ut==true and us==false) strategy.exit(id="LX",from_entry="BUY",profit=tar,comment=lx) strategy.exit(id="SX",from_entry="SELL",profit=tar,comment=sx) if(us==true and ut==false) strategy.exit(id="LX",from_entry="BUY",loss=stop,comment=lx) strategy.exit(id="SX",from_entry="SELL",loss=stop,comment=sx) if(ut==true and us==true) strategy.exit(id="LX",from_entry="BUY",profit=tar,loss=stop,comment=lx) strategy.exit(id="SX",from_entry="SELL",profit=tar,loss=stop,comment=sx) strategy.close(id="BUY",when=et,comment=lx) strategy.close(id="SELL",when=et,comment=sx)