// This source code is subject to the terms of the Mozilla Public License // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © MRC95 //@version=4 strategy("Stoch&MACD", overlay=true) //MACD fastLength = input(5) slowlength = input(35) MACDLength = input(5) MACD = ema(close, fastLength) - ema(close, slowlength) aMACD = ema(MACD, MACDLength) delta = MACD - aMACD //Stochastic periodK = input(26, title="K", minval=1) periodD = input(2, title="D", minval=1) smoothK = input(9, title="Smooth", minval=1) k = sma(stoch(close, high, low, periodK), smoothK) d = sma(k, periodD) deltaS = k - d //input ticker tick=input(0.8,title="Ticker size",type=input.float) //trailing stop settings ts = input(1, title="TrailingStop%", type=input.float) ts_calc = close * (1/tick) * ts * 0.01 ////////////////////// // orders // //////////////////// longCondition = k>d and MACD>aMACD shortCondition = k=1 strategy.exit("Exit Long", "Long", trail_points=0, trail_offset=ts_calc) strategy.exit("Exit Short","Short", trail_points=0, trail_offset=ts_calc)