// Created by Robert N. 030715 // Updated 031115 // Candle labels //modified with alert configration for apibridge //@version=4 strategy(title = "Candles", overlay = true) c1=input(defval=false,title="USE MORNING STAR FOR BULLISH") c2=input(defval=false,title="USE EVENING STAR FOR BEARISH") c3=input(defval=false,title="USE SHOOTING STAR FOR BEARISH") c4=input(defval=false,title="USE HAMMER FOR BULLISH") c5=input(defval=false,title="USE INVERTED HAMMER FOR BEARISH") c6=input(defval=false,title="USE BULLISH HARAMI FOR BULLISH") c7=input(defval=false,title="USE BEARISH HARAMI FOR BEARISH") c8=input(defval=true,title="USE BEARISH ENGULFING FOR BEARISH") c9=input(defval=true,title="USE BULLISH ENGULFING FOR BULLISH") c10=input(defval=false,title="USE PIERCING PATTERN FOR BULLISH") c11=input(defval=false,title="USE DARK CLOUD COVER FOR BEARISH") c12=input(defval=false,title="USE BULLISH KICKER FOR BULLISH") c13=input(defval=false,title="USE BEARISH KICKER FOR BEARISH") c14=input(defval=false,title="USE BULLISH BELT FOR BULLISH") c15=input(defval=false,title="USE HANGING MAN FOR BEARISH") DojiSize = input(0.05, minval=0.01, title="Doji size") c0=input(defval=false,title="USE DOJI TO EXIT") data=(abs(open - close) <= (high - low) * DojiSize) e1=c0 and data plotchar(data and c0, title="Doji", text='Doji', color=color.white) data2=(close[2] > open[2] and min(open[1], close[1]) > close[2] and open < min(open[1], close[1]) and close < open ) plotshape(data2 and c2, title= "Evening Star", color=color.red, style=shape.arrowdown, text="Evening\nStar") s1=c2 and data2 data3=(close[2] < open[2] and max(open[1], close[1]) < close[2] and open > max(open[1], close[1]) and close > open ) plotshape(data3 and c1, title= "Morning Star", location=location.belowbar, color=color.lime, style=shape.arrowup, text="Morning\nStar") b1=c1 and data3 data4=(open[1] < close[1] and open > close[1] and high - max(open, close) >= abs(open - close) * 3 and min(close, open) - low <= abs(open - close)) plotshape(data4 and c3, title= "Shooting Star", color=color.red, style=shape.arrowdown, text="Shooting\nStar") s2=c3 and data4 data5=(((high - low)>3*(open -close)) and ((close - low)/(.001 + high - low) > 0.6) and ((open - low)/(.001 + high - low) > 0.6)) plotshape(data5 and c4, title= "Hammer", location=location.belowbar, color=color.white, style=shape.diamond, text="H") b2=c4 and data5 data5b=(((high - low)>3*(open -close)) and ((high - close)/(.001 + high - low) > 0.6) and ((high - open)/(.001 + high - low) > 0.6)) plotshape(data5b and c5, title= "Inverted Hammer", location=location.belowbar, color=color.white, style=shape.diamond, text="IH") s3=c5 and data5b data6=(close[1] > open[1] and open > close and open <= close[1] and open[1] <= close and open - close < close[1] - open[1] ) plotshape(data6 and c7, title= "Bearish Harami", color=color.red, style=shape.arrowdown, text="Bearish\nHarami") s4=c7 and data6 data7=(open[1] > close[1] and close > open and close <= open[1] and close[1] <= open and close - open < open[1] - close[1] ) plotshape(data7 and c6, title= "Bullish Harami", location=location.belowbar, color=color.lime, style=shape.arrowup, text="Bullish\nHarami") b4=c6 and data7 data8=(close[1] > open[1] and open > close and open >= close[1] and open[1] >= close and open - close > close[1] - open[1] ) plotshape(data8 and c8, title= "Bearish Engulfing", color=color.red, style=shape.arrowdown, text="Bearish\nEngulfing") s5=c8 and data8 data9=(open[1] > close[1] and close > open and close >= open[1] and close[1] >= open and close - open > open[1] - close[1] ) plotshape(data9 and c9, title= "Bullish Engulfing", location=location.belowbar, color=color.lime, style=shape.arrowup, text="Bullish\nEngulfling") b5=c9 and data9 upper = highest(10)[1] data10=(close[1] < open[1] and open < low[1] and close > close[1] + ((open[1] - close[1])/2) and close < open[1]) plotshape(data10 and c10, title= "Piercing Line", location=location.belowbar, color=color.lime, style=shape.arrowup, text="Piercing\nLine") b6=c10 and data10 lower = lowest(10)[1] data11=(low == open and open < lower and open < close and close > ((high[1] - low[1]) / 2) + low[1]) plotshape(data11 and c14, title= "Bullish Belt", location=location.belowbar, color=color.lime, style=shape.arrowup, text="Bullish\nBelt") b7=c14 and data11 data12=(open[1]>close[1] and open>=open[1] and close>open) plotshape(data12 and c12, title= "Bullish Kicker", location=location.belowbar, color=color.lime, style=shape.arrowup, text="Bullish\nKicker") b3=c12 and data12 data13=(open[1]4*(open-close))and((close-low)/(.001+high-low)>=0.75)and((open-low)/(.001+high-low)>=0.75)) and high[1] < open and high[2] < open) plotshape(data14 and c15, title= "Hanging Man", color=color.red, style=shape.arrowdown, text="Hanging\nMan") s7=c15 and data14 data15=((close[1]>open[1])and(((close[1]+open[1])/2)>close)and(open>close)and(open>close[1])and(close>open[1])and((open-close)/(.001+(high-low))>0.6)) plotshape(data15 and c11, title= "Dark Cloud Cover", color=color.red, style=shape.arrowdown, text="Dark\nCloudCover") s8=c11 and data15 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) //adding custom quantities q=input(title="Trade Quantity",defval=1) q1=1 if(strategy.position_size!=0) q1:=q*2 if(strategy.position_size==0) q1:=q //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 m=" :SYMBOL:"+syminfo.ticker+" :QTY:"+tostring(q1) m1=" :SYMBOL:"+syminfo.ticker+" :QTY:"+tostring(q) if((b1 or b2 or b3 or b4 or b5 or b6 or b7) and st) strategy.entry("BUY",strategy.long,comment="TYPE:LE"+m) if((s1 or s2 or s3 or s4 or s5 or s6 or s7 or s8)and st) strategy.entry("SELL",strategy.short,comment="TYPE:SE"+m) if(ut==true and us==false) strategy.exit(id="LX",from_entry="BUY",profit=tar,comment="TYPE:LX"+m1) strategy.exit(id="SX",from_entry="SELL",profit=tar,comment="TYPE:SX"+m1) if(us==true and ut==false) strategy.exit(id="LX",from_entry="BUY",loss=stop,comment="TYPE:LX"+m1) strategy.exit(id="SX",from_entry="SELL",loss=stop,comment="TYPE:SX"+m1) if(ut==true and us==true) strategy.exit(id="LX",from_entry="BUY",profit=tar,loss=stop,comment="TYPE:LX"+m1) strategy.exit(id="SX",from_entry="SELL",profit=tar,loss=stop,comment="TYPE:SX"+m1) if(e1) strategy.close("BUY",comment="TYPE:LX"+m1) strategy.close("SELL",comment="TYPE:SX"+m1) strategy.close(id="BUY",when=et,comment="TYPE:LX"+m1) strategy.close(id="SELL",when=et,comment="TYPE:SX"+m1)