BUYVIPonly — Strategy by vipulgupta0728

By version

Performance Metrics

Description

//version=5strategy("Buy-Only: 40 EMA + BB(0.7) [with TP reset]", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)// === INPUTS ===emaLength = input.int(40, title="EMA Length")bbStdDev = input.float(0.7, title="Bollinger Bands StdDev")rr_ratio = input.float(3.0, title="Reward-to-Risk Ratio") // 3:1 RR// === INDICATORS ===ema = ta.ema(close, emaLength)dev = bbStdDev * ta.stdev(close, emaLength)upperBB = ema + devlowerBB = ema - devplot(ema, color=color.orange, title="EMA 40")plot(upperBB, color=color.teal, title="Upper BB")plot(lowerBB, color=color.teal, title="Lower BB")// === STATE VARIABLES ===var float longSL = navar float longTP = navar bool waitForNewCross = false // ema and not waitForNewCross and strategy.position_size == 0if buyCondition strategy.entry("Buy", strategy.long) longSL := lowerBB longTP := close + (close - lowerBB) * rr_ratio// === SL SHIFT TO EMA IF PRICE CLOSES ABOVE UPPER BB ===if (strategy.position_size > 0 and close > upperBB) longSL := ema// === EXIT LOGIC ===if (strategy.position_size > 0) if close = longTP strategy.close("Buy", comment="TP Hit") waitForNewCross := true // Block next trade// === RESET ENTRY CONDITION ===// Wait for crossover below EMA then new close above itif waitForNewCross and ta.crossunder(close, ema) waitForNewCross := false

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView