Patterns Strategy v1 by dipalishah94

By dipalishah94

Performance Metrics

Description

### 1. What the strategy doesThis is a **price-action pattern strategy** that detects four patterns:* **Bullish Engulfing** → long setup* **Bearish Engulfing** → short setup* **Morning Star** → long setup* **Evening Star** → short setupThe strategy then creates an entry trigger, stop loss, and profit targets for the detected pattern. ---### 2. Bullish EngulfingFor a bullish engulfing setup, the script looks for:* Previous candle is bearish.* Current candle is bullish.* Current candle's body is large enough according to the minimum-body setting.* The current candle completely engulfs the previous candle's body when strict engulfing is enabled.* The current close can also be required to finish beyond the previous candle's open.Once detected:**Entry:** above the engulfing candle's high**SL:** below the engulfing candle's low, with optional use of both candles**Target:** normally 1.5R for TP1 and 2R for the final target. ---### 3. Bearish EngulfingThe opposite structure is used:* Previous candle is bullish.* Current candle is bearish.* Current candle has sufficient body strength.* Current candle engulfs the previous candle's body.* The close can be required to finish below the previous candle's open.**Entry:** below the engulfing candle's low**SL:** above the engulfing candle's high**Target:** 1.5R and 2R by default. ---### 4. Morning StarThe strategy uses a **three-candle pattern**:1. Strong bearish first candle.2. Small-body middle candle.3. Strong bullish third candle.4. Third candle must recover at least the configured penetration percentage of the first candle's body.The default settings require:* Middle candle body ≤ 35% of its range.* Outer candles body ≥ 55%.* Third candle penetration = 50%.**Entry:** above the third candle's high**SL:** below the entire three-candle pattern**Target:** 1.5R / 2R. ---### 5. Evening StarThis is the reverse of the Morning Star:1. Strong bullish first candle.2. Small middle candle.3. Strong bearish third candle.4. Third candle penetrates sufficiently into the first candle.**Entry:** below the third candle's low**SL:** above the entire pattern**Target:** 1.5R / 2R. ---## 6. Entry mechanismThere are **two entry modes**.### Stop OrderThe strategy places a resting order at the breakout level.For example:**Bullish pattern → price must break the trigger above the pattern.**### Market on BreakThe strategy waits until price actually breaks the trigger and then enters on the next bar.So the two modes behave differently in backtesting. There is also an **entry buffer**, meaning the trigger can be placed a few ticks beyond the pattern high/low.---## 7. Pending setup expirationAfter a pattern appears, the setup does **not remain active forever**.Default:**5 bars**If price doesn't trigger the entry within those bars, the pending setup is cancelled.There is also an option to cancel the setup if the stop-loss level breaks before the entry occurs. ---## 8. Stop-loss protectionThe strategy has a minimum stop-distance rule.If the calculated SL is too close to the entry, it automatically pushes the SL farther away to satisfy the minimum number of ticks.This prevents extremely small stop distances. ---## 9. Profit managementThe default structure is:**Entry → 1.5R TP1 → 2R final TP**At TP1:* 50% of the position is closed by default.* The remaining position continues toward TP2.* Stop loss can automatically move toward break-even.The break-even adjustment has its own tick offset. So conceptually:**Risk = 1R**If your entry-to-SL distance is 20 points:* TP1 = +30 points* TP2 = +40 pointswith the default 1.5R / 2R settings.---## 10. Daily trading restrictionsThe script has several controls:* Maximum trades per day* Maximum number of losses per day* Only the first pattern of the day* Long trades on/off* Short trades on/off* Trading session restriction* Close trade at session end* EMA trend filterThe default maximum trades per day is **1**. This is important because even if several patterns appear, the strategy can prevent additional trades once the daily limit has been reached.---## 11. EMA trend filterThe strategy can optionally use an EMA as a directional filter.Default EMA:**200 EMA**When enabled:* Long setups require price above the EMA.* Short setups require price below the EMA.When disabled, the EMA does not filter the trades. ---## 12. Position sizingThere are two approaches.### Fixed lotsThe strategy trades a fixed number of lots.Default:**1 lot × 65 units = 65 units**### Risk-based sizingYou can instead specify how much of your equity you want to risk per trade.The position size is then calculated from:**Account equity + risk percentage + distance to SL + lot size**It rounds the quantity to whole lots. ---## 13. White candle featureThis is one of the important visual features of your script.When a valid pattern is detected, the pattern candle can be painted **white**.For two-candle patterns:**Both candles can be highlighted.**For three-candle patterns:**All three candles can be highlighted.**You can independently control this feature from the Visuals settings. ---## 14. Chart markingsThe script can display:* Bullish triangle* Bearish triangle* Pattern name* Entry/trigger level* Entry price* Stop loss* TP1* TP2* EMA when trend filtering is enabledThe levels make it possible to visually follow the entire trade from setup → entry → SL/TP. ---## 15. DashboardThe top-right dashboard shows the current strategy state.It can tell you:* **LONG*** **SHORT*** **Pending Long*** **Pending Short*** **Flat**It also displays:* Trades today* Losses today* Last pattern* Current 1R risk* Net profitWhen DEBUG is enabled, it additionally shows:* Signals detected* Orders placed* Fills* Expired setups* Invalidated setups* Blocked setups* Last reason a setup was skipped. ---## 16. AlertsThe script has alerts for each individual pattern:* Bullish Engulfing* Bearish Engulfing* Morning Star* Evening StarIt also has general long/short setup alerts.The alert message can include the pattern, trigger price and SL. ---### Overall flowThe strategy essentially works like this:**Find pattern → check filters → calculate trigger → calculate SL → create pending setup → wait for breakout → enter → manage TP1 → move SL toward BE → target TP2 or SL → enforce daily limits.**So this is **not simply a candle-pattern indicator**. It is a complete **backtesting/trading strategy with order management, risk sizing, daily limits, visual signals, dashboard and alerts**.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView