Triangle Breakout Strategy with TP/SL, EMA Filter by Reanimate_
By Reanimate_
Performance Metrics
- Author: Reanimate_
- Symbol: NASDAQ:JEPQ
- Timeframe: 1 day
- Net P&L: +21,047.57 USD (+2.10%)
- Win Rate: 53.3%
- Profit Factor: 3.706
- Max Drawdown: 4,169.22 USD (0.41%)
- Total Trades: 15
- Sharpe Ratio: β0.576
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.