//@version=5 strategy("The Pattern Scalp Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10) // Inputs atr_length = input.int(14, title="Daily ATR Length") atr_multiplier = input.float(0.20, title="ATR Requisite Multiplier (e.g. 0.20 = 20%)") target_rr = input.float(1.5, title="Fallback Risk Reward Ratio") // Daily ATR d_atr = request.security(syminfo.tickerid, "D", ta.atr(atr_length)) // Time & Session tracking is_new_day = ta.change(time("D")) != 0 var int bar_count_in_day = 0 if is_new_day bar_count_in_day := 1 else bar_count_in_day := bar_count_in_day + 1 var float op_range_high = na var float op_range_low = na var float op_open = na var float op_close = na var bool is_manipulation_day = false var bool is_bearish_manipulation = false var bool is_bullish_manipulation = false // Reset state at start of day if is_new_day op_range_high := na op_range_low := na op_open := open op_close := na is_manipulation_day := false is_bearish_manipulation := false is_bullish_manipulation := false // Pre-calculate running metrics outside conditional blocks to avoid Pine Script warnings highest_3 = ta.highest(high, 3) lowest_3 = ta.lowest(low, 3) // On the 3rd bar of the day (since we are on a 5-min chart, 3 bars = 15 mins) if bar_count_in_day == 3 op_range_high := highest_3 op_range_low := lowest_3 op_open := open[2] op_close := close range_size = op_range_high - op_range_low if range_size > (d_atr * atr_multiplier) is_manipulation_day := true if op_close < op_open is_bearish_manipulation := true else is_bullish_manipulation := true // Reversal Signals Setup var bool wait_for_bull_break = false var float bull_trigger_high = na var float bull_stop_loss = na var bool wait_for_bear_break = false var float bear_trigger_low = na var float bear_stop_loss = na // Candlestick shapes body = math.abs(close - open) lower_wick = math.min(open, close) - low upper_wick = high - math.max(open, close) is_hammer = lower_wick > body * 1.5 and upper_wick < lower_wick * 0.5 is_shooting_star = upper_wick > body * 1.5 and lower_wick < upper_wick * 0.5 is_power_tower_bull = (close[1] < open[1]) and (close > open) and (close > (open[1] + close[1])/2.0) is_power_tower_bear = (close[1] > open[1]) and (close < open) and (close < (open[1] + close[1])/2.0) // Signal execution (only after the first 15 mins of the day) if bar_count_in_day > 3 and strategy.position_size == 0 // Hammer Reversal - Bullish if is_bearish_manipulation and is_hammer wait_for_bull_break := true bull_trigger_high := high bull_stop_loss := low // Inverted Hammer Reversal - Bearish if is_bullish_manipulation and is_shooting_star wait_for_bear_break := true bear_trigger_low := low bear_stop_loss := high // Trigger Long on breakout of Hammer High if wait_for_bull_break and ta.crossover(high, bull_trigger_high) tp_price = op_range_high // Fallback in case target is too close to entry if tp_price - close < (close - bull_stop_loss) * 0.5 tp_price := close + (close - bull_stop_loss) * target_rr strategy.entry("Long John Wick", strategy.long) strategy.exit("Exit Long", "Long John Wick", limit=tp_price, stop=bull_stop_loss) wait_for_bull_break := false // Trigger Short on breakdown of Shooting Star Low if wait_for_bear_break and ta.crossunder(low, bear_trigger_low) tp_price = op_range_low // Fallback in case target is too close to entry if close - tp_price < (bear_stop_loss - close) * 0.5 tp_price := close - (bear_stop_loss - close) * target_rr strategy.entry("Short John Wick", strategy.short) strategy.exit("Exit Short", "Short John Wick", limit=tp_price, stop=bear_stop_loss) wait_for_bear_break := false // Power of Tower triggers (instant execution at close of bar) if is_bearish_manipulation and is_power_tower_bull sl_price = low tp_price = op_range_high if tp_price - close < (close - sl_price) * 0.5 tp_price := close + (close - sl_price) * target_rr strategy.entry("Long Power Tower", strategy.long) strategy.exit("Exit Long PT", "Long Power Tower", limit=tp_price, stop=sl_price) if is_bullish_manipulation and is_power_tower_bear sl_price = high tp_price = op_range_low if close - tp_price < (sl_price - close) * 0.5 tp_price := close - (sl_price - close) * target_rr strategy.entry("Short Power Tower", strategy.short) strategy.exit("Exit Short PT", "Short Power Tower", limit=tp_price, stop=sl_price) // Reset breakout triggers if we go to a new day or trade closes if is_new_day wait_for_bull_break := false wait_for_bear_break := false // Plots plot(op_range_high, color=color.green, title="Opening Range High") plot(op_range_low, color=color.red, title="Opening Range Low")