Triangle Breakout Strategy with TP/SL, EMA Filter by Reanimate_

By Reanimate_

Performance Metrics

Description

πŸ“Œ Triangle Breakout Strategy with TP/SL, EMA Filters, and Backtest – Explained.βœ… 1. Pattern Detection – Triangle BreakoutThe script scans for triangle patterns by detecting local pivot highs and pivot lows.It uses two recent highs and two recent lows to draw converging trendlines (upper and lower boundaries of the triangle).If the price breaks above the upper trendline, a bullish breakout signal is generated.🎯 2. TP (Take Profit) & SL (Stop Loss)When a bullish breakout is detected:A buy order is placed using strategy.entry.TP and SL levels are calculated relative to the current close price:TP = 3% above the entry priceSL = 1.5% below the entry priceThese are defined using strategy.exit.πŸ“Š 3. EMA FilterAn optional filter checks if:Price is above both EMA 20 and EMA 50Only if this condition is met, the strategy allows a long entry.You can toggle the filter on or off with useEMAFilter.πŸ“ˆ 4. Backtesting with Strategy TesterThis script uses strategy() instead of indicator() to enable TradingView’s built-in backtest engine.Every buy entry and exit (based on TP or SL) is recorded.πŸ“Œ 5. VisualsEMA 20 and EMA 50 lines are plotted on the chart.A label is shown when a breakout is detected: "Breakout Up"Results (profit, win rate, drawdown, etc.) can be viewed in the Strategy Tester panel.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView