Type/to search

Candlestick Pattern Strategy

Cryptocurrency
Created: 2023-11-27 18:26:52
Last modified: 3 years ago
1
Follow
1778
Followers

img
Candlestick Pattern Strategy

Overview

The candlestick pattern strategy is a strategy that makes trading decisions based on candlestick patterns. This strategy can detect various common candlestick patterns, including engulfing patterns, harami patterns, morning stars, three black crows, etc., and generates trading signals when these patterns are detected. The strategy also supports custom stop loss, take profit, and trailing stop parameters to effectively control risks.

Strategy Principle

The core logic of this strategy is to identify different types of candlestick patterns through conditional judgments in Pine Script code. For example, the code logic to judge the engulfing pattern is:

pine
bullish_engulfing = high[0]>high[1] and low[0]<low[1] and open[0]<open[1] and close[0]>close[1] and close[0]>open[0] and close[1]<close[2] and close[0]>open[1]

The above logic judges the relationship between the high, low, open, close prices of the current K-line and previous two K-lines. If it meets the definition of engulfing pattern, it returns true. The judgments of other candlestick patterns are similar.

When a qualified candlestick pattern is identified, the corresponding long or short trading signal variable will be set to true. Then during the trading session, the strategy will check if the trading signal is triggered. If triggered, it will place order and set stop loss, take profit and trailing stop to control risks.

Advantage Analysis

  • Support many common candlestick patterns, wide coverage
  • Customizable risk control parameters, high flexibility
  • Contains multiple plotting tools to clearly identify patterns
  • Combine with true trend of K-lines to avoid being trapped

Risks and Solutions

  • Candlestick patterns are not always reliable signals

    Solution: Combine with trend indicators, avoid using during range-bound markets

  • A single pattern may have false signals

    Solution: Appropriately filter out signals from very short-term patterns

  • Improper parameter settings may amplify losses

    Solution: Strictly set stop loss and take profit parameters based on risk tolerance

Optimization Directions

  • Add trend judgment to avoid patterns against the trend
  • Filter signals with other indicators
  • Optimize pattern parameters to reduce false signals
  • Combine machine learning algorithms to build more reliable pattern recognition

Summary

The candlestick pattern strategy identifies short-term turning points using technical analysis graphics, which is a common short-term strategy. This strategy supports multiple patterns and customizable risk control, very flexible to use. But the reliability of pattern signals is not high. It cannot be used alone and needs to work with trend and other factors to maximize its value.

Source
Pine
/*backtest
start: 2023-11-19 00:00:00
end: 2023-11-24 02:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4

//DanyChe
//The script allows you to test popular candlestick patterns on various instruments and timeframes. In addition, you can configure risk management (if the value is zero, it means the function is disabled), and you can also specify the time of the trading session (for example, so that the positions are not transferred to the next day). 
Strategy parameters
Strategy parameters
Engulfing
Harami
Piercing Line / Dark Cloud Cover
Morning Star / Evening Star
Belt Hold
Three White Soldiers / Three Black Crows
Three Stars in the South
Stick Sandwich
Meeting Line
Kicking
Ladder Bottom
Stop Loss
Take Profit
Trailing Stop
Trading session
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)