The resource loading... loading...

Inside Bar Breakout Strategy

Author: ChaoZhang, Date: 2024-02-26 12:16:52
Tags:

img

Overview

The inside bar breakout strategy is a trend following strategy based on candlestick patterns. It uses the inside bar and outside bar candlestick patterns to determine the trend direction and enters positions on breakouts.

Strategy Logic

The main logic behind this strategy is identifying two types of candlestick patterns:

  1. Inside bar: When the high of current bar is lower than the previous high and the low is higher than the previous low, it indicates a price contraction.

  2. Outside bar: When the high of current bar is higher than the previous high and the low is lower than the previous low, it indicates a price expansion.

When either pattern is identified, it signals a potential entry. On the next bar after the signal bar, if open price breaks above previous high, go long. If open price breaks below previous low, go short.

After entry, take profit and stop loss orders will be placed. The specific algorithms are:

Take Profit = (Current Close Price x Target Profit Percentage) / Minimum Price Tick Stop Loss = (Current Close Price x Stop Loss Percentage) / Minimum Price Tick

By doing this, it can secure profits after hitting take profit level and limit losses below maximum tolerable amount when hitting stop loss.

Advantage Analysis

The advantages of this strategy are:

  1. Inside and outside bar patterns are quite reliable for determining trend direction.

  2. Breakout entry increases certainty and avoids some false breakouts.

  3. Fully automated without manual intervention. Reduces operational risks.

Risk Analysis

Some risks also exist with this strategy:

  1. Candlestick pattern identification not always accurate. Potential for wrong signals.

  2. Breakout entry prone to getting trapped. Stop loss may need adjustment.

  3. Improper parameter settings can lead to amplified losses. Requires robust optimization.

Improvement Areas

Some ways to improve the strategy include:

  1. Adding filters to reduce false signals, e.g. volume filter.

  2. Optimizing dynamic take profit and stop loss algorithms.

  3. Incorporating anti-reverse stop loss.

  4. Utilizing machine learning to auto optimize parameters.

Conclusion

The inside bar breakout strategy is an overall reliable and easy-to-implement trend following method. It takes advantage of the predictive power of inside bar and outside patterns combined with the higher certainty of breakout entries. With simple straightforward logic, it is beginner friendly in algorithmic trading. Further enhancements in optimization and automation will lead to more stable and intelligent trading results.


/*backtest
start: 2023-02-19 00:00:00
end: 2024-02-25 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("inside bar strategy  Wıth SL-TP ", overlay=true )



insides = high < high[1] and low > low[1]
outsides = high > high[1] and low < low[1]

candle_control=insides or outsides


target_profit_percent=input(3,"target profit%",step=0.1)
stop_loss_percent=input(1,"stop loss %",step=0.1)



yearfrom = input(2021)
yearuntil =input(2022)
monthfrom =input(1)
monthuntil =input(12)
dayfrom=input(1)
dayuntil=input(31)


long_cond=candle_control[1] and close>open and high>high[1]
short_cond=candle_control[1] and close<open and low<low[1]



if ( long_cond ) 
    strategy.entry("LONG", strategy.long, stop=close, oca_name="TREND",  comment="LONG")
    
else
    strategy.cancel(id="LONG")


if (  short_cond ) 

    strategy.entry("SHORT", strategy.short,stop=close, oca_name="TREND", comment="SHORT")
else
    strategy.cancel(id="SHORT")
    
    
    
    
profit_target=(close*(target_profit_percent/100))/syminfo.mintick
stop_target=(close*(stop_loss_percent/100))/syminfo.mintick


strategy.exit("LONG EXIT","LONG",profit=profit_target, loss=stop_target ) 
    
strategy.exit("LONG EXIT","SHORT",profit=profit_target, loss=stop_target ) 


More