GTS
//@version=2 strategy("TC - MACDoscillator v2", overlay=true) // ___________ .__ _________ .__ __ .__ // \__ ___/____ | | ____ ____ \_ ___ \_____ ______ |__|/ |______ | | // | | \__ \ | | / ___\ / _ \ / \ \/\__ \ \____ \| \ __\__ \ | | // | | / __ \| |__/ /_/ > <_> ) \ \____/ __ \| |_> > || | / __ \| |__ // |____| (____ /____/\___ / \____/ \______ (____ / __/|__||__| (____ /____/ // \/ /_____/ \/ \/|__| \/ // // MACDoscillator Strategy v2 // Josh Breitfeld 2016 // /// INPUTS START /// //tradeSize = input(title="Shares Per Trade", type=integer, defval=2500, step=1) WMALength = input(title="WMA Length", type=integer, defval=25, step=1) EMA1Length = input(title="EMA1 Length", type=integer, defval=50, step=1) EMA2Length = input(title="EMA2 Length", type=integer, defval=100, step=1) //security = input(title="Alternate Security", type=string, defval="SPX500") //inverse = input(title="Inverse Signals", type=bool, defval=true) /// INPUTS END /// /// ALGORITHM START /// /// Define calculations WMA = wma(close,WMALength) EMA1 = ema(close,EMA1Length) EMA2 = ema(close,EMA2Length) /// Grab values from alternate security dWMA = WMA dEMA1 = EMA1 dEMA2 = EMA2 aClose = close /// Crossover signal system /// Long crosses lc1 = aClose > dWMA ? true : false lc2 = aClose > dEMA1 ? true : false lc3 = aClose > dEMA2 ? true: false /// Short crosses sc1 = aClose < dWMA ? true : false sc2 = aClose < dEMA1 ? true : false sc3 = aClose < dEMA2 ? true : false //plot(lc1,color=green) //plot(lc2,color=green) //plot(lc3,color=green) //plot(sc1,color=red) //plot(sc2,color=red) //plot(sc3,color=red) /// ALGO ORDER CONDITIONS START /// pBuyToOpen = (lc1 and lc2 and lc3 ? true : false) pSellToOpen = (sc1 and sc2 and sc3 ? true : false) pSellToClose = (lc1 ? true : false) and not pBuyToOpen pBuyToClose = (sc1 ? true : false) and not pSellToOpen //plot(pBuyToOpen,color=lime) //plot(pBuyToClose,color=lime) //plot(pSellToOpen,color=red) //plot(pSellToClose,color=red) /// INVERT SIGNALS //buyToOpen = inverse ? -pBuyToOpen : pBuyToOpen //sellToOpen = inverse ? -pBuyToOpen : pSellToOpen //sellToClose = inverse ? -pSellToClose : pSellToClose //buyToClose = inverse ? -pBuyToClose : pBuyToClose /// ALGO ORDER CONDITIONS END /// /// ALGORITHM END /// /// DEFINE PLOTS /// plot(dWMA,"WMA",lime,1,line) plot(dEMA1,"EMA1",blue,2,line) plot(dEMA2,"EMA2",red,3,line) //plot(aClose,"Close",orange,4,line) /// PLOTS END /// /// ORDER BLOCK /// //strategy.entry("My Long Entry Id", strategy.long) /// OPENING ORDERS START /// if(pBuyToOpen) strategy.entry("BTO", strategy.long, comment="BTO") if(pSellToOpen) strategy.entry("STO", strategy.short, comment="STO") /// OPENING ORDERS END /// /// CLOSING ORDERS START /// strategy.close("BTO", pBuyToClose) strategy.close("STO", pSellToClose) /// CLOSING ORDERS END /// /// END ORDER BLOCK /// // Josh Breitfeld - Talgo Capital 2016 /// STRATEGY END ///