Nus111v.1Euro / United States DollarCMCMARKETS:EURUSDmikidxzx//@version=6 strategy("EUR/USD PA Trend System V1", overlay=true, initial_capital=50, currency=currency.USD, pyramiding=0, commission_type=strategy.commission.percent, commission_value=0.0) // ===================================================== // SETTINGS // ===================================================== emaFastLen = input.int(50, "EMA Fast") emaSlowLen = input.int(200, "EMA Slow") swingLen = input.int(3, "Swing Length", minval=2) riskReward = input.float(2.0, "Risk : Reward", minval=1.0, step=0.1) riskPercent = input.float(1.0, "Risk %", minval=0.1, maxval=5.0) atrLen = input.int(14, "ATR Length") atrBuffer = input.float(0.2, "SL ATR Buffer", step=0.1) showEMA = input.bool(true, "Show EMA") showLevels = input.bool(true, "Show Entry / SL / TP") // ===================================================== // EMA // ===================================================== ema50 = ta.ema(close, emaFastLen) ema200 = ta.ema(close, emaSlowLen) plot(showEMA ? ema50 : na, "EMA 50", color=color.blue, linewidth=2) plot(showEMA ? ema200 : na, "EMA 200", color=color.red, linewidth=2) // ===================================================== // H4 TREND // ===================================================== h4Close = request.security( syminfo.tickerid, "240", close, lookahead=barmerge.lookahead_off) h4EMA50 = request.security( syminfo.tickerid, "240", ta.ema(close, emaFastLen), lookahead=barmerge.lookahead_off) h4EMA200 = request.security( syminfo.tickerid, "240", ta.ema(close, emaSlowLen), lookahead=barmerge.lookahead_off) bullTrend = h4EMA50 > h4EMA200 and h4Close > h4EMA200 bearTrend = h4EMA50 < h4EMA200 and h4Close < h4EMA200 // ===================================================== // H1 SWING LEVELS // ===================================================== h1High = request.security( syminfo.tickerid, "60", ta.pivothigh(high, swingLen, swingLen), lookahead=barmerge.lookahead_off) h1Low = request.security( syminfo.tickerid, "60", ta.pivotlow(low, swingLen, swingLen), lookahead=barmerge.lookahead_off) var float resistance = na var float support = na if not na(h1High) resistance := h1High if not na(h1Low) support := h1Low // ===================================================== // M15 PRICE ACTION // ===================================================== // Bullish engulfing bullEngulf = close > open and close < open and close >= open and open open and close = close // Rejection candles body = math.abs(close - open) upperWick = high - math.max(open, close) lowerWick = math.min(open, close) - low bullReject = lowerWick > body * 1.5 and close > open bearReject = upperWick > body * 1.5 and close < open bullPA = bullEngulf or bullReject bearPA = bearEngulf or bearReject // ===================================================== // BOS // ===================================================== previousHigh = ta.highest(high, swingLen) previousLow = ta.lowest(low, swingLen) bullBOS = close > previousHigh bearBOS = close < previousLow // ===================================================== // ZONE DISTANCE // ===================================================== atr = ta.atr(atrLen) nearSupport = not na(support) and low = resistance - atr // ===================================================== // SIGNAL // ===================================================== buySignal = bullTrend and nearSupport and bullPA and bullBOS and strategy.position_size == 0 sellSignal = bearTrend and nearResistance and bearPA and bearBOS and strategy.position_size == 0 // ===================================================== // SL / TP // ===================================================== var float entryPrice = na var float stopPrice = na var float targetPrice = na if buySignal entryPrice := close stopPrice := math.min(low, support) - atr * atrBuffer risk = entryPrice - stopPrice targetPrice := entryPrice + risk * riskReward if risk > 0 strategy.entry("BUY", strategy.long) strategy.exit( "BUY EXIT", "BUY", stop=stopPrice, limit=targetPrice) if sellSignal entryPrice := close stopPrice := math.max(high, resistance) + atr * atrBuffer risk = stopPrice - entryPrice targetPrice := entryPrice - risk * riskReward if risk > 0 strategy.entry("SELL", strategy.short) strategy.exit( "SELL EXIT", "SELL", stop=stopPrice, limit=targetPrice) // ===================================================== // PLOT SIGNALS // ===================================================== plotshape( buySignal, title="BUY", style=shape.labelup, location=location.belowbar, color=color.green, text="BUY", textcolor=color.white) plotshape( sellSignal, title="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, text="SELL", textcolor=color.white) // ===================================================== // ENTRY / SL / TP // ===================================================== plot( showLevels and strategy.position_size != 0 ? entryPrice : na, "ENTRY", color=color.blue, linewidth=2, style=plot.style_linebr) plot( showLevels and strategy.position_size != 0 ? stopPrice : na, "SL", color=color.red, linewidth=2, style=plot.style_linebr) plot( showLevels and strategy.position_size != 0 ? targetPrice : na, "TP", color=color.green, linewidth=2, style=plot.style_linebr) // ===================================================== // ALERTS // ===================================================== alertcondition( buySignal, title="BUY Signal", message="EUR/USD PA Trend System: BUY") alertcondition( sellSignal, title="SELL Signal", message="EUR/USD PA Trend System: SELL")