Mo Strategy V1 by abu_elabed

By version

Performance Metrics

Description

//version=6strategy("Mo Strategy V2 - Trend MACD Session", overlay=true, initial_capital=1000, pyramiding=0, commission_type=strategy.commission.percent, commission_value=0.04)// ===== Inputs =====trendMode = input.string("EMA", "Trend Mode", options=["EMA", "Supertrend"])emaFastLen = input.int(50, "EMA Fast")emaSlowLen = input.int(200, "EMA Slow")macdFast = input.int(12, "MACD Fast")macdSlow = input.int(26, "MACD Slow")macdSignal = input.int(9, "MACD Signal")stopPoints = input.float(5.0, "Stop Loss Points", step=0.5)targetPoints = input.float(10.0, "Take Profit Points", step=0.5)useSessionFilter = input.bool(true, "Use Session Filter")tradeSession = input.session("1100-1900", "Trading Session - Dubai Time")stFactor = input.float(3.0, "Supertrend Factor")stAtrLen = input.int(10, "Supertrend ATR Length")// ===== Trend =====emaFast = ta.ema(close, emaFastLen)emaSlow = ta.ema(close, emaSlowLen)[supertrend, direction] = ta.supertrend(stFactor, stAtrLen)emaBull = emaFast > emaSlowemaBear = emaFast 0bullTrend = trendMode == "EMA" ? emaBull : stBullbearTrend = trendMode == "EMA" ? emaBear : stBear// ===== MACD =====[macdLine, signalLine, hist] = ta.macd(close, macdFast, macdSlow, macdSignal)bullMacd = macdLine > signalLine and hist > hist[1]bearMacd = macdLine = 0 strategy.entry("SELL", strategy.short)if strategy.position_size > 0 strategy.exit("BUY EXIT", "BUY", stop=strategy.position_avg_price - stopPoints, limit=strategy.position_avg_price + targetPoints)if strategy.position_size < 0 strategy.exit("SELL EXIT", "SELL", stop=strategy.position_avg_price + stopPoints, limit=strategy.position_avg_price - targetPoints)// ===== Plots =====plot(emaFast, "EMA 50", color=color.orange)plot(emaSlow, "EMA 200", color=color.blue)plot(trendMode == "Supertrend" ? supertrend : na, "Supertrend", color=direction < 0 ? color.green : color.red)plotshape(buySignal, title="BUY", text="BUY", style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, size=size.small)plotshape(sellSignal, title="SELL", text="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.small)// ===== Alerts =====alertcondition(buySignal, title="Mo V2 BUY", message="Mo Strategy V2 BUY Signal")alertcondition(sellSignal, title="Mo V2 SELL", message="Mo Strategy V2 SELL Signal")

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView