// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © yashp1334 //@version=4 //Created by ChrisMoody on 10-05-2014 //Known as SlingShot Method that keeps Traders on Trending Side of Market. strategy("CM_SlingShotSystem", overlay=true) sae = input(false, title="Show Aggressive Entry?, Or Use as Alert To Potential Conservative Entry?") sce = input(true, title="Show Conservative Entry?") st = input(true, title="Show Trend Arrows at Top and Bottom of Screen?") def = input(false, title="Only Choose 1 - Either Conservative Entry Arrows or 'B'-'S' Letters") pa = input(false, title="Show Conservative Entry Arrows?") sl = input(false, title="Show 'B'-'S' Letters?") //EMA Definitions emaSlow = ema(close, 62) emaFast = ema(close, 38) //Aggressive Entry or Alert To Potential Trade pullbackUpT() => emaFast > emaSlow and close < emaFast pullbackDnT() => emaFast < emaSlow and close > emaFast //Conservative Entry Code For Highlight Bars entryUpT() => emaFast > emaSlow and close[1] < emaFast and close > emaFast entryDnT() => emaFast < emaSlow and close[1] > emaFast and close < emaFast //Conservative Entry True/False Condition entryUpTrend = emaFast > emaSlow and close[1] < emaFast and close > emaFast ? 1 : 0 entryDnTrend = emaFast < emaSlow and close[1] > emaFast and close < emaFast ? 1 : 0 //Define Up and Down Trend for Trend Arrows at Top and Bottom of Screen upTrend = emaFast >= emaSlow downTrend = emaFast < emaSlow //Definition for Conseervative Entry Up and Down PlotArrows codiff = entryUpTrend == 1 ? entryUpTrend : 0 codiff2 = entryDnTrend == 1 ? entryDnTrend : 0 //Color definition for Moving Averages col = emaFast > emaSlow ? color.lime : emaFast < emaSlow ? color.red : color.yellow //Moving Average Plots and Fill p1 = plot(emaSlow, title="Slow MA", linewidth=4, color=col) p2 = plot(emaFast, title="Slow MA", linewidth=2, color=col) fill(p1, p2, color=color.silver, transp=50) //Aggressive Entry, Conservative Entry Highlight Bars barcolor(sae and pullbackUpT() ? color.yellow : sae and pullbackDnT() ? color.yellow : na) barcolor(sce and entryUpT() ? color.aqua : sce and entryDnT() ? color.aqua : na) //Trend Triangles at Top and Bottom of Screen plotshape(st and upTrend ? upTrend : na, title="Conservative Buy Entry Triangle",style=shape.triangleup, location=location.bottom, color=color.lime, transp=0, offset=0) plotshape(st and downTrend ? downTrend : na, title="Conservative Short Entry Triangle",style=shape.triangledown, location=location.top, color=color.red, transp=0, offset=0) //Plot Arrows OR Letters B and S for Buy Sell Signals plotarrow(pa and codiff ? codiff : na, title="Up Entry Arrow", colorup=color.lime, maxheight=30, minheight=30, transp=0) plotarrow(pa and codiff2*-1 ? codiff2*-1 : na, title="Down Entry Arrow", colordown=color.red, maxheight=30, minheight=30, transp=0) plotchar(sl and codiff ? low - tr : na, title="Buy Entry", offset=0, char='B', location=location.absolute, color=color.lime, transp=0) plotchar(sl and codiff2 ? high + tr : na, title="Short Entry", offset=0, char='S', location=location.absolute, color=color.red, transp=0) //INTRADAY s=input(title="INTRA DAY TRADE SESSION",type=input.session,defval="0915-1450") t=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) //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(entryUpTrend and t and strategy.position_size==0) strategy.entry("BUY",strategy.long,comment=le) if(entryDnTrend and t and strategy.position_size==0) strategy.entry("SELL",strategy.short,comment=se) if(entryUpTrend and t and strategy.position_size!=0) strategy.entry("BUY",strategy.long,comment=sxle) if(entryDnTrend and t 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)