The Bearish Harami Reversal Backtest Strategy identifies bearish Harami reversal patterns in candlestick charts and automatically trades them. It goes short when detecting a bearish Harami pattern and closes the position when the stop loss or take profit is triggered.
The core pattern recognition indicator of this strategy is: the close of the first candle is a long bullish candle and the second candle’s close is inside the first candle’s body, forming a bearish candle. This indicates a potential Bearish Harami reversal pattern. When this pattern forms, the strategy goes short.
The specific logic is:
The advantages of this strategy are:
There are also some risks:
The strategy can be further optimized in the following areas:
The Bearish Harami Reversal Backtest Strategy has clear, easy to understand logic, good backtest results and controllable risks. It has room for live trading adjustments and optimizations. Overall the trading signals are reliable and worth further optimizations and verification in live trading.
/*backtest start: 2023-11-15 00:00:00 end: 2023-11-19 23:00:00 period: 15m basePeriod: 5m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 16/01/2019 // This is a bearish reversal pattern formed by two candlesticks in which a short // real body is contained within the prior session's long real body. Usually the // second real body is the opposite color of the first real body. The Harami pattern // is the reverse of the Engulfing pattern. // // WARNING: // - For purpose educate only // - This script to change bars colors. //////////////////////////////////////////////////////////// strategy(title = "Bearish Harami Backtest", overlay = true) input_takeprofit = input(20, title="Take Profit pip") input_stoploss = input(10, title="Stop Loss pip") input_minsizebody = input(3, title="Min. Size Body pip") barcolor(abs(close- open) >= input_minsizebody ? close[1] > open[1] ? open > close ? open <= close[1] ? open[1] <= close ? open - close < close[1] - open[1] ? yellow :na :na : na : na : na : na) pos = 0.0 barcolor(nz(pos[1], 0) == -1 ? red: nz(pos[1], 0) == 1 ? green : blue ) posprice = 0.0 posprice := abs( close - open) >= input_minsizebody? close[1] > open[1] ? open > close ? open <= close[1] ? open[1] <= close ? open - close < close[1] - open[1] ? close :nz(posprice[1], 0) :nz(posprice[1], 0) : nz(posprice[1], 0) : nz(posprice[1], 0) : nz(posprice[1], 0): nz(posprice[1], 0) pos := iff(posprice > 0, -1, 0) if (pos == 0) strategy.close_all() if (pos == -1) strategy.entry("Short", strategy.short) posprice := iff(low <= posprice - input_takeprofit and posprice > 0, 0 , nz(posprice, 0)) posprice := iff(high >= posprice + input_stoploss and posprice > 0, 0 , nz(posprice, 0))